History

sklearn support

japborst committed 10 years ago

Commit 1dbc03f1 parent e1937ff6 files · +99 −-2Browse files

Unified · Split

6 files
  1. assets/stylesheets/pages/_sphinx.scss +10 −0
  2. lib/docs/filters/scikit_learn/entries.rb +54 −0
  3. lib/docs/scrapers/scikit_learn.rb +36 −0
  4. public/icons/docs/scikit_learn/16.png +0 −0
  5. public/icons/docs/scikit_learn/16@2x.png +0 −0
  6. public/icons/docs/scikit_learn/SOURCE +1 −0
assets/stylesheets/pages/_sphinx.scss+10−0
@@ -37,6 +37,16 @@ · 36 unmodified lines
37 .admonition-title + dl { padding-top: .5em; }37 .admonition-title + dl { padding-top: .5em; }
38 38
39 td > div { margin: 0 !important; }39 td > div { margin: 0 !important; }
40
41 .row-fluid {
42 h2 {
43 background: none;
44 border: none;
45 > a {
46 float: none;
47 }
48 }
49 }
40}50}
41 51
42._sphinx {52._sphinx {
lib/docs/filters/scikit_learn/entries.rb+54−0
@@ -0,0 +1,54 @@
1module Docs
2 class ScikitLearn
3 class EntriesFilter < Docs::EntriesFilter
4 def get_name
5 # Classes, functions and methods
6 if subpath.start_with?('modules/generated')
7 name = at_css('dt').content.strip
8 name.sub! %r{\(.*}, '()' # Remove function arguments
9 name.remove! %r{[\=\[].*} # Remove [source] anchor
10 # name.remove! %r{\s=.*} # Remove the occasional '=' in class names
11 name.remove! %r{\A(class(method)?) (sklearn\.)?}
12 else
13 # User guide
14 name = at_css('h1').content.strip
15 end
16
17 name.remove! "\u{00B6}"
18 name
19 end
20
21 def get_type
22 # Classes, functions and methods
23 if subpath.start_with?('modules/generated')
24 type = at_css('dt > .descclassname').content.strip
25 type.remove! 'sklearn.'
26 type.remove! '.'
27 type
28 else
29 'Guide'
30 end
31 end
32
33 def additional_entries
34 entries = []
35
36 css('.class > dt[id]', '.exception > dt[id]', '.attribute > dt[id]').each do |node|
37 entries << [node['id'].remove('sklearn.'), node['id']]
38 end
39
40 css('.data > dt[id]').each do |node|
41 if node['id'].split('.').last.upcase! # skip constants
42 entries << [node['id'].remove('sklearn.'), node['id']]
43 end
44 end
45
46 css('.function > dt[id]', '.method > dt[id]', '.classmethod > dt[id]').each do |node|
47 entries << [node['id'].remove('sklearn.') + '()', node['id']]
48 end
49
50 entries
51 end
52 end
53 end
54end
lib/docs/scrapers/scikit_learn.rb+36−0
@@ -0,0 +1,36 @@
1module Docs
2 class ScikitLearn < UrlScraper
3 self.name = 'scikit-learn'
4 self.slug = 'scikit_learn'
5 self.type = 'sphinx'
6 self.release = '0.17.1'
7 self.base_url = "http://scikit-learn.org/0.17/"
8 self.root_path = 'documentation.html'
9 self.initial_paths = %w(
10 user_guide.html
11 supervised_learning.html
12 unsupervised_learning.html
13 model_selection.html
14 data_transforms.html)
15
16 self.links = {
17 home: 'http://scikit-learn.org/',
18 code: 'https://github.com/scikit-learn/scikit-learn'
19 }
20
21 html_filters.push 'scikit_learn/entries', 'sphinx/clean_html'
22
23 options[:container] = '.body'
24
25 options[:root_title] = self.name
26
27 options[:only] = self.initial_paths
28 options[:only_patterns] = [/\Amodules/, /\Adatasets/]
29
30 options[:attribution] = <<-HTML
31 &copy; 2007&ndash;2016 The scikit-learn deveopers<br>
32 Licensed under the 3-clause BSD License.
33 HTML
34
35 end
36end
public/icons/docs/scikit_learn/16.png+0−0

Binary file not shown.

public/icons/docs/scikit_learn/16@2x.png+0−0

Binary file not shown.

public/icons/docs/scikit_learn/SOURCE+1−0
@@ -0,0 +1 @@
1http://scikit-learn.org/stable/_static/favicon.ico