Class: Docs::Laravel::EntriesFilter

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


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

def additional_entries
  return [] if root_page? || !api_page?
  base_name = self.name.remove(/\(.+\)/).strip

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

    name = node['id'].remove('method_')
    name.prepend "#{base_name}::"
    name << '()'

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

#api_page?Boolean


42
43
44
# File 'lib/docs/filters/laravel/entries.rb', line 42

def api_page?
  subpath.start_with?('/api')
end

#get_nameObject


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

def get_name
  if api_page?
    name = at_css('h1').content.strip.remove('Illuminate\\')
    name << " (#{type})" unless name.start_with?(self.type)
    name
  else
    at_css('h1').content
  end
end

#get_typeObject


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

def get_type
  return 'Guides' unless api_page?
  type = slug.remove('api/5.0/').remove('Illuminate/').remove(/\/\w+?\z/).gsub('/', '\\')

  if type.end_with?('Console')
    type.split('\\').first
  elsif type.start_with?('Contracts')
    'Contracts'
  else
    type
  end
end

#include_default_entry?Boolean


46
47
48
# File 'lib/docs/filters/laravel/entries.rb', line 46

def include_default_entry?
  subpath != '/api/5.0/classes.html'
end