History

Refactor PHP scraper with new initial_paths option

Thibaut committed 12 years ago

Commit b66d6d91 parent ca06cc72 files · +11 −18Browse files

Unified · Split

2 files
  1. lib/docs/filters/php/entries.rb +1 −1
  2. lib/docs/scrapers/php.rb +10 −17
lib/docs/filters/php/entries.rb+1−1
@@ -106,7 +106,7 @@ module Docs · 105 unmodified lines
106 end106 end
107 107
108 def include_default_entry?108 def include_default_entry?
109 Php::INDEX_PATHS.exclude?(subpath) && doc.at_css('.reference', '.refentry', '.sect1')109 !initial_page? && doc.at_css('.reference', '.refentry', '.sect1')
110 end110 end
111 end111 end
112 end112 end
lib/docs/scrapers/php.rb+10−17
@@ -5,18 +5,7 @@ module Docs · 4 unmodified lines
5 self.version = 'up to 5.5.6'5 self.version = 'up to 5.5.6'
6 self.base_url = 'http://www.php.net/manual/en/'6 self.base_url = 'http://www.php.net/manual/en/'
7 self.root_path = 'index.html'7 self.root_path = 'index.html'
8 8 self.initial_paths = %w(
9 # Downloaded from php.net/download-docs.php
10 self.dir = '/Users/Thibaut/DevDocs/Docs/PHP'
11
12 html_filters.push 'php/internal_urls', 'php/entries', 'php/clean_html', 'title'
13 text_filters.push 'php/fix_urls'
14
15 options[:title] = false
16 options[:root_title] = 'PHP: Hypertext Preprocessor'
17
18 INDEX_PATHS = %w(
19 index.html
20 funcref.html9 funcref.html
21 refs.database.html10 refs.database.html
22 set.mysqlinfo.html11 set.mysqlinfo.html
@@ -25,11 +14,15 @@ module Docs · 2 unmodified lines
25 reserved.interfaces.html14 reserved.interfaces.html
26 reserved.variables.html)15 reserved.variables.html)
27 16
28 options[:skip_links] = ->(filter) do17 # Downloaded from php.net/download-docs.php
29 INDEX_PATHS.exclude?(filter.subpath)18 self.dir = '/Users/Thibaut/DevDocs/Docs/PHP'
30 end19
20 html_filters.push 'php/internal_urls', 'php/entries', 'php/clean_html', 'title'
21 text_filters.push 'php/fix_urls'
31 22
32 options[:only] = INDEX_PATHS.dup23 options[:title] = false
24 options[:root_title] = 'PHP: Hypertext Preprocessor'
25 options[:skip_links] = ->(filter) { !filter.initial_page? }
33 26
34 options[:only_patterns] = [27 options[:only_patterns] = [
35 /\Aclass\./,28 /\Aclass\./,
@@ -49,7 +42,7 @@ module Docs · 13 unmodified lines
49 sqlite3 sqlsrv ssh2 stats stream strings taint tidy uodbc url var varnish42 sqlite3 sqlsrv ssh2 stats stream strings taint tidy uodbc url var varnish
50 xml xmlreader xmlrpc xmlwriter xsl yaf yaml zip zlib)43 xml xmlreader xmlrpc xmlwriter xsl yaf yaml zip zlib)
51 44
52 options[:only].concat BOOKS.map { |s| "book.#{s}.html" }45 options[:only] = BOOKS.map { |s| "book.#{s}.html" }
53 46
54 options[:skip] = %w(47 options[:skip] = %w(
55 control-structures.intro.html48 control-structures.intro.html