1
0
Эх сурвалжийг харах

Add Salt Stack documentation (#876)

Add Salt Stack documentation

Co-authored-by: Boris Bera <bbera@pmctire.com>
Co-authored-by: Jasper van Merle <jaspervmerle@gmail.com>
Jasper van Merle 6 жил өмнө
parent
commit
f580152bf7

+ 6 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -638,6 +638,12 @@ credits = [
     'MIT',
     'https://raw.githubusercontent.com/rust-lang/rust/master/LICENSE-MIT'
   ], [
+    'Salt Stack',
+    '2019 SaltStack',
+    'Apache',
+    'https://raw.githubusercontent.com/saltstack/salt/develop/LICENSE'
+  ],
+  [
     'Sass',
     '2006-2016 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein',
     'MIT',

+ 27 - 0
lib/docs/filters/salt_stack/clean_html.rb

@@ -0,0 +1,27 @@
+module Docs
+  class SaltStack
+    class CleanHtmlFilter < Filter
+      def call
+        if root_page?
+          doc.inner_html = '<h1>SaltStack</h1>'
+          return doc
+        end
+
+        css('.headerlink').remove
+
+        css('div[class^="highlight-"]').each do |node|
+          node.name = 'pre'
+          node['data-language'] = node['class'].scan(/highlight-([a-z]+)/i)[0][0]
+          node.content = node.content.strip
+        end
+
+        css('.function > dt').each do |node|
+          node.name = 'h3'
+          node.content = node.content
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 38 - 0
lib/docs/filters/salt_stack/entries.rb

@@ -0,0 +1,38 @@
+module Docs
+  class SaltStack
+    class EntriesFilter < Docs::EntriesFilter
+      SALT_REF_RGX = /salt\.([^\.]+)\.([^\s]+)/
+
+      def get_name
+        header = at_css('h1').content
+
+        ref_match = SALT_REF_RGX.match(header)
+        if ref_match
+          ns, mod = ref_match.captures
+          "#{ns}.#{mod}"
+        else
+          header
+        end
+      end
+
+      def get_type
+        slug.split('/', 3)[1]
+      end
+
+      def include_default_entry?
+        slug.split('/').last.start_with? 'salt'
+      end
+
+      def additional_entries
+        entries = []
+
+        css('.function > h3').each do |node|
+          name = node.content.remove('salt.').split('(')[0] + '()'
+          entries << [name, node['id']]
+        end
+
+        entries
+      end
+    end
+  end
+end

+ 36 - 0
lib/docs/scrapers/salt_stack.rb

@@ -0,0 +1,36 @@
+module Docs
+  # The official documentation website is heavily rate-limited
+  #
+  # The documentation can be generated like this (replace 2019.2 with the correct tag):
+  # $ git clone https://github.com/saltstack/salt.git --branch 2019.2 --depth 1
+  # $ cd salt/doc
+  # $ pip install sphinx
+  # $ make html
+  #
+  # The generated html can be found in salt/doc/_build/html
+  class SaltStack < FileScraper
+    self.type = 'simple'
+    self.slug = 'saltstack'
+    self.release = '2019.2.0'
+    self.base_url = 'https://docs.saltstack.com/en/latest/'
+    self.root_path = 'ref/index.html'
+    self.links = {
+      home: 'https://www.saltstack.com/',
+      code: 'https://github.com/saltstack/salt'
+    }
+
+    html_filters.push 'salt_stack/clean_html', 'salt_stack/entries'
+
+    options[:only_patterns] = [/all\//]
+    options[:container] = '.body-content > .section'
+
+    options[:attribution] = <<-HTML
+      &copy; 2019 SaltStack.<br>
+      Licensed under the Apache License, Version 2.0.
+    HTML
+
+    def get_latest_version(opts)
+      get_latest_github_release('saltstack', 'salt', opts)
+    end
+  end
+end

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


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


+ 1 - 0
public/icons/docs/saltstack/SOURCE

@@ -0,0 +1 @@
+https://github.com/saltstack/salt/blob/develop/doc/_static/salt-logo.svg