浏览代码

sklearn support

japborst 9 年之前
父节点
当前提交
1dbc03fab4

+ 10 - 0
assets/stylesheets/pages/_sphinx.scss

@@ -37,6 +37,16 @@
   .admonition-title + dl { padding-top: .5em; }
 
   td > div { margin: 0 !important; }
+
+  .row-fluid {
+    h2 {
+      background: none;
+      border: none;
+      > a {
+        float: none;
+      }
+    }
+  }
 }
 
 ._sphinx {

+ 54 - 0
lib/docs/filters/scikit_learn/entries.rb

@@ -0,0 +1,54 @@
+module Docs
+  class ScikitLearn
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        # Classes, functions and methods
+        if subpath.start_with?('modules/generated')
+          name = at_css('dt').content.strip
+          name.sub! %r{\(.*}, '()' # Remove function arguments
+          name.remove! %r{[\=\[].*} # Remove [source] anchor
+          # name.remove! %r{\s=.*} # Remove the occasional '=' in class names
+          name.remove! %r{\A(class(method)?) (sklearn\.)?}
+        else
+          # User guide
+          name = at_css('h1').content.strip
+        end
+
+        name.remove! "\u{00B6}"
+        name
+      end
+
+      def get_type
+        # Classes, functions and methods
+        if subpath.start_with?('modules/generated')
+          type = at_css('dt > .descclassname').content.strip
+          type.remove! 'sklearn.'
+          type.remove! '.'
+          type
+        else
+          'Guide'
+        end
+      end
+
+      def additional_entries
+        entries = []
+
+        css('.class > dt[id]', '.exception > dt[id]', '.attribute > dt[id]').each do |node|
+          entries << [node['id'].remove('sklearn.'), node['id']]
+        end
+
+        css('.data > dt[id]').each do |node|
+          if node['id'].split('.').last.upcase! # skip constants
+            entries << [node['id'].remove('sklearn.'), node['id']]
+          end
+        end
+
+        css('.function > dt[id]', '.method > dt[id]', '.classmethod > dt[id]').each do |node|
+          entries << [node['id'].remove('sklearn.') + '()', node['id']]
+        end
+
+        entries
+      end
+    end
+  end
+end

+ 36 - 0
lib/docs/scrapers/scikit_learn.rb

@@ -0,0 +1,36 @@
+module Docs
+  class ScikitLearn < UrlScraper
+    self.name = 'scikit-learn'
+    self.slug = 'scikit_learn'
+    self.type = 'sphinx'
+    self.release = '0.17.1'
+    self.base_url = "http://scikit-learn.org/0.17/"
+    self.root_path = 'documentation.html'
+    self.initial_paths = %w(
+      user_guide.html
+      supervised_learning.html
+      unsupervised_learning.html
+      model_selection.html
+      data_transforms.html)
+
+    self.links = {
+      home: 'http://scikit-learn.org/',
+      code: 'https://github.com/scikit-learn/scikit-learn'
+    }
+
+    html_filters.push 'scikit_learn/entries', 'sphinx/clean_html'
+
+    options[:container] = '.body'
+
+    options[:root_title] = self.name
+
+    options[:only] = self.initial_paths
+    options[:only_patterns] = [/\Amodules/, /\Adatasets/]
+
+    options[:attribution] = <<-HTML
+      &copy; 2007&ndash;2016 The scikit-learn deveopers<br>
+      Licensed under the 3-clause BSD License.
+    HTML
+
+  end
+end

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


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


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

@@ -0,0 +1 @@
+http://scikit-learn.org/stable/_static/favicon.ico