History

Statsmodels support

japborst committed 10 years ago

Commit 06f5fae1 parent 721adf86 files · +73 −-2Browse files

Showing the changes to lib/docs (3 of 6 files). Show all

Unified · Split

3 files
  1. lib/docs/filters/statsmodels/clean_html.rb +18 −0
  2. lib/docs/filters/statsmodels/entries.rb +30 −0
  3. lib/docs/scrapers/statsmodels.rb +26 −0
lib/docs/filters/statsmodels/clean_html.rb+18−0
@@ -0,0 +1,18 @@
1module Docs
2 class Statsmodels
3 class CleanHtmlFilter < Filter
4 def call
5 @doc = at_css('.body')
6
7 if root_page?
8 at_css('h1').content = 'Statsmodels'
9 at_css('#basic-documentation').remove
10 at_css('#table-of-contents').remove
11 at_css('#indices-and-tables').remove
12 end
13
14 doc
15 end
16 end
17 end
18end
lib/docs/filters/statsmodels/entries.rb+30−0
@@ -0,0 +1,30 @@
1module Docs
2 class Statsmodels
3 class EntriesFilter < Docs::EntriesFilter
4 def get_name
5 if subpath.start_with?('generated')
6 name = at_css('dt').content.strip
7 name.sub! %r{\(.*}, '()' # Remove method arguments
8 name.remove! %r{[\=\[].*} # Remove "[source]"
9 name.remove! %r{\A(class(method)?) (statsmodels\.)?}
10 else
11 name = at_css('h1').content.strip
12 end
13 name.remove! "\u{00B6}" # Remove ¶
14 name
15 end
16
17 def get_type
18 if subpath.start_with?('generated')
19 # '> text()' doesn't include children's text in type naming
20 at_xpath('//div[@class="related"]//li[not(@class="right")][7]/a/text()').content
21
22 elsif subpath.start_with?('examples')
23 'Examples'
24 else
25 'Manual'
26 end
27 end
28 end
29 end
30end
lib/docs/scrapers/statsmodels.rb+26−0
@@ -0,0 +1,26 @@
1module Docs
2 class Statsmodels < UrlScraper
3 self.name = 'Statsmodels'
4 self.type = 'sphinx'
5 self.release = '0.6.1'
6 self.base_url = "http://statsmodels.sourceforge.net/stable/"
7 self.root_path = 'index.html'
8 self.links = {
9 home: 'http://statsmodels.sourceforge.net/',
10 code: 'https://github.com/statsmodels/statsmodels/'
11 }
12
13 html_filters.push 'statsmodels/entries', 'statsmodels/clean_html', 'sphinx/clean_html'
14
15 options[:skip] = %w(about.html)
16 options[:skip_patterns] = [/\Arelease/, /\Adev/, /\A_modules/, /\Adatasets/]
17
18 options[:attribution] = <<-HTML
19 &copy; 2009&ndash;2012 Statsmodels Developers<br>
20 &copy; 2006&ndash;2008 Scipy Developers<br>
21 &copy; 2006 Jonathan E. Taylor<br>
22 Licensed under the 3-clause BSD License.
23 HTML
24
25 end
26end