History

Update PHP documentation (7.1.0)

Thibaut Courouble committed 9 years ago

Commit bd2224b1 parent 3a18fe64 files · +72 −9Browse files

Unified · Split

4 files
  1. assets/stylesheets/pages/_php.scss +5 −0
  2. lib/docs/filters/php/clean_html.rb +14 −2
  3. lib/docs/filters/php/entries.rb +47 −1
  4. lib/docs/scrapers/php.rb +6 −6
assets/stylesheets/pages/_php.scss+5−0
@@ -7,6 +7,10 @@ · 6 unmodified lines
77 h2 { @extend %block-heading; }
88 h3.title { @extend %block-heading; }
99
10+ .manualnavbar {
11+ margin-top: 1rem;
12+ }
13+
1014 .verinfo {
1115 float: right;
1216 font-weight: bold;
@@ -28,6 +32,7 @@ · 15 unmodified lines
2832 blockquote.note > p { margin-bottom: 0; }
2933
3034 div.warning { @extend %note, %note-red; }
35+ div.caution { @extend %note, %note-orange; }
3136 div.tip { @extend %note, %note-green; }
3237
3338 strong > code, dt > code { @extend %label; }
lib/docs/filters/php/clean_html.rb+14−2
@@ -11,16 +11,28 @@ module Docs · 10 unmodified lines
1111 end
1212
1313 def other
14− css('.manualnavbar', 'hr').remove
14+ css('.manualnavbar:first-child', '.manualnavbar .up', '.manualnavbar .home', 'hr').remove
15+
16+ nav = at_css('.manualnavbar').remove
17+
18+ if prev_link = nav.at_css('.prev a')
19+ prev_link.content = "← #{prev_link.content}"
20+ end
21+
22+ if next_link = nav.at_css('.next a')
23+ next_link.content = "#{next_link.content} →"
24+ end
1525
1626 # Remove top-level <div>
1727 if doc.elements.length == 1
1828 @doc = doc.first_element_child
1929 end
2030
31+ doc << nav
32+
2133 # Remove code highlighting
2234 br = /<br\s?\/?>/i
23− css('.phpcode').each do |node|
35+ css('.phpcode', 'div.methodsynopsis').each do |node|
2436 node.name = 'pre'
2537 node.inner_html = node.inner_html.gsub(br, "\n")
2638 node.content = node.content.strip
lib/docs/filters/php/entries.rb+47−1
@@ -7,6 +7,7 @@ module Docs · 6 unmodified lines
77 'Cond' => 'pthreads',
88 'CURL' => 'cURL',
99 'Date' => 'Date/Time',
10+ 'Ds' => 'Data Structures',
1011 'ErrorException' => 'Predefined Exceptions',
1112 'Exception' => 'Predefined Exceptions',
1213 'Json' => 'JSON',
@@ -14,6 +15,7 @@ module Docs · 1 unmodified line
1415 'Mutex' => 'pthreads',
1516 'php_user_filter' => 'Stream',
1617 'Pool' => 'pthreads',
18+ 'QuickHash' => 'Quickhash',
1719 'Reflector' => 'Reflection',
1820 'Soap' => 'SOAP',
1921 'SplFile' => 'SPL/File',
@@ -24,6 +26,7 @@ module Docs · 4 unmodified lines
2426 'streamWrapper' => 'Stream',
2527 'Thread' => 'pthreads',
2628 'tidy' => 'Tidy',
29+ 'Weak' => 'Weakref',
2730 'Worker' => 'pthreads',
2831 'XsltProcessor' => 'XSLT',
2932 'Yar' => 'Yar',
@@ -48,8 +51,10 @@ module Docs · 18 unmodified lines
4851 end
4952
5053 REPLACE_TYPES = {
54+ 'APCu' => 'APC',
5155 'Error' => 'Errors',
5256 'Exceptions' => 'SPL/Exceptions',
57+ 'Exif' => 'Image/Exif',
5358 'finfo' => 'File System',
5459 'GD and Image' => 'Image',
5560 'Gmagick' => 'Image/GraphicsMagick',
@@ -74,7 +79,7 @@ module Docs · 18 unmodified lines
7479 'Database' => ['DBA', 'ODBC', 'PDO'],
7580 'Date and Time' => ['Calendar', 'Date/Time'],
7681 'Errors' => ['Error Handling', 'Predefined Exceptions'],
77− 'File System' => ['Directory', 'Fileinfo', 'Filesystem', 'Inotify'],
82+ 'File System' => ['Directory', 'Fileinfo', 'Filesystem', 'Inotify', 'Proctitle'],
7883 'HTML' => ['DOM', 'Tidy'],
7984 'Language' => ['Control Structures', 'Misc.', 'PHP Options/Info', 'Predefined Variables'],
8085 'Mail' => ['Mail', 'Mailparse'],
@@ -116,6 +121,47 @@ module Docs · 35 unmodified lines
116121 REPLACE_TYPES[type] || type
117122 end
118123
124+ ALIASES = {
125+ 'language.oop5.traits' => ['trait'],
126+ 'language.operators.type' => ['instanceof'],
127+ 'functions.user-defined' => ['function'],
128+ 'language.oop5.visibility' => ['public', 'private', 'protected'],
129+ 'language.references.whatdo' => ['=&'],
130+ 'language.oop5.static' => ['static'],
131+ 'language.oop5.interfaces' => ['interface', 'implements'],
132+ 'language.oop5.inheritance' => ['extends'],
133+ 'language.oop5.cloning' => ['clone', '__clone()'],
134+ 'language.operators.logical' => ['and', 'or', 'xor'],
135+ 'language.operators.increment' => ['++', '--'],
136+ 'language.generators.syntax' => ['yield'],
137+ 'language.oop5.final' => ['final'],
138+ 'language.exceptions' => ['try', 'catch', 'finally'],
139+ 'language.oop5.decon' => ['__construct()', '__destruct()'],
140+ 'language.operators.comparison' => ['==', '===', '!=', '<>', '!==', '<=>'],
141+ 'language.oop5.abstract' => ['abstract'],
142+ 'language.operators.bitwise' => ['&', '|', '^', '~', '<<', '>>']
143+ }
144+
145+ def additional_entries
146+ if aliases = ALIASES[slug]
147+ aliases.map { |a| [a] }
148+ elsif slug == 'language.constants.predefined'
149+ css('table tr[id]').map do |node|
150+ [node.at_css('code').content, node['id']]
151+ end
152+ elsif slug == 'language.oop5.magic'
153+ css('h3 a').map do |node|
154+ [node.content, node['href'][/#(.+)/, 1]]
155+ end
156+ elsif slug == 'language.oop5.overloading'
157+ css('.methodsynopsis[id]').map do |node|
158+ [node.at_css('.methodname').content + '()', node['id']]
159+ end
160+ else
161+ []
162+ end
163+ end
164+
119165 def include_default_entry?
120166 !initial_page? && doc.at_css('.reference', '.refentry', '.sect1', '.simpara', '.para')
121167 end
lib/docs/scrapers/php.rb+6−6
@@ -4,7 +4,7 @@ module Docs · 3 unmodified lines
44
55 self.name = 'PHP'
66 self.type = 'php'
7− self.release = 'up to 7.0.11'
7+ self.release = 'up to 7.1.0'
88 self.base_url = 'https://secure.php.net/manual/en/'
99 self.root_path = 'index.html'
1010 self.initial_paths = %w(
@@ -43,15 +43,15 @@ module Docs · 32 unmodified lines
4343 /\Areserved\.interfaces/,
4444 /\Areserved\.variables/]
4545
46− BOOKS = %w(apache apc array bc bzip2 calendar csprng classobj ctype curl
47− datetime dba dir dom eio errorfunc ev event exec fileinfo filesystem filter
46+ BOOKS = %w(apache apc apcu array bc bzip2 calendar csprng classobj ctype curl
47+ datetime dba dir dom ds eio errorfunc ev event exec exif fileinfo filesystem filter
4848 ftp funchand gearman geoip gettext gmagick gmp hash iconv iisfunc image
4949 imagick imap info inotify intl json ldap libevent libxml mail mailparse
5050 math mbstring mcrypt memcached misc mysqli network oauth openssl
51− outcontrol password pcntl pcre pdo pgsql phar posix pthreads regex runkit reflection
52− sca session sem session-pgsql shmop simplexml soap sockets solr sphinx spl
51+ outcontrol password pcntl pcre pdo pgsql phar posix proctitle pthreads quickhash regex runkit
52+ reflection sca session sem session-pgsql shmop simplexml soap sockets solr sphinx spl
5353 spl-types sqlite3 sqlsrv ssh2 stats stream strings sync taint tidy uodbc url
54− var varnish xml xmlreader xmlrpc xmlwriter xsl yaf yar yaml zip zlib)
54+ var varnish weakref xml xmlreader xmlrpc xmlwriter xsl yaf yar yaml zip zlib)
5555
5656 options[:only] = BOOKS.map { |s| "book.#{s}.html" }
5757