Class: Docs::Sass::CleanHtmlFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/docs/filters/sass/clean_html.rb

Constant Summary

Constants inherited from Filter

Filter::SCHEME_RGX

Instance Method Summary collapse

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

#callObject


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

def call
  css('tt').each do |node|
    node.name = 'code'
  end

  root_page? ? root : other

  doc
end

#otherObject


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
46
47
48
49
# File 'lib/docs/filters/sass/clean_html.rb', line 18

def other
  at_css('h2').remove

  css('.showSource', '.source_code').remove

  css('div.docstring', 'div.discussion').each do |node|
    node.before(node.children).remove
  end

  # Remove "See Also"
  css('.see').each do |node|
    node.previous_element.remove
    node.remove
  end

  # Remove "- ([...])" before method names
  css('.signature', 'span.overload', 'span.signature').each do |node|
    next if node.at_css('.overload')
    node.child.remove while node.child.name != 'strong'
  end

  # Clean up .inline divs
  css('div.inline').each do |node|
    node.content = node.content
    node.name = 'span'
  end

  # Remove links to type classes (e.g. Number)
  css('.type > code').each do |node|
    node.before(node.content.remove('Sass::Script::Value::').remove('Sass::Script::')).remove
  end
end

#rootObject


14
15
16
# File 'lib/docs/filters/sass/clean_html.rb', line 14

def root
  at_css('.maruku_toc').remove
end