Unified · Split
| @@ -0,0 +1,18 @@ | |||
| 1 | module Docs | ||
| 2 | class Numpy | ||
| 3 | class CleanHtmlFilter < Filter | ||
| 4 | def call | ||
| 5 | @doc = at_css('#spc-section-body') | ||
| 6 | |||
| 7 | css('.headerlink').remove # remove permalinks | ||
| 8 | |||
| 9 | # Add class for correct syntax highlighting | ||
| 10 | css('pre').each do |pre| | ||
| 11 | pre['class'] = 'python' | ||
| 12 | end | ||
| 13 | |||
| 14 | doc | ||
| 15 | end | ||
| 16 | end | ||
| 17 | end | ||
| 18 | end | ||
| @@ -0,0 +1,50 @@ | |||
| 1 | module Docs | ||
| 2 | class Numpy | ||
| 3 | class EntriesFilter < Docs::EntriesFilter | ||
| 4 | def get_name | ||
| 5 | dt = at_css('dt') | ||
| 6 | if dt | ||
| 7 | name = dt.content | ||
| 8 | name.sub! /\(.*/, '()' | ||
| 9 | name.sub! /[\=\[].*/, '' | ||
| 10 | name.remove! 'class ' | ||
| 11 | name.remove! 'classmethod ' | ||
| 12 | name.remove! 'exception ' | ||
| 13 | else | ||
| 14 | name = at_css('h1').content.strip | ||
| 15 | end | ||
| 16 | name.remove! '¶' # remove permalinks from title | ||
| 17 | name | ||
| 18 | end | ||
| 19 | |||
| 20 | def get_type | ||
| 21 | type = name.dup | ||
| 22 | nav_items = at_css('.nav.nav-pills.pull-left').children | ||
| 23 | if nav_items[7] | ||
| 24 | # Infer type from navigation item if possible... | ||
| 25 | type = nav_items[7].content | ||
| 26 | else | ||
| 27 | # ... or the page is probably an overview, so use its title. | ||
| 28 | type = at_css('h1').content | ||
| 29 | type.remove! '¶' # remove permalinks from type | ||
| 30 | |||
| 31 | # Handle some edge cases that arent proberly categorized in the docs | ||
| 32 | if type[0..16] == 'numpy.polynomial.' | ||
| 33 | type = 'Polynomials' | ||
| 34 | elsif type[0..11] == 'numpy.ufunc.' | ||
| 35 | type = 'Universal functions (ufunc)' | ||
| 36 | elsif type[0..12] == 'numpy.nditer.' | ||
| 37 | type = 'Indexing routines' | ||
| 38 | elsif type == 'numpy.core.defchararray.chararray.argsort' | ||
| 39 | type = 'String operations' | ||
| 40 | elsif type == 'numpy.memmap.shape' | ||
| 41 | type = 'Input and output' | ||
| 42 | elsif type == 'numpy.poly1d.variable' | ||
| 43 | type = 'Polynomials' | ||
| 44 | end | ||
| 45 | end | ||
| 46 | type | ||
| 47 | end | ||
| 48 | end | ||
| 49 | end | ||
| 50 | end | ||
| @@ -0,0 +1,36 @@ | |||
| 1 | module Docs | ||
| 2 | class Numpy < FileScraper | ||
| 3 | self.name = 'NumPy' | ||
| 4 | self.type = 'sphinx' | ||
| 5 | self.root_path = 'routines.html' | ||
| 6 | self.links = { | ||
| 7 | home: 'http://www.numpy.org/', | ||
| 8 | code: 'https://github.com/numpy/numpy' | ||
| 9 | } | ||
| 10 | |||
| 11 | html_filters.push 'numpy/entries', 'numpy/clean_html' | ||
| 12 | |||
| 13 | # .main contains more than the page's content alone, but we need something | ||
| 14 | # that includes the navigation bar as well in order to guess the type of | ||
| 15 | # most pages. | ||
| 16 | options[:container] = '.main' | ||
| 17 | |||
| 18 | # "generated" pages seem to be autogenerated from python docstrings. | ||
| 19 | # "routines" are mostly lists that help organize the generated pages. | ||
| 20 | # Everything else is manual-like and probably not desired in Devdocs. | ||
| 21 | options[:only_patterns] = [ | ||
| 22 | /routines\.?.*\.html/, | ||
| 23 | /generated.*/] | ||
| 24 | |||
| 25 | options[:attribution] = <<-HTML | ||
| 26 | © Copyright 2008-2015, The Scipy community.<br> | ||
| 27 | Licensed under a BSD-new License. | ||
| 28 | HTML | ||
| 29 | |||
| 30 | version '1.10' do | ||
| 31 | self.release = '1.10' | ||
| 32 | self.dir = '/vagrant/numpy-html/reference/' | ||
| 33 | # self.base_url = 'http://docs.scipy.org/doc/numpy/reference/' | ||
| 34 | end | ||
| 35 | end | ||
| 36 | end | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1 @@ | |||
| 1 | https://www.scipy.org/_static/images/numpylogo_med.png | ||