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
22 class Chai
33 class CleanHtmlFilter < Filter
44 def call
5− @doc = at_css('.documentation .rendered')
5+ @doc = at_css('.documentation .rendered') if at_css('.documentation .rendered')
66
77 if root_page?
88 at_css('h1').content = 'Chai Assertion Library'
@@ -12,9 +12,9 @@ module Docs · 3 unmodified lines
1212 node.before(node.children).remove
1313 end
1414
15− # Remove code highlighting
1615 css('pre').each do |node|
1716 node.content = node.content
17+ node['data-language'] = 'javascript'
1818 end
1919
2020 doc
lib/docs/filters/chai/entries.rb+2−2
@@ -6,12 +6,12 @@ module Docs · 5 unmodified lines
66 end
77
88 def get_type
9− subpath.start_with?('/guide') ? 'Guides' : nil
9+ subpath.start_with?('/guide') ? 'Guides' : name
1010 end
1111
1212 def additional_entries
1313 css('.antiscroll-inner a').each_with_object [] do |node, entries|
14− id = node['href'].remove('#') + '-section'
14+ id = node['href'].remove('#')
1515 node.content.strip.split(' / ').uniq { |name| name.downcase }.each do |name|
1616 entries << [name, id, self.name]
1717 end