Преглед на файлове

Add Ansible documentation

mkwardakov преди 9 години
родител
ревизия
16955d1277

+ 19 - 0
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

+ 63 - 0
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

+ 30 - 0
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
+      &copy; Michael DeHaan<br>
+      Licensed under the GNU General Public License v.3.
+    HTML
+  end
+end

BIN
public/icons/docs/ansible/16.png


BIN
public/icons/docs/ansible/16@2x.png