History

Update and improve lodash documentation (3.2.0)

Thibaut committed 11 years ago

Commit b6c72c81 parent e34e3833 files · +12 −18Browse files

Unified · Split

3 files
  1. lib/docs/filters/lodash/clean_html.rb +2 −0
  2. lib/docs/filters/lodash/entries.rb +6 −13
  3. lib/docs/scrapers/lodash.rb +4 −5
lib/docs/filters/lodash/clean_html.rb+2−0
@@ -2,6 +2,8 @@ module Docs · 1 unmodified line
22 class Lodash
33 class CleanHtmlFilter < Filter
44 def call
5+ @doc = at_css('h1+div+div')
6+
57 css('h3 + p', 'hr').remove
68
79 # Set id attributes on <h3> instead of an empty <a>
lib/docs/filters/lodash/entries.rb+6−13
@@ -4,20 +4,13 @@ module Docs · 3 unmodified lines
44 def additional_entries
55 entries = []
66
7− css('h2').each do |node|
8− type = node.content.split.first
9− type.remove! %r{\W} # remove quotation marks
7+ css('.toc-container h2').each do |heading|
8+ type = heading.content.split.first
109
11− node.parent.css('h3').each do |heading|
12− name = heading.content
13− name.sub! %r{\(.+?\)}, '()'
14− entries << [name, heading['id'], 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
10+ heading.parent.css('a').each do |link|
11+ name = link.content
12+ name = name.remove(/\u{2192}.*/)
13+ entries << [name, link['href'].remove('#'), type]
2114 end
2215 end
2316
lib/docs/scrapers/lodash.rb+4−5
@@ -1,15 +1,14 @@
11 module Docs
22 class Lodash < UrlScraper
3− self.name = 'Lo-Dash'
3+ self.name = 'lodash'
44 self.slug = 'lodash'
55 self.type = 'lodash'
6− self.version = '3.1.0'
6+ self.version = '3.2.0'
77 self.base_url = 'https://lodash.com/docs'
88
9− html_filters.push 'lodash/clean_html', 'lodash/entries', 'title'
9+ html_filters.push 'lodash/entries', 'lodash/clean_html', 'title'
1010
11− options[:title] = 'Lo-Dash'
12− options[:container] = 'h1+div+div'
11+ options[:title] = 'lodash'
1312 options[:skip_links] = true
1413
1514 options[:attribution] = <<-HTML