Class: Docs::Cpp::EntriesFilter

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

Constant Summary collapse

REPLACE_NAMES =
{
'Error directive' => '#error directive',
'Filename and line information' => '#line directive',
'Implementation defined behavior control' => '#pragma directive',
'Replacing text macros' => '#define directive',
'Source file inclusion' => '#include directive' }

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


37
38
39
40
41
42
43
44
# File 'lib/docs/filters/cpp/entries.rb', line 37

def additional_entries
  return [] unless include_default_entry?
  names = at_css('#firstHeading').content.remove(%r{\(.+?\)}).split(',')[1..-1]
  names.each(&:strip!).reject! do |name|
    name.size <= 2 || name == '...' || name =~ /\A[<>]/ || name.start_with?('operator')
  end
  names.map { |name| [name] }
end

#get_nameObject


11
12
13
14
15
16
17
18
19
20
# File 'lib/docs/filters/cpp/entries.rb', line 11

def get_name
  name = at_css('#firstHeading').content.strip
  name.remove! 'C++ concepts: '
  name.remove! 'C++ keywords: '
  name.remove! 'C++ '
  name.remove! %r{\s\(.+\)}
  name.sub! %r{\AStandard library header <(.+)>\z}, '\1'
  name = name.split(',').first
  REPLACE_NAMES[name] || name
end

#get_typeObject


22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/docs/filters/cpp/entries.rb', line 22

def get_type
  if at_css('#firstHeading').content.include?('C++ keyword')
    'Keywords'
  elsif subpath.start_with?('experimental')
    'Experimental libraries'
  elsif type = at_css('.t-navbar > div:nth-child(4) > :first-child').try(:content)
    type.strip!
    type.remove! ' library'
    type.remove! ' utilities'
    type.remove! 'C++ '
    type.capitalize!
    type
  end
end

#include_default_entry?Boolean

Returns:

  • (Boolean)

46
47
48
49
# File 'lib/docs/filters/cpp/entries.rb', line 46

def include_default_entry?
  return @include_default_entry if defined? @include_default_entry
  @include_default_entry = at_css('.t-navbar > div:nth-child(4) > a') && at_css('#firstHeading').content !~ /\A\s*operator./
end