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
129```129```
130 130
131## PHP131## PHP
132Click 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/`.
132 133
134Or run the following commands in your terminal:
135
136```sh
137curl https://www.php.net/distributions/manual/php_manual_en.tar.gz > php.tar; \
138tar -xf php.tar; mv php-chunked-xhtml/ path/to/devdocs/docs/php/
139```
133## Python140## Python
134 141
135### Versions 3.6+142### Versions 3.6+
lib/docs/filters/php/clean_html.rb+7−16
@@ -1,6 +1,8 @@
1# coding: utf-8
1module Docs2module Docs
2 class Php3 class Php
3 class CleanHtmlFilter < Filter4 class CleanHtmlFilter < Filter
5
4 def call6 def call
5 root_page? ? root : other7 root_page? ? root : other
6 doc8 doc
@@ -11,24 +13,11 @@ module Docs · 4 unmodified lines
11 end13 end
12 14
13 def other15 def other
14 css('.manualnavbar:first-child', '.manualnavbar .up', '.manualnavbar .home', 'hr').remove16 # css('.manualnavbar:first-child', '.manualnavbar .up', '.manualnavbar .home', 'hr').remove
15 17
16 nav = at_css('.manualnavbar').remove18 css('#breadcrumbs').remove
17 19
18 if prev_link = nav.at_css('.prev a')20 css('.nav').remove
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
32 21
33 # Remove code highlighting22 # Remove code highlighting
34 br = /<br\s?\/?>/i23 br = /<br\s?\/?>/i
@@ -50,7 +39,9 @@ module Docs · 15 unmodified lines
50 css('.title + .verinfo + .title').each do |node|39 css('.title + .verinfo + .title').each do |node|
51 node.after(node.previous_element)40 node.after(node.previous_element)
52 end41 end
42
53 end43 end
44
54 end45 end
55 end46 end
56end47end
lib/docs/filters/php/entries.rb+17−8
@@ -12,7 +12,6 @@ module Docs · 11 unmodified lines
12 'Exception' => 'Predefined Exceptions',12 'Exception' => 'Predefined Exceptions',
13 'Http' => 'HTTP',13 'Http' => 'HTTP',
14 'Json' => 'JSON',14 'Json' => 'JSON',
15 'Lua' => 'Lua',
16 'Mutex' => 'pthreads',15 'Mutex' => 'pthreads',
17 'php_user_filter' => 'Stream',16 'php_user_filter' => 'Stream',
18 'Pool' => 'pthreads',17 'Pool' => 'pthreads',
@@ -31,11 +30,14 @@ module Docs · 12 unmodified lines
31 'Weak' => 'Weakref',30 'Weak' => 'Weakref',
32 'Worker' => 'pthreads',31 'Worker' => 'pthreads',
33 'XsltProcessor' => 'XSLT',32 'XsltProcessor' => 'XSLT',
34 'Yar' => 'Yar',33 'ZipArchive' => 'Zip',
35 'ZipArchive' => 'Zip' }34 'Rar' => 'Rar',
35 'Direct IO' => 'Dio',
36 'Zoo' => 'Zookeeper'
37 }
36 38
37 %w(APC Directory DOM Event Gearman Gmagick Imagick mysqli OAuth PDO Phar Reflection39 %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|
39 TYPE_BY_NAME_STARTS_WITH[str] = str41 TYPE_BY_NAME_STARTS_WITH[str] = str
40 end42 end
41 43
@@ -76,7 +78,7 @@ module Docs · 34 unmodified lines
76 TYPE_GROUPS = {78 TYPE_GROUPS = {
77 'Classes and Functions' => ['Classes/Object', 'Function handling', 'Predefined Interfaces and Classes', 'runkit', 'Throwable'],79 'Classes and Functions' => ['Classes/Object', 'Function handling', 'Predefined Interfaces and Classes', 'runkit', 'Throwable'],
78 'Encoding' => ['Gettext', 'iconv', 'Multibyte String'],80 'Encoding' => ['Gettext', 'iconv', 'Multibyte String'],
79 'Compression' => ['Bzip2', 'Zip', 'Zlib'],81 'Compression' => ['Bzip2', 'Zip', 'Zlib', 'Rar'],
80 'Cryptography' => ['Hash', 'Mcrypt', 'OpenSSL', 'Password Hashing'],82 'Cryptography' => ['Hash', 'Mcrypt', 'OpenSSL', 'Password Hashing'],
81 'Database' => ['DBA', 'ODBC', 'PDO'],83 'Database' => ['DBA', 'ODBC', 'PDO'],
82 'Date and Time' => ['Calendar', 'Date/Time'],84 'Date and Time' => ['Calendar', 'Date/Time'],
@@ -94,7 +96,13 @@ module Docs · 11 unmodified lines
94 96
95 def get_name97 def get_name
96 return 'IntlException' if slug == 'class.intlexception'98 return 'IntlException' if slug == 'class.intlexception'
97 name = css('> .sect1 > .title', 'h1', 'h2').first.content99
100 if at_css('h1')
101 name = at_css('h1').content.strip
102 else
103 name = at_css('h2').content.strip
104 end
105
98 name.remove! 'The '106 name.remove! 'The '
99 name.sub! ' class', ' (class)'107 name.sub! ' class', ' (class)'
100 name.sub! ' interface', ' (interface)'108 name.sub! ' interface', ' (interface)'
@@ -102,10 +110,10 @@ module Docs · 1 unmodified line
102 end110 end
103 111
104 def get_type112 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')
106 return 'PCRE Reference' if subpath.start_with?('regexp.')114 return 'PCRE Reference' if subpath.start_with?('regexp.')
107 115
108 type = at_css('.up').content.strip116 type = at_css('.breadcrumbs-container li ~ li').content.strip
109 type = 'SPL/Iterators' if type.end_with? 'Iterator'117 type = 'SPL/Iterators' if type.end_with? 'Iterator'
110 type = 'Ev' if type =~ /\AEv[A-Z]/118 type = 'Ev' if type =~ /\AEv[A-Z]/
111 type.remove! ' Functions'119 type.remove! ' Functions'
@@ -167,6 +175,7 @@ module Docs · 55 unmodified lines
167 def include_default_entry?175 def include_default_entry?
168 !initial_page? && doc.at_css('.reference', '.refentry', '.sect1', '.simpara', '.para')176 !initial_page? && doc.at_css('.reference', '.refentry', '.sect1', '.simpara', '.para')
169 end177 end
178
170 end179 end
171 end180 end
172end181end
lib/docs/filters/php/fix_urls.rb+1−1
@@ -3,7 +3,7 @@ module Docs · 2 unmodified lines
3 class FixUrlsFilter < Filter3 class FixUrlsFilter < Filter
4 def call4 def call
5 html.gsub! File.join(Php.base_url, Php.root_path), Php.base_url5 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'
7 html7 html
8 end8 end
9 end9 end
lib/docs/scrapers/php.rb+14−14
@@ -1,13 +1,12 @@
1module Docs1module Docs
2 class Php < FileScraper2 class Php < FileScraper
3 # Downloaded from php.net/download-docs.php3 # Downloaded from php.net/download-docs.php
4
5 include FixInternalUrlsBehavior4 include FixInternalUrlsBehavior
6 5
7 self.name = 'PHP'6 self.name = 'PHP'
8 self.type = 'php'7 self.type = 'php'
9 self.release = '7.2.9'8 self.release = '8.0'
10 self.base_url = 'https://secure.php.net/manual/en/'9 self.base_url = 'https://www.php.net/manual/en/'
11 self.root_path = 'index.html'10 self.root_path = 'index.html'
12 self.initial_paths = %w(11 self.initial_paths = %w(
13 funcref.html12 funcref.html
@@ -21,7 +20,7 @@ module Docs · 7 unmodified lines
21 reserved.variables.html)20 reserved.variables.html)
22 21
23 self.links = {22 self.links = {
24 home: 'https://secure.php.net/',23 home: 'https://www.php.net/',
25 code: 'https://git.php.net/?p=php-src.git;a=summary'24 code: 'https://git.php.net/?p=php-src.git;a=summary'
26 }25 }
27 26
@@ -42,15 +41,15 @@ module Docs · 14 unmodified lines
42 /\Areserved\.interfaces/,41 /\Areserved\.interfaces/,
43 /\Areserved\.variables/]42 /\Areserved\.variables/]
44 43
45 BOOKS = %w(apache apc apcu array bc bzip2 calendar csprng classobj ctype curl44 BOOKS = %w(apache apc apcu array bc blenc bzip2 calendar csprng componere classobj ctype curl
46 datetime dba dir dom ds eio errorfunc ev event exec exif fileinfo filesystem filter45 datetime dba dbx dir dio dom ds eio errorfunc enchant ev event exec exif fileinfo filesystem filter
47 ftp funchand gearman geoip gettext gmagick gmp hash ibase iconv iisfunc image46 fdf ftp funchand fpm gearman geoip gettext gmagick gmp gnupg hash ibase iconv iisfunc image
48 imagick imap info inotify intl json judy ldap libevent libxml lua mail mailparse47 imagick imap info inotify intl iisfunc json judy ldap libevent libxml lua lzf mail mailparse
49 math mbstring mcrypt memcached misc mysqli network oauth openssl48 math mhash mbstring mcrypt memcached misc mysqli ncurses network nsapi oauth openssl openal opcache
50 outcontrol password pcntl pcre pdo pgsql phar posix proctitle pthreads quickhash regex runkit49 outcontrol password parle pcntl phpdbg pcre pdo pgsql phar posix proctitle pspell pthreads quickhash recode regex runkit runkit7 radius rar
51 reflection sca session sem session-pgsql shmop simplexml soap sockets solr sphinx spl50 reflection readline sca session sem session-pgsql shmop simplexml ssdeep sdo sdodasrel sdo-das-xml sodium soap sockets solr snmp sphinx spl stomp
52 spl-types sqlite3 sqlsrv ssh2 stats stream strings sync taint tidy tokenizer uodbc url51 spl-types sqlite3 sqlsrv ssh2 stats stream strings sync svm svn taint tidy tokenizer uodbc url uopz
53 v8js var varnish weakref xml xmlreader xmlrpc xmlwriter xsl yaf yar yaml zip zlib)52 v8js var varnish wddx weakref wincache xattr xdiff xhprof xml xmlreader xmlrpc xmlwriter xsl yaf yar yaml yac zip zookeeper zlib)
54 53
55 options[:only] = BOOKS.map { |s| "book.#{s}.html" }54 options[:only] = BOOKS.map { |s| "book.#{s}.html" }
56 55
@@ -63,7 +62,7 @@ module Docs · 6 unmodified lines
63 options[:skip_patterns] = [/mysqlnd/, /xdevapi/i]62 options[:skip_patterns] = [/mysqlnd/, /xdevapi/i]
64 63
65 options[:attribution] = <<-HTML64 options[:attribution] = <<-HTML
66 &copy; 1997&ndash;2018 The PHP Documentation Group<br>65 &copy; 1997&ndash;2020 The PHP Documentation Group<br>
67 Licensed under the Creative Commons Attribution License v3.0 or later.66 Licensed under the Creative Commons Attribution License v3.0 or later.
68 HTML67 HTML
69 68
@@ -71,5 +70,6 @@ module Docs · 1 unmodified line
71 doc = fetch_doc('https://www.php.net/supported-versions.php', opts)70 doc = fetch_doc('https://www.php.net/supported-versions.php', opts)
72 doc.at_css('table > tbody > .stable:last-of-type > td > a').content.strip71 doc.at_css('table > tbody > .stable:last-of-type > td > a').content.strip
73 end72 end
73
74 end74 end
75end75end