1
0

php.rb 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. module Docs
  2. class Php < FileScraper
  3. # WARNING: if you are the kind of developer who likes to automate things,
  4. # this scraper will hurt your feelings.
  5. self.name = 'PHP'
  6. self.type = 'php'
  7. self.version = 'up to 5.5.4'
  8. self.base_url = 'http://www.php.net/manual/en/'
  9. self.root_path = 'extensions.alphabetical.html'
  10. # Downloaded from php.net/download-docs.php
  11. self.dir = '/Users/Thibaut/DevDocs/Docs/PHP'
  12. html_filters.push 'php/entries', 'php/clean_html', 'title'
  13. text_filters.push 'php/fix_urls'
  14. options[:title] = false
  15. options[:root_title] = 'PHP: Hypertext Preprocessor'
  16. options[:only] = [] # using a whitelist
  17. options[:only_patterns] = [/\Afunction\.\w+\.html\z/,
  18. /\Areserved\.exceptions/, /\Areserved\.interfaces/,
  19. /\Areserved\.variables/, /\Acontrol\-structures/]
  20. # TODO: MongoDB, Phar
  21. BOOKS = %w(amqp apache apc array bc bzip2 calendar classkit classobj com
  22. ctype curl datetime dba dir dom eio errorfunc exec fileinfo filesystem
  23. filter ftp funchand gearman geoip gettext gmagick hash http iconv iisfunc
  24. image imagick imap info inotify intl json ldap libevent libxml mail
  25. mailparse math mbstring mcrypt memcached misc mysqli network oauth
  26. openssl outcontrol password pcre pdo pgsql posix pthreads quickhash
  27. readline regex runkit reflection session session-pgsql simplexml soap
  28. sockets solr sphinx spl spl-types sqlite3 sqlsrv ssh2 stats stream
  29. strings taint tidy url v8js var varnish weakref xml xmlreader xmlrpc
  30. xmlwriter xsl yaf yaml zip zlib uodbc)
  31. options[:only].concat BOOKS.map { |s| "book.#{s}.html" }
  32. options[:only_patterns].concat BOOKS.map { |s| /\Afunction\.#{s}(?:\.|\-)/ }
  33. CLASSES = %w(apciterator curlfile dateinterval dateperiod collator
  34. numberformatter locale normalizer messageformatter resourcebundle
  35. spoofchecker transliterator uconverter memcached thread worker stackable
  36. mutex cond runkit reflector sessionhandler sessionhandlerinterface
  37. sphinxclient countable arrayobject streamwrapper xmlreader xsltprocessor
  38. ziparchive exception errorexception)
  39. options[:only].concat CLASSES.map { |s| "class.#{s}.html" }
  40. options[:only_patterns].concat CLASSES.map { |s| /\A#{s}\./ }
  41. FUNCTION_PREFIXES = %w(assert base base64 cal call chunk class cli
  42. connection convert count create date debug define disk dns easter ereg
  43. eregi error event file finfo forward func gc gd get grapheme halt header
  44. headers highlight html http idn iis in inet ini is iterator magic mb md5
  45. mdecrypt memory mime move mt nl ob output parse pg php preg print proc
  46. quoted realpath register restore set sha1 shell show stream socket spl
  47. str sys tidy time timezone unregister use utf8 variant xml)
  48. options[:only_patterns].concat FUNCTION_PREFIXES.map { |s| /\Afunction\.#{s}\-/ }
  49. FUNCTIONS = %w(trigger-error user-error require-once include-once)
  50. options[:only].concat FUNCTIONS.map { |s| "function.#{s}.html" }
  51. options[:only_patterns].concat [
  52. /function\.\w+\-exists\.html\z/,
  53. /\A\w+iterator\./,
  54. /\Afunction\.bz\w+\.html\z/,
  55. /\Aclass\.\w+iterator\.html\z/,
  56. /\Aclass\.\w+exception\.html\z/,
  57. /\Aclass\.amqp/, /\Aamqp/,
  58. /\Aclass\.datetime/, /\Adatetime/,
  59. /\Aclass\.dom/, /\Adom/,
  60. /\Aclass\.gearman/, /\Agearman/,
  61. /\Aclass\.gmagick/, /\Agmagick/,
  62. /\Aclass\.http/, /\Ahttp/,
  63. /\Aclass\.imagick/, /\Aimagick/,
  64. /\Aclass\.intl/, /\Aintl/,
  65. /\Aclass\.json/, /\Ajson/,
  66. /\Aclass\.mysqli/, /\Amysqli/,
  67. /\Aclass\.oauth/, /\Aoauth/,
  68. /\Aclass\.pdo/, /\Apdo/,
  69. /\Aclass\.quickhash/, /\Aquickhash/,
  70. /\Aclass\.reflection/, /\Areflection/,
  71. /\Aclass\.simplexml/, /\Asimplexml/,
  72. /\Aclass\.soap/, /\Asoap/,
  73. /\Aclass\.solr/, /\Asolr/,
  74. /\Aclass\.spl/, /\Aspl/,
  75. /\Aclass\.sqlite3/, /\Asqlite3/,
  76. /\Aclass\.tidy/, /\Atidy/,
  77. /\Aclass\.v8js/, /\Av8js/,
  78. /\Aclass\.varnish/, /\Avarnish/,
  79. /\Aclass\.weak/, /\Aweak/,
  80. /\Aclass\.yaf\-/, /\Ayaf\-/]
  81. options[:skip_patterns] = [/example/, /quickstart/, /\.setup\.html\z/,
  82. /\.overview\.html\z/, /\.requirements\.html\z/, /\.installation\.html\z/,
  83. /\.install\.html\z/, /\.configuration\.html\z/, /\.resources\.html\z/,
  84. /\.constants\.html\z/, /\Amysqlinfo/, /\Adatetime\.formats/]
  85. options[:skip] = %w(control-structures.intro.html
  86. control-structures.alternative-syntax.html memcached.expiration.html
  87. memcached.callbacks.html memcached.callbacks.result.html
  88. memcached.callbacks.read-through.html memcached.sessions.html
  89. mysqli.persistconns.html mysqli.notes.html mysqli.summary.html
  90. pdo.connections.html pdo.transactions.html pdo.prepared-statements.html
  91. pdo.error-handling.html pdo.lobs.htm pdo.drivers.html
  92. reflection.extending.html http.request.options.html
  93. class.lapackexception.html class.snmpexception.html function.mhash.html
  94. spl.datastructures.html spl.iterators.html spl.interfaces.html
  95. spl.exceptions.html spl.files.html spl.misc.html)
  96. options[:attribution] = <<-HTML
  97. &copy; 1997&ndash;2013 The PHP Documentation Group<br>
  98. Licensed under the Creative Commons Attribution License v3.0 or later.
  99. HTML
  100. end
  101. end