mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Add NumPy documentation
This commit is contained in:
parent
3b72e254c3
commit
547f4f54ed
6 changed files with 105 additions and 0 deletions
18
lib/docs/filters/numpy/clean_html.rb
Normal file
18
lib/docs/filters/numpy/clean_html.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
module Docs
|
||||
class Numpy
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
@doc = at_css('#spc-section-body')
|
||||
|
||||
css('.headerlink').remove # remove permalinks
|
||||
|
||||
# Add class for correct syntax highlighting
|
||||
css('pre').each do |pre|
|
||||
pre['class'] = 'python'
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
50
lib/docs/filters/numpy/entries.rb
Normal file
50
lib/docs/filters/numpy/entries.rb
Normal file
|
@ -0,0 +1,50 @@
|
|||
module Docs
|
||||
class Numpy
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
dt = at_css('dt')
|
||||
if dt
|
||||
name = dt.content
|
||||
name.sub! /\(.*/, '()'
|
||||
name.sub! /[\=\[].*/, ''
|
||||
name.remove! 'class '
|
||||
name.remove! 'classmethod '
|
||||
name.remove! 'exception '
|
||||
else
|
||||
name = at_css('h1').content.strip
|
||||
end
|
||||
name.remove! '¶' # remove permalinks from title
|
||||
name
|
||||
end
|
||||
|
||||
def get_type
|
||||
type = name.dup
|
||||
nav_items = at_css('.nav.nav-pills.pull-left').children
|
||||
if nav_items[7]
|
||||
# Infer type from navigation item if possible...
|
||||
type = nav_items[7].content
|
||||
else
|
||||
# ... or the page is probably an overview, so use its title.
|
||||
type = at_css('h1').content
|
||||
type.remove! '¶' # remove permalinks from type
|
||||
|
||||
# Handle some edge cases that arent proberly categorized in the docs
|
||||
if type[0..16] == 'numpy.polynomial.'
|
||||
type = 'Polynomials'
|
||||
elsif type[0..11] == 'numpy.ufunc.'
|
||||
type = 'Universal functions (ufunc)'
|
||||
elsif type[0..12] == 'numpy.nditer.'
|
||||
type = 'Indexing routines'
|
||||
elsif type == 'numpy.core.defchararray.chararray.argsort'
|
||||
type = 'String operations'
|
||||
elsif type == 'numpy.memmap.shape'
|
||||
type = 'Input and output'
|
||||
elsif type == 'numpy.poly1d.variable'
|
||||
type = 'Polynomials'
|
||||
end
|
||||
end
|
||||
type
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
36
lib/docs/scrapers/numpy.rb
Normal file
36
lib/docs/scrapers/numpy.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
module Docs
|
||||
class Numpy < FileScraper
|
||||
self.name = 'NumPy'
|
||||
self.type = 'sphinx'
|
||||
self.root_path = 'routines.html'
|
||||
self.links = {
|
||||
home: 'http://www.numpy.org/',
|
||||
code: 'https://github.com/numpy/numpy'
|
||||
}
|
||||
|
||||
html_filters.push 'numpy/entries', 'numpy/clean_html'
|
||||
|
||||
# .main contains more than the page's content alone, but we need something
|
||||
# that includes the navigation bar as well in order to guess the type of
|
||||
# most pages.
|
||||
options[:container] = '.main'
|
||||
|
||||
# "generated" pages seem to be autogenerated from python docstrings.
|
||||
# "routines" are mostly lists that help organize the generated pages.
|
||||
# Everything else is manual-like and probably not desired in Devdocs.
|
||||
options[:only_patterns] = [
|
||||
/routines\.?.*\.html/,
|
||||
/generated.*/]
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© Copyright 2008-2015, The Scipy community.<br>
|
||||
Licensed under a BSD-new License.
|
||||
HTML
|
||||
|
||||
version '1.10' do
|
||||
self.release = '1.10'
|
||||
self.dir = '/vagrant/numpy-html/reference/'
|
||||
# self.base_url = 'http://docs.scipy.org/doc/numpy/reference/'
|
||||
end
|
||||
end
|
||||
end
|
BIN
public/icons/docs/numpy/16.png
Normal file
BIN
public/icons/docs/numpy/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
public/icons/docs/numpy/16@2x.png
Normal file
BIN
public/icons/docs/numpy/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
1
public/icons/docs/numpy/SOURCE
Normal file
1
public/icons/docs/numpy/SOURCE
Normal file
|
@ -0,0 +1 @@
|
|||
https://www.scipy.org/_static/images/numpylogo_med.png
|
Loading…
Reference in a new issue