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
2 class Lodash2 class Lodash
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 @doc = at_css('h1+div+div')
6
5 css('h3 + p', 'hr').remove7 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>
lib/docs/filters/lodash/entries.rb+6−13
@@ -4,20 +4,13 @@ module Docs · 3 unmodified lines
4 def additional_entries4 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.first8 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.content11 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 end14 end
22 end15 end
23 16
lib/docs/scrapers/lodash.rb+4−5
@@ -1,15 +1,14 @@
1module Docs1module Docs
2 class Lodash < UrlScraper2 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] = true12 options[:skip_links] = true
14 13
15 options[:attribution] = <<-HTML14 options[:attribution] = <<-HTML