浏览代码

Add JSDoc

Jed Fox 8 年之前
父节点
当前提交
abbd43b85e

+ 1 - 0
assets/stylesheets/application.css.scss

@@ -56,6 +56,7 @@
         'pages/go',
         'pages/haskell',
         'pages/jquery',
+        'pages/jsdoc',
         'pages/julia',
         'pages/knockout',
         'pages/kotlin',

+ 25 - 0
assets/stylesheets/pages/_jsdoc.scss

@@ -0,0 +1,25 @@
+._jsdoc {
+  > h2 { @extend %block-heading; }
+
+  > h3 {
+    @extend %lined-heading;
+    font-size: 1.1em;
+  }
+
+  figure {
+    margin-left: 0;
+    font-size: inherit;
+
+    pre {
+      margin-bottom: 0.5em;
+    }
+
+    figcaption {
+      font-style: italic;
+    }
+  }
+
+  pre {
+    font-size: inherit;
+  }
+}

+ 43 - 0
lib/docs/filters/jsdoc/clean_html.rb

@@ -0,0 +1,43 @@
+module Docs
+  class Jsdoc
+    class CleanHtmlFilter < Filter
+      def call
+        css('h2').each do |node|
+          next unless node.content.strip == 'Table of Contents'
+          toc_ul = node.next_element
+          toc_block = node.add_next_sibling('<nav class="_toc" role="directory"></nav>').first
+
+          node.name = 'h3'
+          node['class'] = '_toc-title'
+          node.remove
+          toc_block.add_child(node)
+
+          toc_ul.remove
+          toc_ul['class'] = '_toc-list'
+          toc_ul.css('ul').each do |child_list|
+            child_list.remove
+          end
+          toc_block.add_child(toc_ul)
+        end
+
+        css('.prettyprint').each do |node|
+          match = /lang-(\w+)/.match(node['class'])
+          next unless match
+
+          lang = match[1]
+          node.remove_attribute('class')
+          node['data-language'] = lang
+        end
+
+        css('figure').each do |node|
+          caption = node.at_css 'figcaption'
+          next unless caption
+
+          node.children.last.add_next_sibling(caption)
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 25 - 0
lib/docs/filters/jsdoc/entries.rb

@@ -0,0 +1,25 @@
+module Docs
+  class Jsdoc
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        at_css('h1').content
+      end
+      def get_type
+        case slug
+          when /^about-/
+            'Getting Started'
+          when /^plugins-/
+            'Plugins'
+          when /^howto-/
+            'Examples'
+          when /^tags-inline-/
+            'Inline Tags'
+          when /^tags-/
+            'Tags'
+          else
+            'Other' # Only shown if a new category gets added in the upstream docs
+        end
+      end
+    end
+  end
+end

+ 30 - 0
lib/docs/scrapers/jsdoc.rb

@@ -0,0 +1,30 @@
+module Docs
+  class Jsdoc < UrlScraper
+    self.name = 'JSDoc'
+    self.type = 'jsdoc'
+    self.release = '3.5.5'
+    self.base_url = 'http://usejsdoc.org/'
+    self.links = {
+      home: 'http://usejsdoc.org/',
+      code: 'https://github.com/jsdoc3/jsdoc'
+    }
+
+    html_filters.push 'jsdoc/clean_html', 'jsdoc/entries'
+
+    options[:trailing_slash] = false
+    options[:container] = 'article'
+    options[:skip] = [
+      'about-license-jsdoc3.html'
+    ]
+    options[:attribution] = <<-HTML
+      &copy; 2011&ndash;2017
+        <a href="https://github.com/jsdoc3/jsdoc3.github.com/contributors">
+          JSDoc 3 contributors
+        </a><br>
+      Licensed under
+        <a href="http://creativecommons.org/licenses/by-sa/3.0/">
+          CC BY-SA 3.0
+        </a>
+    HTML
+  end
+end

二进制
public/icons/docs/jsdoc/16.png


二进制
public/icons/docs/jsdoc/16@2x.png


+ 1 - 0
public/icons/docs/jsdoc/SOURCE

@@ -0,0 +1 @@
+https://avatars2.githubusercontent.com/u/1530630