Class: Docs::Less::EntriesFilter

Inherits:
EntriesFilter show all
Defined in:
lib/docs/filters/less/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, #get_name, #get_type, #include_default_entry?, #path

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


12
13
14
# File 'lib/docs/filters/less/entries.rb', line 12

def additional_entries
  root_page? ? language_entries : function_entries
end

#function_entriesObject


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/docs/filters/less/entries.rb', line 47

def function_entries
  entries = []
  type = nil

  css('*').each do |node|
    if node.name == 'h2'
      type = node.content
      type.sub! %r{(.+) Functions}, 'Functions: \1'
    elsif node.name == 'h4'
      entries << [node.content, node['id'], type]
    end
  end

  entries
end

#language_entriesObject


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/docs/filters/less/entries.rb', line 16

def language_entries
  entries = []

  css('h2').each do |node|
    name = node.content.strip
    name = 'Rulesets' if name == 'Passing Rulesets to Mixins'
    entries << [name, node['id']] unless name == 'Overview'
  end

  css('h3[id^="import-options-"]').each do |node|
    entries << ["@import #{node.content}", node['id']]
  end

  entries.concat [
    ['@var',              'variables-feature'],
    ['@{} interpolation', 'variables-feature-variable-interpolation'],
    ['url()',             'variables-feature-urls'],
    ['@property',         'variables-feature-properties'],
    ['@@var',             'variables-feature-variable-names'],
    [':extend()',         'extend-feature'],
    [':extend(all)',      'extend-feature-extend-all-'],
    ['@arguments',        'mixins-parametric-feature-the-arguments-variable'],
    ['@rest',             'mixins-parametric-feature-advanced-arguments-and-the-rest-variable'],
    ['@import',           'import-directives-feature'],
    ['when',              'mixin-guards-feature'],
    ['.loop()',           'loops-feature'],
    ['+:',                'merge-feature'] ]

  entries
end

#nameObject


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

def name
  at_css('h2').content
end

#typeObject


8
9
10
# File 'lib/docs/filters/less/entries.rb', line 8

def type
  root_page? ? 'Language' : nil
end