History

Update NumPy documentation (1.17.0)

Jasper van Merle committed 7 years ago

Commit 4eeca311 parent ffb39cb4 files · +64 −19Browse files

Unified · Split

4 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +2 −2
  2. lib/docs/filters/numpy/clean_html.rb +1 −3
  3. lib/docs/filters/numpy/entries.rb +40 −9
  4. lib/docs/scrapers/numpy.rb +21 −5
assets/javascripts/templates/pages/about_tmpl.coffee+2−2
@@ -528,8 +528,8 @@ credits = [ · 527 unmodified lines
528528 'https://raw.githubusercontent.com/npm/npm/master/LICENSE'
529529 ], [
530530 'NumPy',
531− '2008-2017 NumPy Developers',
532− 'NumPy',
531+ '2005-2019 NumPy Developers',
532+ 'BSD',
533533 'https://raw.githubusercontent.com/numpy/numpy/master/LICENSE.txt'
534534 ], [
535535 'Octave',
lib/docs/filters/numpy/clean_html.rb+1−3
@@ -2,9 +2,7 @@ module Docs · 1 unmodified line
22 class Numpy
33 class CleanHtmlFilter < Filter
44 def call
5− @doc = at_css('#spc-section-body')
6−
7− doc
5+ at_css('#spc-section-body')
86 end
97 end
108 end
lib/docs/filters/numpy/entries.rb+40−9
@@ -3,11 +3,7 @@ module Docs · 2 unmodified lines
33 class EntriesFilter < Docs::EntriesFilter
44 def get_name
55 if dt = at_css('dt')
6− name = dt.content.strip
7− name.sub! %r{\(.*}, '()'
8− name.remove! %r{[\=\[].*}
9− name.remove! %r{\A(class(method)?|exception) }
10− name.remove! %r{\s—.*}
6+ name = dt_to_name(dt)
117 else
128 name = at_css('h1').content.strip
139 end
@@ -26,14 +22,26 @@ module Docs · 12 unmodified lines
2622 type = at_css('h1').content.strip
2723 type.remove! "\u{00B6}"
2824
29− # Handle some edge cases that arent proberly categorized in the docs
30− if type.start_with?('numpy.polynomial.')
25+ # Handle some edge cases that aren't properly categorized in the docs
26+ if type.start_with?('numpy.polynomial.') || type.start_with?('numpy.poly1d.')
3127 type = 'Polynomials'
3228 elsif type.start_with?('numpy.ufunc.')
3329 type = 'Universal functions'
34− elsif type.start_with?('numpy.nditer.')
30+ elsif type.start_with?('numpy.nditer.') || type.start_with?('numpy.lib.Arrayterator.') || type.start_with?('numpy.flatiter.')
3531 type = 'Indexing routines'
36− elsif type == 'numpy.core.defchararray.chararray.argsort'
32+ elsif type.start_with?('numpy.record.') || type.start_with?('numpy.recarray.') || type.start_with?('numpy.broadcast.') || type.start_with?('numpy.matrix.')
33+ type = 'Standard array subclasses'
34+ elsif type.start_with?('numpy.busdaycalendar.')
35+ type = 'Datetime support functions'
36+ elsif type.start_with?('numpy.random.')
37+ type = 'Random sampling'
38+ elsif type.start_with?('numpy.iinfo.')
39+ type = 'Data type routines'
40+ elsif type.start_with?('numpy.dtype.')
41+ type = 'Data type objects'
42+ elsif type.start_with?('numpy.generic.')
43+ type = 'Scalars'
44+ elsif type.start_with?('numpy.char.chararray.') || type.start_with?('numpy.core.defchararray.chararray.')
3745 type = 'String operations'
3846 elsif type == 'numpy.memmap.shape'
3947 type = 'Input and output'
@@ -50,6 +58,29 @@ module Docs · 10 unmodified lines
5058 type.sub! 'swig', 'Swig'
5159 type
5260 end
61+
62+ def additional_entries
63+ css('dl:not(:first-of-type) > dt[id]').each_with_object [] do |node, entries|
64+ name = dt_to_name(node)
65+
66+ if type == 'NumPy C API'
67+ name = name.rpartition(' ').last
68+ name = name[2..-1] if name.start_with?('**')
69+ name = name[1..-1] if name.start_with?('*')
70+ end
71+
72+ entries << [name, node['id']]
73+ end
74+ end
75+
76+ def dt_to_name(dt)
77+ name = dt.content.strip
78+ name.sub! %r{\(.*}, '()'
79+ name.remove! %r{[\=\[].*}
80+ name.remove! %r{\A(class(method)?|exception) }
81+ name.remove! %r{\s—.*}
82+ name.remove! '¶'
83+ end
5384 end
5485 end
5586 end
lib/docs/scrapers/numpy.rb+21−5
@@ -4,7 +4,7 @@ module Docs · 3 unmodified lines
44 self.type = 'sphinx'
55 self.root_path = 'index.html'
66 self.links = {
7− home: 'http://www.numpy.org/',
7+ home: 'https://www.numpy.org/',
88 code: 'https://github.com/numpy/numpy'
99 }
1010
@@ -21,12 +21,27 @@ module Docs · 10 unmodified lines
2121 ]
2222
2323 options[:attribution] = <<-HTML
24− &copy; 2008&ndash;2017 NumPy Developers<br>
25− Licensed under the NumPy License.
24+ &copy; 2005&ndash;2019 NumPy Developers<br>
25+ Licensed under the 3-clause BSD License.
2626 HTML
2727
28+ version '1.17' do
29+ self.release = '1.17.0'
30+ self.base_url = "https://docs.scipy.org/doc/numpy-#{self.release}/reference/"
31+ end
32+
33+ version '1.16' do
34+ self.release = '1.16.1'
35+ self.base_url = "https://docs.scipy.org/doc/numpy-#{self.release}/reference/"
36+ end
37+
38+ version '1.15' do
39+ self.release = '1.15.4'
40+ self.base_url = "https://docs.scipy.org/doc/numpy-#{self.release}/reference/"
41+ end
42+
2843 version '1.14' do
29− self.release = '1.14.2'
44+ self.release = '1.14.5'
3045 self.base_url = "https://docs.scipy.org/doc/numpy-#{self.release}/reference/"
3146 end
3247
@@ -51,7 +66,8 @@ module Docs · 18 unmodified lines
5166 end
5267
5368 def get_latest_version(opts)
54− get_latest_github_release('numpy', 'numpy', opts)
69+ html = fetch('https://docs.scipy.org/doc/', opts)
70+ html.scan(/Numpy ([0-9.]+) Reference Guide/)[0][0]
5571 end
5672 end
5773 end