Class: Docs::Django::EntriesFilter

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


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

def additional_entries
  entries = []

  css('dl.function', 'dl.class', 'dl.method', 'dl.attribute').each do |node|
    next unless id = node.at_css('dt')['id']
    next unless name = id.dup.sub!('django.', '')

    path = name.split('.')
    type = "django.#{path.first}"
    type << ".#{path.second}" if %w(contrib db).include?(path.first)

    name.remove! 'contrib.'
    name << '()' if node['class'].include?('method') || node['class'].include?('function')

    entries << [name, id, type]
  end

  entries
end

#get_nameObject


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

def get_name
  at_css('h1').content.remove("\u{00b6}")
end

#get_typeObject


8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/docs/filters/django/entries.rb', line 8

def get_type
  case subpath
  when /\Atopics/
    'Guides'
  when /\Aintro/
    'Guides: Intro'
  when /\Ahowto/
    'Guides: How-tos'
  when /\Aref/
    'API'
  end
end

#include_default_entry?Boolean

Returns:

  • (Boolean)

41
42
43
# File 'lib/docs/filters/django/entries.rb', line 41

def include_default_entry?
  at_css('#sidebar a[href="index"]')
end