History

Merge pull request #1446 from MasterEnoc/php

Update PHP to 8.0

Simon Legner committed 5 years ago

Commit e8e035d2 parents f523dc6 49b597f5 files · +46 −39Browse files

Unified · Split

5 files
  1. docs/file-scrapers.md +7 −0
  2. lib/docs/filters/php/clean_html.rb +7 −16
  3. lib/docs/filters/php/entries.rb +17 −8
  4. lib/docs/filters/php/fix_urls.rb +1 −1
  5. lib/docs/scrapers/php.rb +14 −14
docs/file-scrapers.md+7−0
@@ -129,7 +129,14 @@ bsdtar --extract --xz --file - --strip-components=6 --directory=docs/openjdk\~8/ · 128 unmodified lines
129129 ```
130130
131131 ## PHP
132+Click the link under the "Many HTML files" column on https://www.php.net/download-docs.php, extract the tarball, change its name to `php` and put it in `/path/to/devdocs/docs/`.
132133
134+Or run the following commands in your terminal:
135+
136+```sh
137+curl https://www.php.net/distributions/manual/php_manual_en.tar.gz > php.tar; \
138+tar -xf php.tar; mv php-chunked-xhtml/ path/to/devdocs/docs/php/
139+```
133140 ## Python
134141
135142 ### Versions 3.6+
lib/docs/filters/php/clean_html.rb+7−16
@@ -1,6 +1,8 @@
1+# coding: utf-8
12 module Docs
23 class Php
34 class CleanHtmlFilter < Filter
5+
46 def call
57 root_page? ? root : other
68 doc
@@ -11,24 +13,11 @@ module Docs · 4 unmodified lines
1113 end
1214
1315 def other
14− css('.manualnavbar:first-child', '.manualnavbar .up', '.manualnavbar .home', 'hr').remove
16+ # css('.manualnavbar:first-child', '.manualnavbar .up', '.manualnavbar .home', 'hr').remove
1517
16− nav = at_css('.manualnavbar').remove
18+ css('#breadcrumbs').remove
1719
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
25−
26− # Remove top-level <div>
27− if doc.elements.length == 1
28− @doc = doc.first_element_child
29− end
30−
31− doc << nav
20+ css('.nav').remove
3221
3322 # Remove code highlighting
3423 br = /<br\s?\/?>/i
@@ -50,7 +39,9 @@ module Docs · 15 unmodified lines
5039 css('.title + .verinfo + .title').each do |node|
5140 node.after(node.previous_element)
5241 end
42+
5343 end
44+
5445 end
5546 end
5647 end
lib/docs/filters/php/entries.rb+17−8
@@ -12,7 +12,6 @@ module Docs · 11 unmodified lines
1212 'Exception' => 'Predefined Exceptions',
1313 'Http' => 'HTTP',
1414 'Json' => 'JSON',
15− 'Lua' => 'Lua',
1615 'Mutex' => 'pthreads',
1716 'php_user_filter' => 'Stream',
1817 'Pool' => 'pthreads',
@@ -31,11 +30,14 @@ module Docs · 12 unmodified lines
3130 'Weak' => 'Weakref',
3231 'Worker' => 'pthreads',
3332 'XsltProcessor' => 'XSLT',
34− 'Yar' => 'Yar',
35− 'ZipArchive' => 'Zip' }
33+ 'ZipArchive' => 'Zip',
34+ 'Rar' => 'Rar',
35+ 'Direct IO' => 'Dio',
36+ 'Zoo' => 'Zookeeper'
37+ }
3638
3739 %w(APC Directory DOM Event Gearman Gmagick Imagick mysqli OAuth PDO Phar Reflection
38− Session SimpleXML Solr Sphinx SQLite3 Varnish XSLT Yaf).each do |str|
40+ Session SimpleXML Solr Sphinx SQLite3 Varnish XSLT Yaf OpenAL Blenc Componere OPcache phpdbg runkit7 Uopz WinCache Xhprof Yac Radius Ncurses Readline Lzf Mhash Sodium SVM dbx FPM xattr xdiff Enchant Pspell Parle Recode FDF GnuPG ssdeep Yar Lua Stomp SPL zookeeper SDO).each do |str|
3941 TYPE_BY_NAME_STARTS_WITH[str] = str
4042 end
4143
@@ -76,7 +78,7 @@ module Docs · 34 unmodified lines
7678 TYPE_GROUPS = {
7779 'Classes and Functions' => ['Classes/Object', 'Function handling', 'Predefined Interfaces and Classes', 'runkit', 'Throwable'],
7880 'Encoding' => ['Gettext', 'iconv', 'Multibyte String'],
79− 'Compression' => ['Bzip2', 'Zip', 'Zlib'],
81+ 'Compression' => ['Bzip2', 'Zip', 'Zlib', 'Rar'],
8082 'Cryptography' => ['Hash', 'Mcrypt', 'OpenSSL', 'Password Hashing'],
8183 'Database' => ['DBA', 'ODBC', 'PDO'],
8284 'Date and Time' => ['Calendar', 'Date/Time'],
@@ -94,7 +96,13 @@ module Docs · 11 unmodified lines
9496
9597 def get_name
9698 return 'IntlException' if slug == 'class.intlexception'
97− name = css('> .sect1 > .title', 'h1', 'h2').first.content
99+
100+ if at_css('h1')
101+ name = at_css('h1').content.strip
102+ else
103+ name = at_css('h2').content.strip
104+ end
105+
98106 name.remove! 'The '
99107 name.sub! ' class', ' (class)'
100108 name.sub! ' interface', ' (interface)'
@@ -102,10 +110,10 @@ module Docs · 1 unmodified line
102110 end
103111
104112 def get_type
105− return 'Language Reference' if subpath.start_with?('language.') || subpath.start_with?('functions.')
113+ return 'Language Reference' if subpath.start_with?('language.') || subpath.start_with?('functions.') || subpath.start_with?('reserved')
106114 return 'PCRE Reference' if subpath.start_with?('regexp.')
107115
108− type = at_css('.up').content.strip
116+ type = at_css('.breadcrumbs-container li ~ li').content.strip
109117 type = 'SPL/Iterators' if type.end_with? 'Iterator'
110118 type = 'Ev' if type =~ /\AEv[A-Z]/
111119 type.remove! ' Functions'
@@ -167,6 +175,7 @@ module Docs · 55 unmodified lines
167175 def include_default_entry?
168176 !initial_page? && doc.at_css('.reference', '.refentry', '.sect1', '.simpara', '.para')
169177 end
178+
170179 end
171180 end
172181 end
lib/docs/filters/php/fix_urls.rb+1−1
@@ -3,7 +3,7 @@ module Docs · 2 unmodified lines
33 class FixUrlsFilter < Filter
44 def call
55 html.gsub! File.join(Php.base_url, Php.root_path), Php.base_url
6− html.gsub! %r{https://secure\.php\.net/manual/en/([^"']+?)\.html}, 'https://secure.php.net/manual/en/\1.php'
6+ html.gsub! %r{https://www.php\.net/manual/en/([^"']+?)\.html}, 'https://www.php.net/manual/en/\1.php'
77 html
88 end
99 end
lib/docs/scrapers/php.rb+14−14
@@ -1,13 +1,12 @@
11 module Docs
22 class Php < FileScraper
33 # Downloaded from php.net/download-docs.php
4−
54 include FixInternalUrlsBehavior
65
76 self.name = 'PHP'
87 self.type = 'php'
9− self.release = '7.2.9'
10− self.base_url = 'https://secure.php.net/manual/en/'
8+ self.release = '8.0'
9+ self.base_url = 'https://www.php.net/manual/en/'
1110 self.root_path = 'index.html'
1211 self.initial_paths = %w(
1312 funcref.html
@@ -21,7 +20,7 @@ module Docs · 7 unmodified lines
2120 reserved.variables.html)
2221
2322 self.links = {
24− home: 'https://secure.php.net/',
23+ home: 'https://www.php.net/',
2524 code: 'https://git.php.net/?p=php-src.git;a=summary'
2625 }
2726
@@ -42,15 +41,15 @@ module Docs · 14 unmodified lines
4241 /\Areserved\.interfaces/,
4342 /\Areserved\.variables/]
4443
45− BOOKS = %w(apache apc apcu array bc bzip2 calendar csprng classobj ctype curl
46− datetime dba dir dom ds eio errorfunc ev event exec exif fileinfo filesystem filter
47− ftp funchand gearman geoip gettext gmagick gmp hash ibase iconv iisfunc image
48− imagick imap info inotify intl json judy ldap libevent libxml lua mail mailparse
49− math mbstring mcrypt memcached misc mysqli network oauth openssl
50− outcontrol password pcntl pcre pdo pgsql phar posix proctitle pthreads quickhash regex runkit
51− reflection sca session sem session-pgsql shmop simplexml soap sockets solr sphinx spl
52− spl-types sqlite3 sqlsrv ssh2 stats stream strings sync taint tidy tokenizer uodbc url
53− v8js var varnish weakref xml xmlreader xmlrpc xmlwriter xsl yaf yar yaml zip zlib)
44+ BOOKS = %w(apache apc apcu array bc blenc bzip2 calendar csprng componere classobj ctype curl
45+ datetime dba dbx dir dio dom ds eio errorfunc enchant ev event exec exif fileinfo filesystem filter
46+ fdf ftp funchand fpm gearman geoip gettext gmagick gmp gnupg hash ibase iconv iisfunc image
47+ imagick imap info inotify intl iisfunc json judy ldap libevent libxml lua lzf mail mailparse
48+ math mhash mbstring mcrypt memcached misc mysqli ncurses network nsapi oauth openssl openal opcache
49+ outcontrol password parle pcntl phpdbg pcre pdo pgsql phar posix proctitle pspell pthreads quickhash recode regex runkit runkit7 radius rar
50+ reflection readline sca session sem session-pgsql shmop simplexml ssdeep sdo sdodasrel sdo-das-xml sodium soap sockets solr snmp sphinx spl stomp
51+ spl-types sqlite3 sqlsrv ssh2 stats stream strings sync svm svn taint tidy tokenizer uodbc url uopz
52+ v8js var varnish wddx weakref wincache xattr xdiff xhprof xml xmlreader xmlrpc xmlwriter xsl yaf yar yaml yac zip zookeeper zlib)
5453
5554 options[:only] = BOOKS.map { |s| "book.#{s}.html" }
5655
@@ -63,7 +62,7 @@ module Docs · 6 unmodified lines
6362 options[:skip_patterns] = [/mysqlnd/, /xdevapi/i]
6463
6564 options[:attribution] = <<-HTML
66− &copy; 1997&ndash;2018 The PHP Documentation Group<br>
65+ &copy; 1997&ndash;2020 The PHP Documentation Group<br>
6766 Licensed under the Creative Commons Attribution License v3.0 or later.
6867 HTML
6968
@@ -71,5 +70,6 @@ module Docs · 1 unmodified line
7170 doc = fetch_doc('https://www.php.net/supported-versions.php', opts)
7271 doc.at_css('table > tbody > .stable:last-of-type > td > a').content.strip
7372 end
73+
7474 end
7575 end