Unified · Split
| @@ -311,7 +311,7 @@ credits = [ · 310 unmodified lines | |||
| 311 | 'https://raw.githubusercontent.com/phoenixframework/phoenix/master/LICENSE.md' | 311 | 'https://raw.githubusercontent.com/phoenixframework/phoenix/master/LICENSE.md' |
| 312 | ], [ | 312 | ], [ |
| 313 | 'PHP', | 313 | 'PHP', |
| 314 | '1997-2015 The PHP Documentation Group', | 314 | '1997-2016 The PHP Documentation Group', |
| 315 | 'CC BY', | 315 | 'CC BY', |
| 316 | 'https://creativecommons.org/licenses/by/3.0/' | 316 | 'https://creativecommons.org/licenses/by/3.0/' |
| 317 | ], [ | 317 | ], [ |
| @@ -4,6 +4,7 @@ · 3 unmodified lines | |||
| 4 | @extend %lined-heading; | 4 | @extend %lined-heading; |
| 5 | } | 5 | } |
| 6 | 6 | ||
| 7 | h2 { @extend %block-heading; } | ||
| 7 | h3.title { @extend %block-heading; } | 8 | h3.title { @extend %block-heading; } |
| 8 | 9 | ||
| 9 | .verinfo { | 10 | .verinfo { |
| @@ -186,5 +186,66 @@ module Docs · 185 unmodified lines | |||
| 186 | Typhoeus.stub(root_url.to_s).and_return(response) | 186 | Typhoeus.stub(root_url.to_s).and_return(response) |
| 187 | end | 187 | end |
| 188 | end | 188 | end |
| 189 | |||
| 190 | module FixInternalUrlsBehavior | ||
| 191 | def self.included(base) | ||
| 192 | base.extend ClassMethods | ||
| 193 | end | ||
| 194 | |||
| 195 | module ClassMethods | ||
| 196 | attr_reader :internal_urls | ||
| 197 | |||
| 198 | def store_pages(store) | ||
| 199 | instrument 'info.doc', msg: 'Building internal urls...' | ||
| 200 | with_internal_urls do | ||
| 201 | instrument 'info.doc', msg: 'Building pages...' | ||
| 202 | super | ||
| 203 | end | ||
| 204 | end | ||
| 205 | |||
| 206 | private | ||
| 207 | |||
| 208 | def with_internal_urls | ||
| 209 | @internal_urls = new.fetch_internal_urls | ||
| 210 | yield | ||
| 211 | ensure | ||
| 212 | @internal_urls = nil | ||
| 213 | end | ||
| 214 | end | ||
| 215 | |||
| 216 | def fetch_internal_urls | ||
| 217 | result = [] | ||
| 218 | build_pages do |page| | ||
| 219 | result << base_url.subpath_to(page[:response_url]) if page[:entries].present? | ||
| 220 | end | ||
| 221 | result | ||
| 222 | end | ||
| 223 | |||
| 224 | def initial_urls | ||
| 225 | return super unless self.class.internal_urls | ||
| 226 | @initial_urls ||= self.class.internal_urls.map(&method(:url_for)).freeze | ||
| 227 | end | ||
| 228 | |||
| 229 | private | ||
| 230 | |||
| 231 | def additional_options | ||
| 232 | if self.class.internal_urls | ||
| 233 | { | ||
| 234 | only: self.class.internal_urls.to_set, | ||
| 235 | only_patterns: nil, | ||
| 236 | skip: nil, | ||
| 237 | skip_patterns: nil, | ||
| 238 | skip_links: nil, | ||
| 239 | fixed_internal_urls: true | ||
| 240 | } | ||
| 241 | else | ||
| 242 | {} | ||
| 243 | end | ||
| 244 | end | ||
| 245 | |||
| 246 | def process_response(response) | ||
| 247 | super.merge! response_url: response.url | ||
| 248 | end | ||
| 249 | end | ||
| 189 | end | 250 | end |
| 190 | end | 251 | end |
| @@ -25,6 +25,18 @@ module Docs · 24 unmodified lines | |||
| 25 | node.inner_html = node.inner_html.gsub(br, "\n") | 25 | node.inner_html = node.inner_html.gsub(br, "\n") |
| 26 | node.content = node.content | 26 | node.content = node.content |
| 27 | end | 27 | end |
| 28 | |||
| 29 | css('> h2:first-child.title').each do |node| | ||
| 30 | node.name = 'h1' | ||
| 31 | end | ||
| 32 | |||
| 33 | css('div.partintro', 'div.section').each do |node| | ||
| 34 | node.before(node.children).remove | ||
| 35 | end | ||
| 36 | |||
| 37 | css('.title + .verinfo + .title').each do |node| | ||
| 38 | node.after(node.previous_element) | ||
| 39 | end | ||
| 28 | end | 40 | end |
| 29 | end | 41 | end |
| 30 | end | 42 | end |
| @@ -25,6 +25,7 @@ module Docs · 24 unmodified lines | |||
| 25 | 'tidy' => 'Tidy', | 25 | 'tidy' => 'Tidy', |
| 26 | 'Worker' => 'pthreads', | 26 | 'Worker' => 'pthreads', |
| 27 | 'XsltProcessor' => 'XSLT', | 27 | 'XsltProcessor' => 'XSLT', |
| 28 | 'Yar' => 'Yar', | ||
| 28 | 'ZipArchive' => 'Zip' } | 29 | 'ZipArchive' => 'Zip' } |
| 29 | 30 | ||
| 30 | %w(APC Directory DOM Event Gearman Gmagick Imagick mysqli OAuth PDO Reflection | 31 | %w(APC Directory DOM Event Gearman Gmagick Imagick mysqli OAuth PDO Reflection |
| @@ -46,13 +47,16 @@ module Docs · 15 unmodified lines | |||
| 46 | end | 47 | end |
| 47 | 48 | ||
| 48 | REPLACE_TYPES = { | 49 | REPLACE_TYPES = { |
| 50 | 'Error' => 'Errors', | ||
| 49 | 'Exceptions' => 'SPL/Exceptions', | 51 | 'Exceptions' => 'SPL/Exceptions', |
| 52 | 'finfo' => 'File System', | ||
| 50 | 'GD and Image' => 'Image', | 53 | 'GD and Image' => 'Image', |
| 51 | 'Gmagick' => 'Image/GraphicsMagick', | 54 | 'Gmagick' => 'Image/GraphicsMagick', |
| 52 | 'Imagick' => 'Image/ImageMagick', | 55 | 'Imagick' => 'Image/ImageMagick', |
| 53 | 'Interfaces' => 'SPL/Interfaces', | 56 | 'Interfaces' => 'SPL/Interfaces', |
| 54 | 'Iterators' => 'SPL/Iterators', | 57 | 'Iterators' => 'SPL/Iterators', |
| 55 | 'mysqli' => 'Database/MySQL', | 58 | 'mysqli' => 'Database/MySQL', |
| 59 | 'PCRE Patterns' => 'PCRE Reference', | ||
| 56 | 'PostgreSQL' => 'Database/PostgreSQL', | 60 | 'PostgreSQL' => 'Database/PostgreSQL', |
| 57 | 'Session' => 'Sessions', | 61 | 'Session' => 'Sessions', |
| 58 | 'Session PgSQL' => 'Database/PostgreSQL', | 62 | 'Session PgSQL' => 'Database/PostgreSQL', |
| @@ -62,7 +66,7 @@ module Docs · 3 unmodified lines | |||
| 62 | 'Yaml' => 'YAML' } | 66 | 'Yaml' => 'YAML' } |
| 63 | 67 | ||
| 64 | TYPE_GROUPS = { | 68 | TYPE_GROUPS = { |
| 65 | 'Classes and Functions' => ['Classes/Object', 'Function handling', 'Predefined Interfaces and Classes', 'runkit'], | 69 | 'Classes and Functions' => ['Classes/Object', 'Function handling', 'Predefined Interfaces and Classes', 'runkit', 'Throwable'], |
| 66 | 'Encoding' => ['Gettext', 'iconv', 'Multibyte String'], | 70 | 'Encoding' => ['Gettext', 'iconv', 'Multibyte String'], |
| 67 | 'Compression' => ['Bzip2', 'Zip', 'Zlib'], | 71 | 'Compression' => ['Bzip2', 'Zip', 'Zlib'], |
| 68 | 'Cryptography' => ['Hash', 'Mcrypt', 'OpenSSL', 'Password Hashing'], | 72 | 'Cryptography' => ['Hash', 'Mcrypt', 'OpenSSL', 'Password Hashing'], |
| @@ -90,6 +94,9 @@ module Docs · 21 unmodified lines | |||
| 90 | end | 94 | end |
| 91 | 95 | ||
| 92 | def get_type | 96 | def get_type |
| 97 | return 'Language Reference' if subpath.start_with?('language.') | ||
| 98 | return 'PCRE Reference' if subpath.start_with?('regexp.') | ||
| 99 | |||
| 93 | type = at_css('.up').content.strip | 100 | type = at_css('.up').content.strip |
| 94 | type = 'SPL/Iterators' if type.end_with? 'Iterator' | 101 | type = 'SPL/Iterators' if type.end_with? 'Iterator' |
| 95 | type.remove! ' Functions' | 102 | type.remove! ' Functions' |
| @@ -108,7 +115,7 @@ module Docs · 12 unmodified lines | |||
| 108 | end | 115 | end |
| 109 | 116 | ||
| 110 | def include_default_entry? | 117 | def include_default_entry? |
| 111 | !initial_page? && doc.at_css('.reference', '.refentry', '.sect1') | 118 | !initial_page? && doc.at_css('.reference', '.refentry', '.sect1', '.simpara', '.para') |
| 112 | end | 119 | end |
| 113 | end | 120 | end |
| 114 | end | 121 | end |
| @@ -3,7 +3,7 @@ module Docs · 2 unmodified lines | |||
| 3 | class FixUrlsFilter < Filter | 3 | class FixUrlsFilter < Filter |
| 4 | def call | 4 | def call |
| 5 | html.gsub! File.join(Php.base_url, Php.root_path), Php.base_url | 5 | html.gsub! File.join(Php.base_url, Php.root_path), Php.base_url |
| 6 | html.gsub! %r{http://www\.php\.net/manual/en/([^"']+?)\.html}, 'http://www.php.net/manual/en/\1.php' | 6 | html.gsub! %r{https://secure\.php\.net/manual/en/([^"']+?)\.html}, 'https://secure.php.net/manual/en/\1.php' |
| 7 | html | 7 | html |
| 8 | end | 8 | end |
| 9 | end | 9 | end |
| @@ -2,9 +2,12 @@ module Docs · 1 unmodified line | |||
| 2 | class Php | 2 | class Php |
| 3 | class InternalUrlsFilter < Filter | 3 | class InternalUrlsFilter < Filter |
| 4 | def call | 4 | def call |
| 5 | return doc if context[:fixed_internal_urls] | ||
| 6 | |||
| 5 | if subpath.start_with?('book.') || subpath.start_with?('class.') | 7 | if subpath.start_with?('book.') || subpath.start_with?('class.') |
| 6 | result[:internal_urls] = internal_urls | 8 | result[:internal_urls] = internal_urls |
| 7 | end | 9 | end |
| 10 | |||
| 8 | doc | 11 | doc |
| 9 | end | 12 | end |
| 10 | 13 | ||
| @@ -1,19 +1,28 @@ | |||
| 1 | module Docs | 1 | module Docs |
| 2 | class Php < FileScraper | 2 | class Php < FileScraper |
| 3 | include FixInternalUrlsBehavior | ||
| 4 | |||
| 3 | self.name = 'PHP' | 5 | self.name = 'PHP' |
| 4 | self.type = 'php' | 6 | self.type = 'php' |
| 5 | self.release = 'up to 5.6.13' | 7 | self.release = 'up to 7.0.3' |
| 6 | self.base_url = 'http://www.php.net/manual/en/' | 8 | self.base_url = 'https://secure.php.net/manual/en/' |
| 7 | self.root_path = 'index.html' | 9 | self.root_path = 'index.html' |
| 8 | self.initial_paths = %w( | 10 | self.initial_paths = %w( |
| 9 | funcref.html | 11 | funcref.html |
| 12 | langref.html | ||
| 10 | refs.database.html | 13 | refs.database.html |
| 11 | set.mysqlinfo.html | 14 | set.mysqlinfo.html |
| 12 | language.control-structures.html | 15 | language.control-structures.html |
| 16 | reference.pcre.pattern.syntax.html | ||
| 13 | reserved.exceptions.html | 17 | reserved.exceptions.html |
| 14 | reserved.interfaces.html | 18 | reserved.interfaces.html |
| 15 | reserved.variables.html) | 19 | reserved.variables.html) |
| 16 | 20 | ||
| 21 | self.links = { | ||
| 22 | home: 'https://secure.php.net/', | ||
| 23 | code: 'https://github.com/php/php-src' | ||
| 24 | } | ||
| 25 | |||
| 17 | # Downloaded from php.net/download-docs.php | 26 | # Downloaded from php.net/download-docs.php |
| 18 | self.dir = '/Users/Thibaut/DevDocs/Docs/PHP' | 27 | self.dir = '/Users/Thibaut/DevDocs/Docs/PHP' |
| 19 | 28 | ||
| @@ -25,34 +34,37 @@ module Docs · 5 unmodified lines | |||
| 25 | options[:skip_links] = ->(filter) { !filter.initial_page? } | 34 | options[:skip_links] = ->(filter) { !filter.initial_page? } |
| 26 | 35 | ||
| 27 | options[:only_patterns] = [ | 36 | options[:only_patterns] = [ |
| 37 | /\Alanguage\./, | ||
| 28 | /\Aclass\./, | 38 | /\Aclass\./, |
| 29 | /\Afunction\./, | 39 | /\Afunction\./, |
| 30 | /\Acontrol-structures/, | 40 | /\Acontrol-structures/, |
| 41 | /\Aregexp\./, | ||
| 31 | /\Areserved\.exceptions/, | 42 | /\Areserved\.exceptions/, |
| 32 | /\Areserved\.interfaces/, | 43 | /\Areserved\.interfaces/, |
| 33 | /\Areserved\.variables/] | 44 | /\Areserved\.variables/] |
| 34 | 45 | ||
| 35 | BOOKS = %w(apache apc array bc bzip2 calendar classobj ctype curl datetime | 46 | BOOKS = %w(apache apc array bc bzip2 calendar csprng classobj ctype curl |
| 36 | dba dir dom eio errorfunc event exec fileinfo filesystem filter ftp funchand | 47 | datetime dba dir dom eio errorfunc event exec fileinfo filesystem filter |
| 37 | gearman geoip gettext gmagick hash http iconv iisfunc image imagick imap | 48 | ftp funchand gearman geoip gettext gmagick gmp hash iconv iisfunc image |
| 38 | info inotify intl json ldap libevent libxml mail mailparse math mbstring | 49 | imagick imap info inotify intl json ldap libevent libxml mail mailparse |
| 39 | mcrypt memcached misc mysqli network oauth openssl outcontrol password | 50 | math mbstring mcrypt memcached misc mysqli network oauth openssl |
| 40 | pcre pdo pgsql posix pthreads regex runkit reflection session | 51 | outcontrol password pcre pdo pgsql posix pthreads regex runkit reflection |
| 41 | session-pgsql simplexml soap sockets solr sphinx spl spl-types sqlite3 | 52 | sca session session-pgsql simplexml soap sockets solr sphinx spl |
| 42 | sqlsrv ssh2 stats stream strings taint tidy uodbc url var varnish xml | 53 | spl-types sqlite3 sqlsrv ssh2 stats stream strings taint tidy uodbc url |
| 43 | xmlreader xmlrpc xmlwriter xsl yaf yaml zip zlib) | 54 | var varnish xml xmlreader xmlrpc xmlwriter xsl yaf yar yaml zip zlib) |
| 44 | 55 | ||
| 45 | options[:only] = BOOKS.map { |s| "book.#{s}.html" } | 56 | options[:only] = BOOKS.map { |s| "book.#{s}.html" } |
| 46 | 57 | ||
| 47 | options[:skip] = %w( | 58 | options[:skip] = %w( |
| 48 | control-structures.intro.html | 59 | control-structures.intro.html |
| 49 | control-structures.alternative-syntax.html | 60 | control-structures.alternative-syntax.html |
| 50 | function.mssql-select-db.html) | 61 | function.mssql-select-db.html |
| 62 | pthreads.modifiers.html) | ||
| 51 | 63 | ||
| 52 | options[:skip_patterns] = [/mysqlnd/] | 64 | options[:skip_patterns] = [/mysqlnd/] |
| 53 | 65 | ||
| 54 | options[:attribution] = <<-HTML | 66 | options[:attribution] = <<-HTML |
| 55 | © 1997–2015 The PHP Documentation Group<br> | 67 | © 1997–2016 The PHP Documentation Group<br> |
| 56 | Licensed under the Creative Commons Attribution License v3.0 or later. | 68 | Licensed under the Creative Commons Attribution License v3.0 or later. |
| 57 | HTML | 69 | HTML |
| 58 | end | 70 | end |