History

Add Ansible documentation

mkwardakov committed 10 years ago

Commit 16955d11 parent caa25925 files · +110 −-2Browse files

Unified · Split

5 files
  1. lib/docs/filters/ansible/clean_html.rb +19 −0
  2. lib/docs/filters/ansible/entries.rb +63 −0
  3. lib/docs/scrapers/ansible.rb +30 −0
  4. public/icons/docs/ansible/16.png +0 −0
  5. public/icons/docs/ansible/16@2x.png +0 −0
lib/docs/filters/ansible/clean_html.rb+19−0
@@ -0,0 +1,19 @@
1+module Docs
2+ class Ansible
3+ class CleanHtmlFilter < Filter
4+ def call
5+ # Remove 'Permalink to this headline'
6+ css('.headerlink').remove
7+ # Make proper table headers
8+ css('th.head').each do |node|
9+ node.name = 'th'
10+ end
11+ css('table').each do |node|
12+ node.remove_attribute('border')
13+ node.remove_attribute('cellpadding')
14+ end
15+ doc
16+ end
17+ end
18+ end
19+end
lib/docs/filters/ansible/entries.rb+63−0
@@ -0,0 +1,63 @@
1+module Docs
2+ class Ansible
3+ class EntriesFilter < Docs::EntriesFilter
4+ TYPES = {
5+ 'intro' => 'Basic Topics',
6+ 'modules' => 'Basic Topics',
7+ 'common' => 'Basic Topics',
8+ 'playbooks' => 'Playbooks',
9+ 'become' => 'Playbooks',
10+ 'test' => 'Playbooks',
11+ 'YAMLSyntax' => 'Playbooks',
12+ 'list' => 'Module Categories',
13+ 'guide' => 'Advanced Topics',
14+ 'developing' => 'Advanced Topics',
15+ 'galaxy' => 'Advanced Topics'
16+ }
17+
18+ HIDE_SLUGS = [
19+ 'playbooks',
20+ 'playbooks_special_topics',
21+ 'list_of_all_modules.html',
22+ 'modules_by_category',
23+ 'modules'
24+ ]
25+
26+ def get_name
27+ node = at_css('h1')
28+ name = node.content.strip
29+ case
30+ when name.empty?
31+ super
32+ when slug.eql?('modules_intro')
33+ name = 'Modules'
34+ when name.eql?('Introduction')
35+ name = '#Introduction'
36+ when name.eql?('Getting Started')
37+ name = '#Getting Started'
38+ when name.eql?('Introduction To Ad-Hoc Commands')
39+ name = 'Ad-Hoc Commands'
40+ end
41+ name
42+ end
43+
44+ def get_type
45+ if HIDE_SLUGS.include?(slug)
46+ type = nil
47+ else
48+ akey = slug.split('_').first
49+ type = TYPES.key?(akey) ? TYPES[akey] : 'Modules Reference'
50+ end
51+ type
52+ end
53+
54+ def additional_entries
55+ []
56+ end
57+
58+ def include_default_entry?
59+ true
60+ end
61+ end
62+ end
63+end
lib/docs/scrapers/ansible.rb+30−0
@@ -0,0 +1,30 @@
1+module Docs
2+ class Ansible < UrlScraper
3+ self.name = 'Ansible'
4+ self.type = 'ansible'
5+ self.release = '2.1.0'
6+ self.base_url = 'http://docs.ansible.com/ansible/'
7+ self.root_path = 'intro.html'
8+ self.links = {
9+ home: 'http://docs.ansible.com',
10+ code: 'https://github.com/ansible/ansible'
11+ }
12+
13+ html_filters.push 'ansible/clean_html', 'ansible/entries'
14+
15+ options[:title] = 'Ansible'
16+ options[:container] = '#page-content'
17+ options[:skip] = [
18+ 'glossary.html',
19+ 'faq.html',
20+ 'community.html',
21+ 'tower.html',
22+ 'quickstart.html'
23+ ]
24+
25+ options[:attribution] = <<-HTML
26+ &copy; Michael DeHaan<br>
27+ Licensed under the GNU General Public License v.3.
28+ HTML
29+ end
30+end
public/icons/docs/ansible/16.png+0−0

Binary file not shown.

public/icons/docs/ansible/16@2x.png+0−0

Binary file not shown.