| @@ -3,14 +3,32 @@ module Docs · 2 unmodified lines |
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | 4 | def get_name |
| 5 | 5 | name = at_css('h1').content.strip |
| 6 | | − name.prepend 'Guide: ' if doc.inner_html.include?('<strong>User\'s Guide</strong>') |
| 6 | + name << " (#{type.remove('Guide: ')})" if name == '1 Introduction' |
| 7 | 7 | name |
| 8 | 8 | end |
| 9 | 9 | |
| 10 | 10 | def get_type |
| 11 | | − type = subpath[/lib\/(.+?)[\-\/]/, 1] |
| 12 | | − type << "/#{name}" if type == 'stdlib' && entry_nodes.length >= 10 |
| 13 | | − type |
| 11 | + if subpath.start_with?('lib/') |
| 12 | + type = subpath[/lib\/(.+?)[\-\/]/, 1] |
| 13 | + type << "/#{name}" if type == 'stdlib' && entry_nodes.length >= 10 |
| 14 | + type |
| 15 | + elsif subpath.start_with?('doc/') |
| 16 | + type = subpath[/doc\/(.+?)\//, 1] |
| 17 | + type.capitalize! |
| 18 | + type.sub! '_', ' ' |
| 19 | + type.sub! 'Oam', 'OAM' |
| 20 | + type.remove! ' Guide' |
| 21 | + type.prepend 'Guide: ' |
| 22 | + type |
| 23 | + elsif subpath.start_with?('erts') |
| 24 | + type = 'ERTS' |
| 25 | + if name =~ /\A\d/ |
| 26 | + type.prepend 'Guide: ' |
| 27 | + elsif entry_nodes.length > 0 |
| 28 | + type << "/#{name}" |
| 29 | + end |
| 30 | + type |
| 31 | + end |
| 14 | 32 | end |
| 15 | 33 | |
| 16 | 34 | def include_default_entry? |
| @@ -18,17 +36,38 @@ module Docs · 1 unmodified line |
| 18 | 36 | end |
| 19 | 37 | |
| 20 | 38 | def additional_entries |
| 21 | | − entry_nodes.map do |node| |
| 22 | | − id = node['name'] |
| 23 | | − name = id.gsub %r{\-(?<arity>.*)\z}, '/\k<arity>' |
| 24 | | − name.remove! 'Module:' |
| 25 | | − name.prepend "#{self.name}:" |
| 26 | | − [name, id] |
| 39 | + return [] unless include_default_entry? |
| 40 | + |
| 41 | + if subpath.start_with?('lib/') |
| 42 | + entry_nodes.map do |node| |
| 43 | + id = node['name'] |
| 44 | + name = id.gsub %r{\-(?<arity>.*)\z}, '/\k<arity>' |
| 45 | + name.remove! 'Module:' |
| 46 | + name.prepend "#{self.name}:" |
| 47 | + [name, id] |
| 48 | + end |
| 49 | + elsif subpath.start_with?('doc/') |
| 50 | + [] |
| 51 | + elsif subpath.start_with?('erts') |
| 52 | + return [] if type.start_with?('Guide') |
| 53 | + entry_nodes.map do |node| |
| 54 | + id = node['href'][/#(.+)/, 1] |
| 55 | + name = node.content.strip |
| 56 | + name.remove! 'Module:' |
| 57 | + name.prepend "#{self.name}:" |
| 58 | + [name, id] |
| 59 | + end |
| 27 | 60 | end |
| 28 | 61 | end |
| 29 | 62 | |
| 30 | 63 | def entry_nodes |
| 31 | | − @entry_nodes ||= css('div.REFBODY + p > a') |
| 64 | + @entry_nodes ||= if subpath.start_with?('lib/') |
| 65 | + css('div.REFBODY + p > a') |
| 66 | + elsif subpath.start_with?('erts') |
| 67 | + link = at_css(".flipMenu a[href='#{File.basename(subpath, '.html')}']") |
| 68 | + list = link.parent.parent |
| 69 | + list['class'] == 'flipMenu' ? [] : list.css('a').to_a.tap { |a| a.delete(link); } |
| 70 | + end |
| 32 | 71 | end |
| 33 | 72 | end |
| 34 | 73 | end |