Class: Docs::Angular::EntriesFilter

Inherits:
EntriesFilter show all
Defined in:
lib/docs/filters/angular/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, #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


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/docs/filters/angular/entries.rb', line 25

def additional_entries
  entries = []

  css('ul.defs').each do |list|
    list.css('> li[id]').each do |node|
      next unless heading = node.at_css('h3')
      name = heading.content.strip
      name.sub! %r{\(.*\);}, '()'
      name.prepend "#{self.name.split.first}."
      entries << [name, node['id']]
    end
  end

  entries
end

#get_nameObject


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

def get_name
  name = slug.split('/').last
  name.remove! %r{\Ang\.}
  name << " (#{subtype})" if subtype == 'directive' || subtype == 'filter'
  name.prepend("#{type}.") unless type.starts_with?('ng ') || name == type
  name
end

#get_typeObject


12
13
14
15
16
# File 'lib/docs/filters/angular/entries.rb', line 12

def get_type
  type = slug.split('/').first
  type << " #{subtype}s" if type == 'ng' && subtype
  type
end

#subtypeObject


18
19
20
21
22
23
# File 'lib/docs/filters/angular/entries.rb', line 18

def subtype
  return @subtype if defined? @subtype
  node = at_css '.api-profile-header-structure'
  data = node.content.match %r{(\w+?) in module} if node
  @subtype = data && data[1]
end