php.rb 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. module Docs
  2. class Php < FileScraper
  3. # Downloaded from php.net/download-docs.php
  4. include FixInternalUrlsBehavior
  5. self.name = 'PHP'
  6. self.type = 'php'
  7. self.release = '7.2.9'
  8. self.base_url = 'https://secure.php.net/manual/en/'
  9. self.root_path = 'index.html'
  10. self.initial_paths = %w(
  11. funcref.html
  12. langref.html
  13. refs.database.html
  14. set.mysqlinfo.html
  15. language.control-structures.html
  16. reference.pcre.pattern.syntax.html
  17. reserved.exceptions.html
  18. reserved.interfaces.html
  19. reserved.variables.html)
  20. self.links = {
  21. home: 'https://secure.php.net/',
  22. code: 'https://git.php.net/?p=php-src.git;a=summary'
  23. }
  24. html_filters.push 'php/internal_urls', 'php/entries', 'php/clean_html', 'title'
  25. text_filters.push 'php/fix_urls'
  26. options[:title] = false
  27. options[:root_title] = 'PHP: Hypertext Preprocessor'
  28. options[:skip_links] = ->(filter) { !filter.initial_page? }
  29. options[:only_patterns] = [
  30. /\Alanguage\./,
  31. /\Aclass\./,
  32. /\Afunctions?\./,
  33. /\Acontrol-structures/,
  34. /\Aregexp\./,
  35. /\Areserved\.exceptions/,
  36. /\Areserved\.interfaces/,
  37. /\Areserved\.variables/]
  38. BOOKS = %w(apache apc apcu array bc bzip2 calendar csprng classobj ctype curl
  39. datetime dba dir dom ds eio errorfunc ev event exec exif fileinfo filesystem filter
  40. ftp funchand gearman geoip gettext gmagick gmp hash ibase iconv iisfunc image
  41. imagick imap info inotify intl json judy ldap libevent libxml lua mail mailparse
  42. math mbstring mcrypt memcached misc mysqli network oauth openssl
  43. outcontrol password pcntl pcre pdo pgsql phar posix proctitle pthreads quickhash regex runkit
  44. reflection sca session sem session-pgsql shmop simplexml soap sockets solr sphinx spl
  45. spl-types sqlite3 sqlsrv ssh2 stats stream strings sync taint tidy tokenizer uodbc url
  46. v8js var varnish weakref xml xmlreader xmlrpc xmlwriter xsl yaf yar yaml zip zlib)
  47. options[:only] = BOOKS.map { |s| "book.#{s}.html" }
  48. options[:skip] = %w(
  49. control-structures.intro.html
  50. control-structures.alternative-syntax.html
  51. function.mssql-select-db.html
  52. pthreads.modifiers.html)
  53. options[:skip_patterns] = [/mysqlnd/, /xdevapi/i]
  54. options[:attribution] = <<-HTML
  55. &copy; 1997&ndash;2018 The PHP Documentation Group<br>
  56. Licensed under the Creative Commons Attribution License v3.0 or later.
  57. HTML
  58. def get_latest_version(opts)
  59. doc = fetch_doc('https://secure.php.net/manual/en/doc.changelog.php', opts)
  60. label = doc.at_css('tbody.gen-changelog > tr > td').content
  61. label.split(',').last.strip
  62. end
  63. end
  64. end