Skip to content

Commit 1dbc03f

Browse files
japborstThibaut
authored andcommitted
sklearn support
1 parent e1937ff commit 1dbc03f

6 files changed

Lines changed: 101 additions & 0 deletions

File tree

assets/stylesheets/pages/_sphinx.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@
3737
.admonition-title + dl { padding-top: .5em; }
3838

3939
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+
}
4050
}
4151

4252
._sphinx {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
module 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
54+
end

lib/docs/scrapers/scikit_learn.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module 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
36+
end
270 Bytes
Loading
636 Bytes
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
http://scikit-learn.org/stable/_static/favicon.ico

0 commit comments

Comments
 (0)