php.rb 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 = '8.2'
  8. self.base_url = 'https://www.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://www.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 blenc bzip2 calendar csprng componere classobj ctype curl
  39. datetime dba dbx dir dio dom ds eio errorfunc enchant ev event exec exif fileinfo filesystem filter
  40. fdf ftp funchand fpm gearman geoip gettext gmagick gmp gnupg hash ibase iconv iisfunc image
  41. imagick imap info inotify intl iisfunc json judy ldap libevent libxml lua lzf mail mailparse
  42. math mhash mbstring mcrypt memcached misc mysqli ncurses network nsapi oauth openssl openal opcache
  43. outcontrol password parle pcntl phpdbg pcre pdo pgsql phar posix proctitle pspell pthreads quickhash recode regex runkit runkit7 radius rar
  44. reflection readline sca session sem session-pgsql shmop simplexml ssdeep sdo sdodasrel sdo-das-xml sodium soap sockets solr snmp sphinx spl stomp
  45. spl-types sqlite3 sqlsrv ssh2 stats stream strings sync svm svn taint tidy tokenizer uodbc url uopz
  46. v8js var varnish wddx weakref wincache xattr xdiff xhprof xml xmlreader xmlrpc xmlwriter xsl yaf yar yaml yac zip zookeeper 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;2022 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://www.php.net/supported-versions.php', opts)
  60. doc.at_css('table > tbody > .stable:last-of-type > td > a').content.strip
  61. end
  62. end
  63. end