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
7 h2 { @extend %block-heading; }7 h2 { @extend %block-heading; }
8 h3.title { @extend %block-heading; }8 h3.title { @extend %block-heading; }
9 9
10 .manualnavbar {
11 margin-top: 1rem;
12 }
13
10 .verinfo {14 .verinfo {
11 float: right;15 float: right;
12 font-weight: bold;16 font-weight: bold;
@@ -28,6 +32,7 @@ · 15 unmodified lines
28 blockquote.note > p { margin-bottom: 0; }32 blockquote.note > p { margin-bottom: 0; }
29 33
30 div.warning { @extend %note, %note-red; }34 div.warning { @extend %note, %note-red; }
35 div.caution { @extend %note, %note-orange; }
31 div.tip { @extend %note, %note-green; }36 div.tip { @extend %note, %note-green; }
32 37
33 strong > code, dt > code { @extend %label; }38 strong > code, dt > code { @extend %label; }
lib/docs/filters/php/clean_html.rb+14−2
@@ -11,16 +11,28 @@ module Docs · 10 unmodified lines
11 end11 end
12 12
13 def other13 def other
14 css('.manualnavbar', 'hr').remove14 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
15 25
16 # Remove top-level <div>26 # Remove top-level <div>
17 if doc.elements.length == 127 if doc.elements.length == 1
18 @doc = doc.first_element_child28 @doc = doc.first_element_child
19 end29 end
20 30
31 doc << nav
32
21 # Remove code highlighting33 # Remove code highlighting
22 br = /<br\s?\/?>/i34 br = /<br\s?\/?>/i
23 css('.phpcode').each do |node|35 css('.phpcode', 'div.methodsynopsis').each do |node|
24 node.name = 'pre'36 node.name = 'pre'
25 node.inner_html = node.inner_html.gsub(br, "\n")37 node.inner_html = node.inner_html.gsub(br, "\n")
26 node.content = node.content.strip38 node.content = node.content.strip
lib/docs/filters/php/entries.rb+47−1
@@ -7,6 +7,7 @@ module Docs · 6 unmodified lines
7 'Cond' => 'pthreads',7 'Cond' => 'pthreads',
8 'CURL' => 'cURL',8 'CURL' => 'cURL',
9 'Date' => 'Date/Time',9 'Date' => 'Date/Time',
10 'Ds' => 'Data Structures',
10 'ErrorException' => 'Predefined Exceptions',11 'ErrorException' => 'Predefined Exceptions',
11 'Exception' => 'Predefined Exceptions',12 'Exception' => 'Predefined Exceptions',
12 'Json' => 'JSON',13 'Json' => 'JSON',
@@ -14,6 +15,7 @@ module Docs · 1 unmodified line
14 'Mutex' => 'pthreads',15 'Mutex' => 'pthreads',
15 'php_user_filter' => 'Stream',16 'php_user_filter' => 'Stream',
16 'Pool' => 'pthreads',17 'Pool' => 'pthreads',
18 'QuickHash' => 'Quickhash',
17 'Reflector' => 'Reflection',19 'Reflector' => 'Reflection',
18 'Soap' => 'SOAP',20 'Soap' => 'SOAP',
19 'SplFile' => 'SPL/File',21 'SplFile' => 'SPL/File',
@@ -24,6 +26,7 @@ module Docs · 4 unmodified lines
24 'streamWrapper' => 'Stream',26 'streamWrapper' => 'Stream',
25 'Thread' => 'pthreads',27 'Thread' => 'pthreads',
26 'tidy' => 'Tidy',28 'tidy' => 'Tidy',
29 'Weak' => 'Weakref',
27 'Worker' => 'pthreads',30 'Worker' => 'pthreads',
28 'XsltProcessor' => 'XSLT',31 'XsltProcessor' => 'XSLT',
29 'Yar' => 'Yar',32 'Yar' => 'Yar',
@@ -48,8 +51,10 @@ module Docs · 18 unmodified lines
48 end51 end
49 52
50 REPLACE_TYPES = {53 REPLACE_TYPES = {
54 'APCu' => 'APC',
51 'Error' => 'Errors',55 'Error' => 'Errors',
52 'Exceptions' => 'SPL/Exceptions',56 'Exceptions' => 'SPL/Exceptions',
57 'Exif' => 'Image/Exif',
53 'finfo' => 'File System',58 'finfo' => 'File System',
54 'GD and Image' => 'Image',59 'GD and Image' => 'Image',
55 'Gmagick' => 'Image/GraphicsMagick',60 'Gmagick' => 'Image/GraphicsMagick',
@@ -74,7 +79,7 @@ module Docs · 18 unmodified lines
74 'Database' => ['DBA', 'ODBC', 'PDO'],79 'Database' => ['DBA', 'ODBC', 'PDO'],
75 'Date and Time' => ['Calendar', 'Date/Time'],80 'Date and Time' => ['Calendar', 'Date/Time'],
76 'Errors' => ['Error Handling', 'Predefined Exceptions'],81 'Errors' => ['Error Handling', 'Predefined Exceptions'],
77 'File System' => ['Directory', 'Fileinfo', 'Filesystem', 'Inotify'],82 'File System' => ['Directory', 'Fileinfo', 'Filesystem', 'Inotify', 'Proctitle'],
78 'HTML' => ['DOM', 'Tidy'],83 'HTML' => ['DOM', 'Tidy'],
79 'Language' => ['Control Structures', 'Misc.', 'PHP Options/Info', 'Predefined Variables'],84 'Language' => ['Control Structures', 'Misc.', 'PHP Options/Info', 'Predefined Variables'],
80 'Mail' => ['Mail', 'Mailparse'],85 'Mail' => ['Mail', 'Mailparse'],
@@ -116,6 +121,47 @@ module Docs · 35 unmodified lines
116 REPLACE_TYPES[type] || type121 REPLACE_TYPES[type] || type
117 end122 end
118 123
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
119 def include_default_entry?165 def include_default_entry?
120 !initial_page? && doc.at_css('.reference', '.refentry', '.sect1', '.simpara', '.para')166 !initial_page? && doc.at_css('.reference', '.refentry', '.sect1', '.simpara', '.para')
121 end167 end
lib/docs/scrapers/php.rb+6−6
@@ -4,7 +4,7 @@ module Docs · 3 unmodified lines
4 4
5 self.name = 'PHP'5 self.name = 'PHP'
6 self.type = 'php'6 self.type = 'php'
7 self.release = 'up to 7.0.11'7 self.release = 'up to 7.1.0'
8 self.base_url = 'https://secure.php.net/manual/en/'8 self.base_url = 'https://secure.php.net/manual/en/'
9 self.root_path = 'index.html'9 self.root_path = 'index.html'
10 self.initial_paths = %w(10 self.initial_paths = %w(
@@ -43,15 +43,15 @@ module Docs · 32 unmodified lines
43 /\Areserved\.interfaces/,43 /\Areserved\.interfaces/,
44 /\Areserved\.variables/]44 /\Areserved\.variables/]
45 45
46 BOOKS = %w(apache apc array bc bzip2 calendar csprng classobj ctype curl46 BOOKS = %w(apache apc apcu array bc bzip2 calendar csprng classobj ctype curl
47 datetime dba dir dom eio errorfunc ev event exec fileinfo filesystem filter47 datetime dba dir dom ds eio errorfunc ev event exec exif fileinfo filesystem filter
48 ftp funchand gearman geoip gettext gmagick gmp hash iconv iisfunc image48 ftp funchand gearman geoip gettext gmagick gmp hash iconv iisfunc image
49 imagick imap info inotify intl json ldap libevent libxml mail mailparse49 imagick imap info inotify intl json ldap libevent libxml mail mailparse
50 math mbstring mcrypt memcached misc mysqli network oauth openssl50 math mbstring mcrypt memcached misc mysqli network oauth openssl
51 outcontrol password pcntl pcre pdo pgsql phar posix pthreads regex runkit reflection51 outcontrol password pcntl pcre pdo pgsql phar posix proctitle pthreads quickhash regex runkit
52 sca session sem session-pgsql shmop simplexml soap sockets solr sphinx spl52 reflection sca session sem session-pgsql shmop simplexml soap sockets solr sphinx spl
53 spl-types sqlite3 sqlsrv ssh2 stats stream strings sync taint tidy uodbc url53 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)
55 55
56 options[:only] = BOOKS.map { |s| "book.#{s}.html" }56 options[:only] = BOOKS.map { |s| "book.#{s}.html" }
57 57