浏览代码

Add matplotlib documentation

lonewolf 9 年之前
父节点
当前提交
8f88150d73

+ 12 - 0
lib/docs/filters/matplotlib/clean_html.rb

@@ -0,0 +1,12 @@
+module Docs
+  class Matplotlib
+    class CleanHtmlFilter < Filter
+      def call
+        css('.headerlink').each do |node|
+          node.remove
+        end
+        doc
+      end
+    end
+  end
+end

+ 31 - 0
lib/docs/filters/matplotlib/entries.rb

@@ -0,0 +1,31 @@
+module Docs
+  class Matplotlib
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        name = at_css('h1').content.strip
+        name.remove! "\u{00b6}"
+        name
+      end
+
+      def get_type
+        name = at_css('h1').content.strip
+        name.remove! "\u{00b6}"
+        name
+      end
+
+      def additional_entries
+        entries = []
+        ents = css('dt .descname')
+
+        if ents
+          ents.each do |node|
+            name = node.content.sub(/\(.*\)/, '()')
+            id = node.parent['id']
+            entries << [name, id, get_name]
+          end
+        end
+        entries
+      end
+    end
+  end
+end

+ 24 - 0
lib/docs/scrapers/matplotlib.rb

@@ -0,0 +1,24 @@
+module Docs
+  class Matplotlib < FileScraper
+    self.name = 'Matplotlib'
+    self.type = 'sphinx'
+    self.root_path = 'index.html'
+    self.release = "1.5.1"
+    self.links = {
+      home: 'http://matplotlib.org/',
+      code: 'https://github.com/matplotlib/matplotlib'
+    }
+
+    html_filters.push 'matplotlib/entries', 'matplotlib/clean_html'
+
+    options[:container] = '.body'
+
+    options[:attribution] = <<-HTML
+      &copy; Matplotlib Development Team <br>
+      Licensed under the BSD License.
+    HTML
+
+    self.dir = '~/workspace/tmp/matplotlib/matplotlib.github.com-master/1.5.1/api/'
+    # self.base_url = 'http://matplotlib.org/api/'
+  end
+end

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


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