Browse Source

Add pandas documentation

japborst 9 years ago
parent
commit
1941687bf0

+ 1 - 0
assets/javascripts/models/entry.coffee

@@ -67,6 +67,7 @@ class app.models.Entry extends app.Model
     'moment.js': 'mt'
     'nginx': 'ngx'
     'numpy': 'np'
+    'pandas': 'pd'
     'postgresql': 'pg'
     'python': 'py'
     'ruby.on.rails': 'ror'

+ 11 - 0
lib/docs/filters/pandas/clean_html.rb

@@ -0,0 +1,11 @@
+module Docs
+  class Pandas
+    class CleanHtmlFilter < Filter
+      def call
+        @doc = at_css('.body')
+
+        doc
+      end
+    end
+  end
+end

+ 22 - 0
lib/docs/filters/pandas/entries.rb

@@ -0,0 +1,22 @@
+module Docs
+  class Pandas
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        if dt = at_css('dt')
+          name = dt.content.strip
+          name.sub! %r{\(.*}, '()'
+          name.remove! %r{\s=.*}
+          name.remove! %r{\A(class(method)?) }
+        else
+          name = at_css('h1').content.strip
+        end
+        name.remove! "\u{00B6}"
+        name
+      end
+
+      def get_type
+        css(".toctree-l2.current > a").last.content
+      end
+    end
+  end
+end

+ 29 - 0
lib/docs/scrapers/pandas.rb

@@ -0,0 +1,29 @@
+module Docs
+  class Pandas < UrlScraper
+    self.name = 'pandas'
+    self.type = 'sphinx'
+    self.root_path = 'api.html'
+    self.links = {
+      home: 'http://pandas.pydata.org/',
+      code: 'https://github.com/pydata/pandas'
+    }
+
+    html_filters.push 'pandas/entries', 'pandas/clean_html', 'sphinx/clean_html'
+
+    # Cannot take only the body, as the sidebar gives info about the type.
+    options[:container] = '.document'
+
+    # Using the above container, leads to tons of anchors. Only keep the generated/ pages.
+    options[:only_patterns] = [/\Agenerated\//]
+
+    options[:attribution] = <<-HTML
+      &copy; 2008&ndash;2014, the pandas development team.<br>
+      Licensed under the BSD license.
+    HTML
+
+    version '0.18' do
+      self.release = '0.18.1'
+      self.base_url = "http://pandas.pydata.org/pandas-docs/version/#{self.release}/"
+    end
+  end
+end

BIN
public/icons/docs/pandas/16.png


BIN
public/icons/docs/pandas/16@2x.png


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

@@ -0,0 +1 @@
+http://pandas.pydata.org/_static/pandas_logo.png