History

Improve D3.js scraper (3.4.3)

Thibaut committed 12 years ago

Commit ecdc9c81 parent 6186cb52 files · +16 −1Browse files

Unified · Split

2 files
  1. lib/docs/filters/d3/clean_html.rb +15 −0
  2. lib/docs/scrapers/d3.rb +1 −1
lib/docs/filters/d3/clean_html.rb+15−0
@@ -30,6 +30,21 @@ module Docs · 29 unmodified lines
30 node.remove30 node.remove
31 end31 end
32 32
33 # Make headings for function definitions and add "id" attributes
34 css('p > a:first-child').each do |node|
35 next unless node['name'] || node.content == '#'
36 parent = node.parent
37 parent.name = 'h6'
38 parent['id'] = (node['name'] || node['href'].sub(/\A.+#/, '')).sub('wiki-', '')
39 parent.css('a[name]').remove
40 node.remove
41 end
42
43 # Fix internal links
44 css('a[href]').each do |node|
45 node['href'] = node['href'].sub(/#wiki\-(\w+?)\z/, '#\1')
46 end
47
33 # Remove code highlighting48 # Remove code highlighting
34 css('.highlight > pre').each do |node|49 css('.highlight > pre').each do |node|
35 node.content = node.content50 node.content = node.content
lib/docs/scrapers/d3.rb+1−1
@@ -3,7 +3,7 @@ module Docs · 2 unmodified lines
3 self.name = 'D3.js'3 self.name = 'D3.js'
4 self.slug = 'd3'4 self.slug = 'd3'
5 self.type = 'd3'5 self.type = 'd3'
6 self.version = '3.4.2'6 self.version = '3.4.3'
7 self.base_url = 'https://github.com/mbostock/d3/wiki/'7 self.base_url = 'https://github.com/mbostock/d3/wiki/'
8 self.root_path = 'API-Reference'8 self.root_path = 'API-Reference'
9 9