Class: Docs::React::EntriesFilter

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

Constant Summary collapse

API_SLUGS =
%w(
top-level-api
component-api
component-specs

Constants inherited from Filter

Filter::SCHEME_RGX

Instance Method Summary collapse

Methods inherited from 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


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/docs/filters/react/entries.rb', line 20

def additional_entries
  return [] unless API_SLUGS.include?(slug)

  css('.inner-content h3, .inner-content h4').map do |node|
    name = node.content
    name.remove! %r{[#\(\)]}
    name.remove! %r{\w+\:}
    id = node.at_css('.anchor')['name']
    type = slug.include?('component') ? 'Component' : 'React'
    [name, id, type]
  end
end

#get_nameObject


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

def get_name
  at_css('h1').child.content
end

#get_typeObject


14
15
16
17
18
# File 'lib/docs/filters/react/entries.rb', line 14

def get_type
  link = at_css('.nav-docs-section .active')
  section = link.ancestors('.nav-docs-section').first
  section.at_css('h3').content
end