Răsfoiți Sursa

Update D3.js documentation (3.4.4)

Thibaut 11 ani în urmă
părinte
comite
ccf60ac128
2 a modificat fișierele cu 7 adăugiri și 16 ștergeri
  1. 6 15
      lib/docs/filters/d3/clean_html.rb
  2. 1 1
      lib/docs/scrapers/d3.rb

+ 6 - 15
lib/docs/filters/d3/clean_html.rb

@@ -2,6 +2,12 @@ module Docs
   class D3
     class CleanHtmlFilter < Filter
       def call
+        # Remove links inside <h2> and add "id" attributes
+        css('h2 > a').each do |node|
+          node.parent['id'] = node['name'].sub('wiki-', '') if node['name']
+          node.before(node.children).remove
+        end
+
         css('#gollum-footer', '.markdown-body > blockquote:first-child', '.anchor').remove
 
         # Replace #head with <h1>
@@ -15,21 +21,6 @@ module Docs
           node.before(node.at_css('.markdown-body').children).remove
         end
 
-        # Remove links inside <h2>
-        css('h2 > a').each do |node|
-          node.before(node.children).remove
-        end
-
-        # Make headings for function definitions and add "id" attributes
-        css('p > a:first-child').each do |node|
-          next unless node['name'] || node.content == '#'
-          parent = node.parent
-          parent.name = 'h6'
-          parent['id'] = (node['name'] || node['href'].sub(/\A.+#/, '')).sub('wiki-', '')
-          parent.css('a[name]').remove
-          node.remove
-        end
-
         # Make headings for function definitions and add "id" attributes
         css('p > a:first-child').each do |node|
           next unless node['name'] || node.content == '#'

+ 1 - 1
lib/docs/scrapers/d3.rb

@@ -3,7 +3,7 @@ module Docs
     self.name = 'D3.js'
     self.slug = 'd3'
     self.type = 'd3'
-    self.version = '3.4.3'
+    self.version = '3.4.4'
     self.base_url = 'https://github.com/mbostock/d3/wiki/'
     self.root_path = 'API-Reference'