Class: Docs::Rdoc::EntriesFilter

Inherits:
EntriesFilter show all
Defined in:
lib/docs/filters/rdoc/entries.rb

Constant Summary

Constants inherited from Filter

Filter::SCHEME_RGX

Instance Method Summary collapse

Methods inherited from EntriesFilter

#build_entries, #build_entry, #call, #default_entry, #entries, #name, #path, #type

Methods inherited from Filter

#absolute_url_string?, #at_css, #at_xpath, #base_url, #css, #current_url, #fragment_url_string?, #initial_page?, #parse_html, #relative_url_string?, #root_page?, #root_path, #root_url, #slug, #subpath, #subpath_to, #xpath

Instance Method Details

#additional_entriesObject


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/docs/filters/rdoc/entries.rb', line 28

def additional_entries
  return [] if root_page?
  require 'cgi'

  css('.method-detail').inject [] do |entries, node|
    name = node['id'].dup
    name.remove! %r{\A\w+?\-.}
    name.remove! %r{\A-(?!\d)}
    name.gsub! '-', '%'
    name = CGI.unescape(name)

    unless name.start_with? '_'
      name.prepend self.name + (node['id'] =~ /\A\w+-c-/ ? '::' : '#')
      entries << [name, node['id']] unless entries.any? { |entry| entry[0] == name }
    end

    entries
  end
end

#get_nameObject


4
5
6
7
8
9
10
11
# File 'lib/docs/filters/rdoc/entries.rb', line 4

def get_name
  name = at_css('h1, h2').content.strip
  name.remove! "\u{00B6}" # remove pilcrow sign
  name.remove! "\u{2191}" # remove up arrow sign
  name.remove! 'class '
  name.remove! 'module '
  name
end

#get_typeObject


13
14
15
16
17
18
19
20
21
22
# File 'lib/docs/filters/rdoc/entries.rb', line 13

def get_type
  type = name.dup

  unless type.gsub! %r{::.*\z}, ''
    parent = at_css('.meta-parent').try(:content).to_s
    return 'Errors' if type.end_with?('Error') || parent.end_with?('Error') || parent.end_with?('Exception')
  end

  type
end

#include_default_entry?Boolean

Returns:

  • (Boolean)

24
25
26
# File 'lib/docs/filters/rdoc/entries.rb', line 24

def include_default_entry?
  at_css('> .description p') || css('.documentation-section').any? { |node| node.content.present? }
end