Class: Docs::Ember::EntriesFilter

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

Constant Summary

Constants inherited from Filter

Filter::SCHEME_RGX

Instance Method Summary collapse

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


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/docs/filters/ember/entries.rb', line 29

def additional_entries
  css('.item-entry').map do |node|
    heading = node.at_css('h2')
    name = heading.content.strip

    if self.name == 'Handlebars Helpers'
      name << ' (handlebars helper)'
      next [name, heading['id']]
    end

    # Give their own type to "Ember.platform", "Ember.run", etc.
    if self.type != 'Data' && name.include?('.')
      type = "#{self.name}.#{name.split('.').first}"
    end

    # "." = class method, "#" = instance method
    separator = '#'
    separator = '.' if self.name == 'Ember' || self.name.split('.').last =~ /\A[a-z]/ || node.at_css('.static')
    name.prepend self.name + separator

    name << '()'     if node['class'].include? 'method'
    name << ' event' if node['class'].include? 'event'

    [name, heading['id'], type]
  end
end

#get_nameObject


8
9
10
11
12
13
# File 'lib/docs/filters/ember/entries.rb', line 8

def get_name
  name = at_css('.api-header').content.split.first
  # Remove "Ember." prefix if the next character is uppercase
  name.sub! %r{\AEmber\.([A-Z])(?!EATURES)}, '\1'
  name == 'Handlebars.helpers' ? 'Handlebars Helpers' : name
end

#get_typeObject


15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/docs/filters/ember/entries.rb', line 15

def get_type
  if at_css('.api-header').content.include?('Module')
    'Modules'
  elsif name.start_with? 'DS'
    'Data'
  elsif name.start_with? 'RSVP'
    'RSVP'
  elsif name.start_with? 'Test'
    'Test'
  else
    name
  end
end

#include_default_entry?Boolean

Returns:

  • (Boolean)

4
5
6
# File 'lib/docs/filters/ember/entries.rb', line 4

def include_default_entry?
  name != 'Handlebars Helpers'
end