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
528 'https://raw.githubusercontent.com/npm/npm/master/LICENSE'528 'https://raw.githubusercontent.com/npm/npm/master/LICENSE'
529 ], [529 ], [
530 'NumPy',530 'NumPy',
531 '2008-2017 NumPy Developers',531 '2005-2019 NumPy Developers',
532 'NumPy',532 'BSD',
533 'https://raw.githubusercontent.com/numpy/numpy/master/LICENSE.txt'533 'https://raw.githubusercontent.com/numpy/numpy/master/LICENSE.txt'
534 ], [534 ], [
535 'Octave',535 'Octave',
lib/docs/filters/numpy/clean_html.rb+1−3
@@ -2,9 +2,7 @@ module Docs · 1 unmodified line
2 class Numpy2 class Numpy
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 @doc = at_css('#spc-section-body')5 at_css('#spc-section-body')
6
7 doc
8 end6 end
9 end7 end
10 end8 end
lib/docs/filters/numpy/entries.rb+40−9
@@ -3,11 +3,7 @@ module Docs · 2 unmodified lines
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 def get_name4 def get_name
5 if dt = at_css('dt')5 if dt = at_css('dt')
6 name = dt.content.strip6 name = dt_to_name(dt)
7 name.sub! %r{\(.*}, '()'
8 name.remove! %r{[\=\[].*}
9 name.remove! %r{\A(class(method)?|exception) }
10 name.remove! %r{\s—.*}
11 else7 else
12 name = at_css('h1').content.strip8 name = at_css('h1').content.strip
13 end9 end
@@ -26,14 +22,26 @@ module Docs · 12 unmodified lines
26 type = at_css('h1').content.strip22 type = at_css('h1').content.strip
27 type.remove! "\u{00B6}"23 type.remove! "\u{00B6}"
28 24
29 # Handle some edge cases that arent proberly categorized in the docs25 # Handle some edge cases that aren't properly categorized in the docs
30 if type.start_with?('numpy.polynomial.')26 if type.start_with?('numpy.polynomial.') || type.start_with?('numpy.poly1d.')
31 type = 'Polynomials'27 type = 'Polynomials'
32 elsif type.start_with?('numpy.ufunc.')28 elsif type.start_with?('numpy.ufunc.')
33 type = 'Universal functions'29 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.')
35 type = 'Indexing routines'31 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.')
37 type = 'String operations'45 type = 'String operations'
38 elsif type == 'numpy.memmap.shape'46 elsif type == 'numpy.memmap.shape'
39 type = 'Input and output'47 type = 'Input and output'
@@ -50,6 +58,29 @@ module Docs · 10 unmodified lines
50 type.sub! 'swig', 'Swig'58 type.sub! 'swig', 'Swig'
51 type59 type
52 end60 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
53 end84 end
54 end85 end
55end86end
lib/docs/scrapers/numpy.rb+21−5
@@ -4,7 +4,7 @@ module Docs · 3 unmodified lines
4 self.type = 'sphinx'4 self.type = 'sphinx'
5 self.root_path = 'index.html'5 self.root_path = 'index.html'
6 self.links = {6 self.links = {
7 home: 'http://www.numpy.org/',7 home: 'https://www.numpy.org/',
8 code: 'https://github.com/numpy/numpy'8 code: 'https://github.com/numpy/numpy'
9 }9 }
10 10
@@ -21,12 +21,27 @@ module Docs · 10 unmodified lines
21 ]21 ]
22 22
23 options[:attribution] = <<-HTML23 options[:attribution] = <<-HTML
24 &copy; 2008&ndash;2017 NumPy Developers<br>24 &copy; 2005&ndash;2019 NumPy Developers<br>
25 Licensed under the NumPy License.25 Licensed under the 3-clause BSD License.
26 HTML26 HTML
27 27
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
28 version '1.14' do43 version '1.14' do
29 self.release = '1.14.2'44 self.release = '1.14.5'
30 self.base_url = "https://docs.scipy.org/doc/numpy-#{self.release}/reference/"45 self.base_url = "https://docs.scipy.org/doc/numpy-#{self.release}/reference/"
31 end46 end
32 47
@@ -51,7 +66,8 @@ module Docs · 18 unmodified lines
51 end66 end
52 67
53 def get_latest_version(opts)68 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]
55 end71 end
56 end72 end
57end73end