From 1941687bf0d74105c283820dc9a4ef9bd46624a3 Mon Sep 17 00:00:00 2001 From: japborst Date: Thu, 15 Sep 2016 23:48:10 +0200 Subject: [PATCH] Add pandas documentation --- assets/javascripts/models/entry.coffee | 1 + lib/docs/filters/pandas/clean_html.rb | 11 ++++++++++ lib/docs/filters/pandas/entries.rb | 22 +++++++++++++++++++ lib/docs/scrapers/pandas.rb | 29 +++++++++++++++++++++++++ public/icons/docs/pandas/16.png | Bin 0 -> 307 bytes public/icons/docs/pandas/16@2x.png | Bin 0 -> 414 bytes public/icons/docs/pandas/SOURCE | 1 + 7 files changed, 64 insertions(+) create mode 100644 lib/docs/filters/pandas/clean_html.rb create mode 100644 lib/docs/filters/pandas/entries.rb create mode 100644 lib/docs/scrapers/pandas.rb create mode 100644 public/icons/docs/pandas/16.png create mode 100644 public/icons/docs/pandas/16@2x.png create mode 100644 public/icons/docs/pandas/SOURCE diff --git a/assets/javascripts/models/entry.coffee b/assets/javascripts/models/entry.coffee index 9756bd53..2288ecd5 100644 --- a/assets/javascripts/models/entry.coffee +++ b/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' diff --git a/lib/docs/filters/pandas/clean_html.rb b/lib/docs/filters/pandas/clean_html.rb new file mode 100644 index 00000000..e8cd74ae --- /dev/null +++ b/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 diff --git a/lib/docs/filters/pandas/entries.rb b/lib/docs/filters/pandas/entries.rb new file mode 100644 index 00000000..5ccd9615 --- /dev/null +++ b/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 diff --git a/lib/docs/scrapers/pandas.rb b/lib/docs/scrapers/pandas.rb new file mode 100644 index 00000000..418bd952 --- /dev/null +++ b/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 + © 2008–2014, the pandas development team.
+ 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 diff --git a/public/icons/docs/pandas/16.png b/public/icons/docs/pandas/16.png new file mode 100644 index 0000000000000000000000000000000000000000..8618dd6ebd339e911ff329b1ce31d3bf111f588c GIT binary patch literal 307 zcmV-30nGl1P))Q9;aKM20Fsxa-_5ZSy5B_V` zZ2iCJ*!}-%)m#5>x%d<;_xsP^|L}y=z4OL@t=jDvHYrtZ`M>1E12De+>?7FbO&6XZ zq7lYeaq8j!__-%>8i4F{tOno$!@z(&S6}>p^!5u*c>t0hnt|^pBy<1(002ovPDHLk FV1g!qjkcR;RZvrye35aPGmo|GM=%z_@Y+U1Y=N&fBWUf|G2p)z_@7TIWQk4f8*K5|0nLe zf%7jsdiTF$`!%@w+b=%-PhEHl&j0iGADrE_2*Z=?k literal 0 HcmV?d00001 diff --git a/public/icons/docs/pandas/SOURCE b/public/icons/docs/pandas/SOURCE new file mode 100644 index 00000000..b19b45d3 --- /dev/null +++ b/public/icons/docs/pandas/SOURCE @@ -0,0 +1 @@ +http://pandas.pydata.org/_static/pandas_logo.png \ No newline at end of file