| @@ -3,11 +3,7 @@ module Docs · 2 unmodified lines |
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | 4 | def get_name |
| 5 | 5 | 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) |
| 11 | 7 | else |
| 12 | 8 | name = at_css('h1').content.strip |
| 13 | 9 | end |
| @@ -26,14 +22,26 @@ module Docs · 12 unmodified lines |
| 26 | 22 | type = at_css('h1').content.strip |
| 27 | 23 | type.remove! "\u{00B6}" |
| 28 | 24 | |
| 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.') |
| 31 | 27 | type = 'Polynomials' |
| 32 | 28 | elsif type.start_with?('numpy.ufunc.') |
| 33 | 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 | 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 | 45 | type = 'String operations' |
| 38 | 46 | elsif type == 'numpy.memmap.shape' |
| 39 | 47 | type = 'Input and output' |
| @@ -50,6 +58,29 @@ module Docs · 10 unmodified lines |
| 50 | 58 | type.sub! 'swig', 'Swig' |
| 51 | 59 | type |
| 52 | 60 | 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 | 84 | end |
| 54 | 85 | end |
| 55 | 86 | end |