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
106106 end
107107
108108 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')
110110 end
111111 end
112112 end
lib/docs/scrapers/php.rb+10−17
@@ -5,18 +5,7 @@ module Docs · 4 unmodified lines
55 self.version = 'up to 5.5.6'
66 self.base_url = 'http://www.php.net/manual/en/'
77 self.root_path = 'index.html'
8−
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
8+ self.initial_paths = %w(
209 funcref.html
2110 refs.database.html
2211 set.mysqlinfo.html
@@ -25,11 +14,15 @@ module Docs · 2 unmodified lines
2514 reserved.interfaces.html
2615 reserved.variables.html)
2716
28− options[:skip_links] = ->(filter) do
29− INDEX_PATHS.exclude?(filter.subpath)
30− end
17+ # Downloaded from php.net/download-docs.php
18+ self.dir = '/Users/Thibaut/DevDocs/Docs/PHP'
19+
20+ html_filters.push 'php/internal_urls', 'php/entries', 'php/clean_html', 'title'
21+ text_filters.push 'php/fix_urls'
3122
32− options[:only] = INDEX_PATHS.dup
23+ options[:title] = false
24+ options[:root_title] = 'PHP: Hypertext Preprocessor'
25+ options[:skip_links] = ->(filter) { !filter.initial_page? }
3326
3427 options[:only_patterns] = [
3528 /\Aclass\./,
@@ -49,7 +42,7 @@ module Docs · 13 unmodified lines
4942 sqlite3 sqlsrv ssh2 stats stream strings taint tidy uodbc url var varnish
5043 xml xmlreader xmlrpc xmlwriter xsl yaf yaml zip zlib)
5144
52− options[:only].concat BOOKS.map { |s| "book.#{s}.html" }
45+ options[:only] = BOOKS.map { |s| "book.#{s}.html" }
5346
5447 options[:skip] = %w(
5548 control-structures.intro.html