Parcourir la source

Update D3.js documentation (6.5.0)

Simon Legner il y a 4 ans
Parent
commit
86d23b7127

+ 1 - 1
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -223,7 +223,7 @@ credits = [
     'https://raw.githubusercontent.com/dlang/phobos/master/LICENSE_1_0.txt'
   ], [
     'D3.js',
-    '2010-2018 Michael Bostock',
+    '2010-2020 Michael Bostock',
     'BSD',
     'https://raw.githubusercontent.com/d3/d3/master/LICENSE'
   ], [

+ 3 - 0
lib/docs/filters/d3/clean_html.rb

@@ -31,6 +31,9 @@ module Docs
           node.content = 'Source'
           node['class'] = 'source'
         end
+        css('h6 a:contains("Source"), h6 a:contains("Examples")').each do |node|
+          node['class'] = 'source'
+        end
 
         # Fix internal links
         css('a[href]').each do |node|

+ 5 - 0
lib/docs/filters/d3/entries_v4.rb

@@ -18,8 +18,13 @@ module Docs
       def additional_entries
         css('h6[id]').each_with_object [] do |node, entries|
           name = node.content.strip
+          name.remove! 'Source, Examples'
           name.remove! 'Source'
+          name.remove! 'Examples'
           name.remove! '<>'
+          name.remove! ' · '
+          name.remove! '0,' # from d3.quickselect
+          name.remove! '=' # from d3.quickselect
           name.remove! %r{\s\-.*}
           name.remove! %r{\s*\[.*\]}
           name.gsub! %r{\(.+?\)\)?}, '()'

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

@@ -12,10 +12,26 @@ module Docs
     options[:container] = '.markdown-body'
 
     options[:attribution] = <<-HTML
-      &copy; 2010&ndash;2018 Michael Bostock<br>
+      &copy; 2010&ndash;2020 Michael Bostock<br>
       Licensed under the BSD License.
     HTML
 
+    version '6' do
+      self.release = '6.5.0'
+      self.base_url = 'https://github.com/d3/'
+      self.root_path = 'd3/blob/master/API.md'
+
+      html_filters.push 'd3/clean_html', 'd3/entries_v4'
+
+      options[:only_patterns] = [/\Ad3[\-\w]+\z/, /\Ad3\/blob\/master\/changes\.md\z/i]
+      options[:skip_patterns] = [/3\.x-api-reference/]
+
+      options[:fix_urls] = ->(url) do
+        url.sub! %r{/blob/master/readme.md}i, ''
+        url
+      end
+    end
+
     version '5' do
       self.release = '5.7.0'
       self.base_url = 'https://github.com/d3/'