From 16955d127755d3ddcce25e23ffbd3c0f1e138464 Mon Sep 17 00:00:00 2001 From: mkwardakov Date: Wed, 17 Feb 2016 23:09:36 +0300 Subject: [PATCH] Add Ansible documentation --- lib/docs/filters/ansible/clean_html.rb | 19 ++++++++ lib/docs/filters/ansible/entries.rb | 63 +++++++++++++++++++++++++ lib/docs/scrapers/ansible.rb | 30 ++++++++++++ public/icons/docs/ansible/16.png | Bin 0 -> 471 bytes public/icons/docs/ansible/16@2x.png | Bin 0 -> 946 bytes 5 files changed, 112 insertions(+) create mode 100644 lib/docs/filters/ansible/clean_html.rb create mode 100644 lib/docs/filters/ansible/entries.rb create mode 100644 lib/docs/scrapers/ansible.rb create mode 100644 public/icons/docs/ansible/16.png create mode 100644 public/icons/docs/ansible/16@2x.png diff --git a/lib/docs/filters/ansible/clean_html.rb b/lib/docs/filters/ansible/clean_html.rb new file mode 100644 index 00000000..089d4d10 --- /dev/null +++ b/lib/docs/filters/ansible/clean_html.rb @@ -0,0 +1,19 @@ +module Docs + class Ansible + class CleanHtmlFilter < Filter + def call + # Remove 'Permalink to this headline' + css('.headerlink').remove + # Make proper table headers + css('th.head').each do |node| + node.name = 'th' + end + css('table').each do |node| + node.remove_attribute('border') + node.remove_attribute('cellpadding') + end + doc + end + end + end +end diff --git a/lib/docs/filters/ansible/entries.rb b/lib/docs/filters/ansible/entries.rb new file mode 100644 index 00000000..66582f58 --- /dev/null +++ b/lib/docs/filters/ansible/entries.rb @@ -0,0 +1,63 @@ +module Docs + class Ansible + class EntriesFilter < Docs::EntriesFilter + TYPES = { + 'intro' => 'Basic Topics', + 'modules' => 'Basic Topics', + 'common' => 'Basic Topics', + 'playbooks' => 'Playbooks', + 'become' => 'Playbooks', + 'test' => 'Playbooks', + 'YAMLSyntax' => 'Playbooks', + 'list' => 'Module Categories', + 'guide' => 'Advanced Topics', + 'developing' => 'Advanced Topics', + 'galaxy' => 'Advanced Topics' + } + + HIDE_SLUGS = [ + 'playbooks', + 'playbooks_special_topics', + 'list_of_all_modules.html', + 'modules_by_category', + 'modules' + ] + + def get_name + node = at_css('h1') + name = node.content.strip + case + when name.empty? + super + when slug.eql?('modules_intro') + name = 'Modules' + when name.eql?('Introduction') + name = '#Introduction' + when name.eql?('Getting Started') + name = '#Getting Started' + when name.eql?('Introduction To Ad-Hoc Commands') + name = 'Ad-Hoc Commands' + end + name + end + + def get_type + if HIDE_SLUGS.include?(slug) + type = nil + else + akey = slug.split('_').first + type = TYPES.key?(akey) ? TYPES[akey] : 'Modules Reference' + end + type + end + + def additional_entries + [] + end + + def include_default_entry? + true + end + end + end +end diff --git a/lib/docs/scrapers/ansible.rb b/lib/docs/scrapers/ansible.rb new file mode 100644 index 00000000..72c184c4 --- /dev/null +++ b/lib/docs/scrapers/ansible.rb @@ -0,0 +1,30 @@ +module Docs + class Ansible < UrlScraper + self.name = 'Ansible' + self.type = 'ansible' + self.release = '2.1.0' + self.base_url = 'http://docs.ansible.com/ansible/' + self.root_path = 'intro.html' + self.links = { + home: 'http://docs.ansible.com', + code: 'https://github.com/ansible/ansible' + } + + html_filters.push 'ansible/clean_html', 'ansible/entries' + + options[:title] = 'Ansible' + options[:container] = '#page-content' + options[:skip] = [ + 'glossary.html', + 'faq.html', + 'community.html', + 'tower.html', + 'quickstart.html' + ] + + options[:attribution] = <<-HTML + © Michael DeHaan
+ Licensed under the GNU General Public License v.3. + HTML + end +end diff --git a/public/icons/docs/ansible/16.png b/public/icons/docs/ansible/16.png new file mode 100644 index 0000000000000000000000000000000000000000..fc4fd3fb6dfb0562348aed95e2cd43fcb4246be4 GIT binary patch literal 471 zcmV;|0Vw{7P)SUoa@U#cH_} zqf0j^o9w15va8D=Qc_mrM_oPN!F^xvF?qJ<^W%Bn_xZdGBEm0ap_}9J*lM*zQRI2v z@Aqf3SxJ&Emy5}P|D`Aj$8p~yL!pqWszhcOWLahyhKM+hbGzN7bvPXJ`TT9zZnrGU z(o_5WzAVc$5{t!dx0_*TG#WJLa=A8}&3e7|dc8D07z_}RLB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