Unified · Split
| @@ -2,6 +2,8 @@ module Docs · 1 unmodified line | |||
| 2 | class Lodash | 2 | class Lodash |
| 3 | class CleanHtmlFilter < Filter | 3 | class CleanHtmlFilter < Filter |
| 4 | def call | 4 | def call |
| 5 | @doc = at_css('h1+div+div') | ||
| 6 | |||
| 5 | css('h3 + p', 'hr').remove | 7 | css('h3 + p', 'hr').remove |
| 6 | 8 | ||
| 7 | # Set id attributes on <h3> instead of an empty <a> | 9 | # Set id attributes on <h3> instead of an empty <a> |
| @@ -4,20 +4,13 @@ module Docs · 3 unmodified lines | |||
| 4 | def additional_entries | 4 | def additional_entries |
| 5 | entries = [] | 5 | entries = [] |
| 6 | 6 | ||
| 7 | css('h2').each do |node| | 7 | css('.toc-container h2').each do |heading| |
| 8 | type = node.content.split.first | 8 | type = heading.content.split.first |
| 9 | type.remove! %r{\W} # remove quotation marks | ||
| 10 | 9 | ||
| 11 | node.parent.css('h3').each do |heading| | 10 | heading.parent.css('a').each do |link| |
| 12 | name = heading.content | 11 | name = link.content |
| 13 | name.sub! %r{\(.+?\)}, '()' | 12 | name = name.remove(/\u{2192}.*/) |
| 14 | entries << [name, heading['id'], type] | 13 | entries << [name, link['href'].remove('#'), type] |
| 15 | |||
| 16 | if h4 = heading.parent.at_css('h4') and h4.content.strip == 'Aliases' | ||
| 17 | h4.next_element.content.split(',').each do |n| | ||
| 18 | entries << ["#{n.strip}()", heading['id'], type] | ||
| 19 | end | ||
| 20 | end | ||
| 21 | end | 14 | end |
| 22 | end | 15 | end |
| 23 | 16 | ||
| @@ -1,15 +1,14 @@ | |||
| 1 | module Docs | 1 | module Docs |
| 2 | class Lodash < UrlScraper | 2 | class Lodash < UrlScraper |
| 3 | self.name = 'Lo-Dash' | 3 | self.name = 'lodash' |
| 4 | self.slug = 'lodash' | 4 | self.slug = 'lodash' |
| 5 | self.type = 'lodash' | 5 | self.type = 'lodash' |
| 6 | self.version = '3.1.0' | 6 | self.version = '3.2.0' |
| 7 | self.base_url = 'https://lodash.com/docs' | 7 | self.base_url = 'https://lodash.com/docs' |
| 8 | 8 | ||
| 9 | html_filters.push 'lodash/clean_html', 'lodash/entries', 'title' | 9 | html_filters.push 'lodash/entries', 'lodash/clean_html', 'title' |
| 10 | 10 | ||
| 11 | options[:title] = 'Lo-Dash' | 11 | options[:title] = 'lodash' |
| 12 | options[:container] = 'h1+div+div' | ||
| 13 | options[:skip_links] = true | 12 | options[:skip_links] = true |
| 14 | 13 | ||
| 15 | options[:attribution] = <<-HTML | 14 | options[:attribution] = <<-HTML |