Prechádzať zdrojové kódy

Improve Dojo scraper

Thibaut Courouble 8 rokov pred
rodič
commit
384ee20b28

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

@@ -210,7 +210,7 @@ credits = [
     'https://raw.githubusercontent.com/docker/docker/master/LICENSE'
   ], [
     'Dojo',
-    '2005-2015 The Dojo Foundation',
+    '2005-2017 JS Foundation',
     'BSD + AFL',
     'http://dojotoolkit.org/license.html'
   ], [

+ 0 - 14
assets/javascripts/views/pages/javascript.coffee

@@ -1,14 +0,0 @@
-#= require views/pages/base
-
-class app.views.JavascriptWithMarkupCheckPage extends app.views.BasePage
-  prepare: ->
-    for el in @findAllByTag('pre')
-      language = if el.textContent.match(/^\s*</)
-        'markup'
-      else
-        'javascript'
-      @highlightCode el, language
-    return
-
-app.views.DojoPage =
-app.views.JavascriptWithMarkupCheckPage

+ 1 - 0
assets/javascripts/views/pages/simple.coffee

@@ -21,6 +21,7 @@ app.views.CordovaPage =
 app.views.CrystalPage =
 app.views.D3Page =
 app.views.DockerPage =
+app.views.DojoPage =
 app.views.DrupalPage =
 app.views.ElectronPage =
 app.views.ElixirPage =

+ 0 - 1
assets/stylesheets/pages/_dojo.scss

@@ -1,6 +1,5 @@
 ._dojo {
   @extend %simple;
 
-  .functionIcon, .parameters { @extend %code; }
   .jsdoc-inheritance { color: $textColorLight; }
 }

+ 15 - 0
lib/docs/filters/dojo/clean_html.rb

@@ -39,6 +39,21 @@ module Docs
           node.replace(node.content)
         end
 
+        css('.functionIcon', '.parameters').each do |node|
+          node.name = 'code'
+          node.content = node.content.strip
+        end
+
+        css('pre').each do |node|
+          node['data-language'] = node.content =~ /\A\s*</ ? 'markup' : 'javascript'
+        end
+
+        css('.jsdoc-function-information', '.jsdoc-examples', '.jsdoc-example', 'span').each do |node|
+          node.before(node.children).remove
+        end
+
+        css('table', 'a', 'h2', 'h3', 'td', 'strong').remove_attr('class')
+
         doc
       end
     end

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

@@ -25,7 +25,7 @@ module Docs
     options[:skip_patterns] = [/dijit/, /dojox/]
 
     options[:attribution] = <<-HTML
-      &copy; 2005&ndash;2015 The Dojo Foundation<br>
+      &copy; 2005&ndash;2017 JS Foundation<br>
       Licensed under the AFL 2.1 and BSD 3-Clause licenses.
     HTML