From b6c72c85e95b1716be9ead834cf4c6a16dfaa16e Mon Sep 17 00:00:00 2001 From: Thibaut Date: Sat, 14 Feb 2015 11:47:27 -0500 Subject: [PATCH] Update and improve lodash documentation (3.2.0) --- lib/docs/filters/lodash/clean_html.rb | 2 ++ lib/docs/filters/lodash/entries.rb | 19 ++++++------------- lib/docs/scrapers/lodash.rb | 9 ++++----- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/docs/filters/lodash/clean_html.rb b/lib/docs/filters/lodash/clean_html.rb index 2d4286e6..1b64069a 100644 --- a/lib/docs/filters/lodash/clean_html.rb +++ b/lib/docs/filters/lodash/clean_html.rb @@ -2,6 +2,8 @@ module Docs class Lodash class CleanHtmlFilter < Filter def call + @doc = at_css('h1+div+div') + css('h3 + p', 'hr').remove # Set id attributes on

instead of an empty diff --git a/lib/docs/filters/lodash/entries.rb b/lib/docs/filters/lodash/entries.rb index fb93b925..c340358e 100644 --- a/lib/docs/filters/lodash/entries.rb +++ b/lib/docs/filters/lodash/entries.rb @@ -4,20 +4,13 @@ module Docs def additional_entries entries = [] - css('h2').each do |node| - type = node.content.split.first - type.remove! %r{\W} # remove quotation marks + css('.toc-container h2').each do |heading| + type = heading.content.split.first - node.parent.css('h3').each do |heading| - name = heading.content - name.sub! %r{\(.+?\)}, '()' - entries << [name, heading['id'], type] - - if h4 = heading.parent.at_css('h4') and h4.content.strip == 'Aliases' - h4.next_element.content.split(',').each do |n| - entries << ["#{n.strip}()", heading['id'], type] - end - end + heading.parent.css('a').each do |link| + name = link.content + name = name.remove(/\u{2192}.*/) + entries << [name, link['href'].remove('#'), type] end end diff --git a/lib/docs/scrapers/lodash.rb b/lib/docs/scrapers/lodash.rb index ff6ebae6..646656e1 100644 --- a/lib/docs/scrapers/lodash.rb +++ b/lib/docs/scrapers/lodash.rb @@ -1,15 +1,14 @@ module Docs class Lodash < UrlScraper - self.name = 'Lo-Dash' + self.name = 'lodash' self.slug = 'lodash' self.type = 'lodash' - self.version = '3.1.0' + self.version = '3.2.0' self.base_url = 'https://lodash.com/docs' - html_filters.push 'lodash/clean_html', 'lodash/entries', 'title' + html_filters.push 'lodash/entries', 'lodash/clean_html', 'title' - options[:title] = 'Lo-Dash' - options[:container] = 'h1+div+div' + options[:title] = 'lodash' options[:skip_links] = true options[:attribution] = <<-HTML