Class: Docs::Coffeescript::EntriesFilter

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

Constant Summary collapse

ENTRIES =
[
  ['coffee command',              'usage',                    'Miscellaneous'],
  ['Literate mode',               'literate',                 'Miscellaneous'],
  ['Functions',                   'literals',                 'Language'],
  ['->',                          'literals',                 'Statements'],
  ['Objects and arrays',          'objects_and_arrays',       'Language'],
  ['Lexical scoping',             'lexical-scope',            'Language'],
  ['if...then...else',            'conditionals',             'Statements'],
  ['unless',                      'conditionals',             'Statements'],
  ['... splats',                  'splats',                   'Language'],
  ['for...in',                    'loops',                    'Statements'],
  ['for...in...by',               'loops',                    'Statements'],
  ['for...in...when',             'loops',                    'Statements'],
  ['for...of',                    'loops',                    'Statements'],
  ['while',                       'loops',                    'Statements'],
  ['until',                       'loops',                    'Statements'],
  ['loop',                        'loops',                    'Statements'],
  ['do',                          'loops',                    'Statements'],
  ['Array slicing and splicing',  'slices',                   'Language'],
  ['Ranges',                      'slices',                   'Language'],
  ['Expressions',                 'expressions',              'Language'],
  ['?',                           'the-existential-operator', 'Operators'],
  ['?=',                          'the-existential-operator', 'Operators'],
  ['?.',                          'the-existential-operator', 'Operators'],
  ['class',                       'classes',                  'Statements'],
  ['extends',                     'classes',                  'Operators'],
  ['super',                       'classes',                  'Statements'],
  ['::',                          'classes',                  'Operators'],
  ['Destructuring assignment',    'destructuring',            'Language'],
  ['=>',                          'fat-arrow',                'Statements'],
  ['Embedded JavaScript',         'embedded',                 'Language'],
  ['switch...when...else',        'switch',                   'Statements'],
  ['try...catch...finally',       'try',                      'Statements'],
  ['Chained comparisons',         'comparisons',              'Language'],
  ['#{} interpolation',           'strings',                  'Language'],
  ['Block strings',               'strings',                  'Language'],
  ['"""',                         'strings',                  'Language'],
  ['Block comments',              'strings',                  'Language'],
  ['###',                         'strings',                  'Language'],
  ['Block regexes',               'regexes',                  'Language'],
  ['cake command',                'cake',                     'Miscellaneous'],
  ['Cakefile',                    'cake',                     'Miscellaneous'],
  ['Source maps',                 'source-maps',              'Miscellaneous']
]

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?, #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


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/docs/filters/coffeescript/entries.rb', line 49

def additional_entries
  entries = ENTRIES.dup

  # Operators
  css('.definitions td:first-child > code').each do |node|
    node.content.split(', ').each do |name|
      next if %w(true false yes no on off this).include?(name)
      name.sub! %r{\Aa (.+) b\z}, '\1'
      id = name_to_id(name)
      node['id'] = id
      entries << [name, id, 'Operators']
    end
  end

  entries
end

#name_to_id(name) ⇒ Object


66
67
68
69
70
71
72
73
# File 'lib/docs/filters/coffeescript/entries.rb', line 66

def name_to_id(name)
  case name
    when '**' then 'pow'
    when '//' then 'floor'
    when '%%' then 'mod'
    else name.parameterize
  end
end