History

Fix and improve Chai scraper

Thibaut Courouble committed 10 years ago

Commit fa100bf1 parent 13bd8a08 files · +6 −12Browse files

Showing the changes to lib/docs (2 of 8 files). Show all

Unified · Split

2 files
  1. lib/docs/filters/chai/clean_html.rb +2 −2
  2. lib/docs/filters/chai/entries.rb +2 −2
lib/docs/filters/chai/clean_html.rb+2−2
@@ -2,7 +2,7 @@ module Docs · 1 unmodified line
2 class Chai2 class Chai
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 @doc = at_css('.documentation .rendered')5 @doc = at_css('.documentation .rendered') if at_css('.documentation .rendered')
6 6
7 if root_page?7 if root_page?
8 at_css('h1').content = 'Chai Assertion Library'8 at_css('h1').content = 'Chai Assertion Library'
@@ -12,9 +12,9 @@ module Docs · 3 unmodified lines
12 node.before(node.children).remove12 node.before(node.children).remove
13 end13 end
14 14
15 # Remove code highlighting
16 css('pre').each do |node|15 css('pre').each do |node|
17 node.content = node.content16 node.content = node.content
17 node['data-language'] = 'javascript'
18 end18 end
19 19
20 doc20 doc
lib/docs/filters/chai/entries.rb+2−2
@@ -6,12 +6,12 @@ module Docs · 5 unmodified lines
6 end6 end
7 7
8 def get_type8 def get_type
9 subpath.start_with?('/guide') ? 'Guides' : nil9 subpath.start_with?('/guide') ? 'Guides' : name
10 end10 end
11 11
12 def additional_entries12 def additional_entries
13 css('.antiscroll-inner a').each_with_object [] do |node, entries|13 css('.antiscroll-inner a').each_with_object [] do |node, entries|
14 id = node['href'].remove('#') + '-section'14 id = node['href'].remove('#')
15 node.content.strip.split(' / ').uniq { |name| name.downcase }.each do |name|15 node.content.strip.split(' / ').uniq { |name| name.downcase }.each do |name|
16 entries << [name, id, self.name]16 entries << [name, id, self.name]
17 end17 end