Class: Docs::Yii1::CleanHtmlFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/docs/filters/yii1/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
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/docs/filters/yii1/clean_html.rb', line 4

def call
  at_css('h1').content = 'Yii PHP Framework' if root_page?

  css('.api-suggest', '.google-ad', '.g-plusone', '#nav', '#comments').remove

  css('.summary > p > .toggle').each do |node|
    node.parent.remove
  end

  css('.signature', '.signature2').each do |node|
    node.name = 'pre'
    node.inner_html = node.inner_html.strip
  end

  css('div.detailHeader').each do |node|
    node.name = 'h3'
  end

  css('.sourceCode > .code > code').each do |node|
    parent = node.parent
    parent.name = 'pre'
    node.remove
    parent.inner_html = node.first_element_child.inner_html.strip
  end

  doc
end