Class: Docs::Symfony::EntriesFilter

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

Constant Summary collapse

IGNORE_METHODS =
%w(get set)

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


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

def additional_entries
  return [] if initial_page?
  return [] if type == 'Exceptions'
  return [] if self.name.include?('Legacy') || self.name.include?('Loader')

  entries = []
  base_name = self.name.remove(/\(.+\)/).strip

  css('h3[id^="method_"]').each do |node|
    next if node.at_css('.location').content.start_with?('in')

    name = node['id'].remove('method_')
    next if name.start_with?('_') || IGNORE_METHODS.include?(name)

    name.prepend "#{base_name}::"
    name << "() (#{namespace})"

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

  entries.size > 1 ? entries : []
end

#get_nameObject


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

def get_name
  name = at_css('h1').content.strip
  name.remove! 'Symfony\\'
  name << " (#{namespace})" if name.gsub! "#{namespace}\\", ''
  name
end

#get_typeObject


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

def get_type
  return 'Exceptions' if slug =~ /exception/i
  return 'Testing' if slug =~ /test/i
  namespace
end

#include_default_entry?Boolean

Returns:

  • (Boolean)

52
53
54
# File 'lib/docs/filters/symfony/entries.rb', line 52

def include_default_entry?
  !initial_page?
end

#namespaceObject


17
18
19
20
21
22
23
24
25
# File 'lib/docs/filters/symfony/entries.rb', line 17

def namespace
  @namespace ||= begin
    path = slug.remove('Symfony/').remove(/\/\w+?\z/).split('/')
    upto = 1
    upto = 2 if path[1] == 'Form' && path[2] == 'Extension'
    upto = 2 if path[1] == 'HttpFoundation' && path[2] == 'Session'
    path[0..upto].join('\\')
  end
end