Class: Docs::Express::EntriesFilter

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

Constant Summary collapse

TYPES_BY_PATH =
{
  'starter' => 'Getting started',
  'guide' => 'Guide',
  'advanced' => 'Guide'
}

Constants inherited from Filter

Filter::SCHEME_RGX

Instance Method Summary collapse

Methods inherited from Docs::EntriesFilter

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


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

def additional_entries
  return [] unless root_page?
  type = 'Application'

  doc.children.each_with_object [] do |node, entries|
    if node.name == 'h2'
      type = node.content
      entries << [type, node['id'], 'Application'] if type == 'Middleware'
      next
    elsif node.name == 'h3'
      next if type == 'Middleware'
      name = node.content.strip
      name.sub! %r{\(.+\)}, '()'

      entries << [name, node['id'], type]
    end
  end
end

#get_nameObject


10
11
12
# File 'lib/docs/filters/express/entries.rb', line 10

def get_name
  at_css('h1').content
end

#get_typeObject


14
15
16
# File 'lib/docs/filters/express/entries.rb', line 14

def get_type
  TYPES_BY_PATH[slug.split('/').first]
end