Class: Docs::Ruby::EntriesFilter

Inherits:
Docs::Rdoc::EntriesFilter show all
Defined in:
lib/docs/filters/ruby/entries.rb

Constant Summary collapse

REPLACE_TYPE =
{
'ACL'               => 'DRb',
'Addrinfo'          => 'Socket',
'BigMath'           => 'BigDecimal',
'CMath'             => 'Math',
'ConditionVariable' => 'Mutex',
'DEBUGGER__'        => 'Debug',
'Errno'             => 'Errors',
'FileTest'          => 'File',
'Jacobian'          => 'BigDecimal',
'LUSolve'           => 'BigDecimal',
'Newton'            => 'BigDecimal',
'PP'                => 'PrettyPrint',
'Profiler__'        => 'Profiler',
'Psych'             => 'YAML',
'Rinda'             => 'DRb',
'SimpleDelegator'   => 'Delegator',
'SingleForwardable' => 'Forwardable',
'SortedSet'         => 'Set',
'TCPServer'         => 'Socket',
'TempIO'            => 'Tempfile',
'ThWait'            => 'Thread',
'UNIXServer'        => 'Socket' }
REPLACE_TYPE_STARTS_WITH =
{
'Monitor' => 'Monitor',
'Mutex'   => 'Mutex',
'Shell'   => 'Shell',
'Sync'    => 'Sync',
'Thread'  => 'Thread' }
REPLACE_TYPE_ENDS_WITH =
{
'Queue'  => 'Queue',
'Socket' => 'Socket' }

Constants inherited from Filter

Filter::SCHEME_RGX

Instance Method Summary collapse

Methods inherited from Docs::Rdoc::EntriesFilter

#get_name

Methods inherited from EntriesFilter

#build_entries, #build_entry, #call, #default_entry, #entries, #get_name, #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


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/docs/filters/ruby/entries.rb', line 56

def additional_entries
  return super unless guide?

  if slug == 'syntax/control_expressions_rdoc' || slug == 'syntax/miscellaneous_rdoc'
    css('h2 > code').each_with_object([]) do |node, entries|
      name = node.content.strip
      entries << [name, node.parent['id'], 'Syntax'] unless entries.any? { |e| e[0] == name }
    end
  elsif slug == 'globals_rdoc'
    css('dt').map do |node|
      name = node['id'] = node.content.strip
      [name, name, 'Globals']
    end
  else
    []
  end
end

#get_typeObject


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/docs/filters/ruby/entries.rb', line 39

def get_type
  return 'Language' if guide?
  return $1 if name =~ /\A(Net\:\:(?:FTP|HTTP|IMAP|SMTP))/

  type = super

  REPLACE_TYPE_STARTS_WITH.each_pair do |key, value|
    return value if type.start_with?(key)
  end

  REPLACE_TYPE_ENDS_WITH.each_pair do |key, value|
    return value if type.end_with?(key)
  end

  REPLACE_TYPE[type] || type
end

#guide?Boolean


78
79
80
# File 'lib/docs/filters/ruby/entries.rb', line 78

def guide?
  slug =~ /[^\/]+_rdoc/
end

#include_default_entry?Boolean


74
75
76
# File 'lib/docs/filters/ruby/entries.rb', line 74

def include_default_entry?
  guide? || super
end