Procházet zdrojové kódy

Add HAProxy documentation

Phil Scherer před 5 roky
rodič
revize
450adb5e72

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

@@ -351,6 +351,11 @@ credits = [
     '2011-2017 Yehuda Katz',
     'MIT',
     'https://raw.githubusercontent.com/wycats/handlebars.js/master/LICENSE'
+  ], [
+    'HAProxy',
+    '2020 Willy Tarreau, HAProxy contributors',
+    'GPLv2',
+    'https://raw.githubusercontent.com/haproxy/haproxy/master/LICENSE'
   ], [
     'Haskell',
     'The University of Glasgow',

+ 1 - 0
assets/stylesheets/application.css.scss

@@ -62,6 +62,7 @@
         'pages/go',
         'pages/graphite',
         'pages/gnuplot',
+        'pages/haproxy',
         'pages/haskell',
         'pages/jekyll',
         'pages/jquery',

+ 28 - 0
assets/stylesheets/pages/_haproxy.scss

@@ -0,0 +1,28 @@
+._haproxy {
+  padding-left: 1rem;
+
+  h1, h2, h3 { margin-left: -1rem; }
+  h2 { @extend %block-heading; }
+  h3 { @extend %block-label; }
+  h4 { @extend %block-label; }
+
+  ._mobile & {
+    padding-left: 0;
+
+    h1, h2, h3 { margin-left: 0; }
+  }
+
+  .pagination-centered { text-align: center; }
+
+  .pull-right { float: right !important; }
+
+  .keyword { @extend %block-label, %label-blue;}
+
+  pre.text {
+    background: var(--contentBackground);
+    border-width: 0px;
+  }
+
+  td.alert-success { background: var(--noteGreenBackground); }
+  td.alert-error { background: var(--noteRedBackground); }
+}

+ 46 - 0
lib/docs/filters/haproxy/clean_html.rb

@@ -0,0 +1,46 @@
+module Docs
+  class Haproxy
+    class CleanHtmlFilter < Filter
+      def call
+        css('br', 'hr' '.text-right', '.dropdown-menu', 'table.summary').remove
+        css('.alert-success > img[src$="check.png"]').remove
+        css('.alert-error > img[src$="cross.png"]').remove
+
+        at_css('.page-header').remove
+
+        css('h1, h2, h3, h4').each do |node|
+          node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
+          node.remove_attribute('data-target')
+        end
+
+        header = at_css('.text-center')
+        header.name = 'h1'
+        header.content = header.at_css('h3').content
+
+        css('small > a').each do |node|
+          node.parent.content = node.content
+        end
+
+        css('.page-header').each do |node|
+          node.replace node.children
+        end
+
+        css('.keyword').each do |node|
+          node['id'] = node.at_css('.anchor')['name']
+        end
+
+        css('.dropdown').each do |node|
+          node.content = node.content
+        end
+
+        css('table').each do |node|
+          node.keys.each do |attribute|
+            node.remove_attribute(attribute)
+          end
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 49 - 0
lib/docs/filters/haproxy/entries.rb

@@ -0,0 +1,49 @@
+module Docs
+  class Haproxy
+    class EntriesFilter < Docs::EntriesFilter
+      TYPE_BY_SLUG = {
+        'intro' => 'Starter Guide',
+        'configuration' => 'Configuration Manual',
+        'management' => 'Management Guide',
+      }
+
+      REPLACE_TYPE = {
+        'Management: 2) Typed output format' => 'Statistics and monitoring'
+      }
+
+      def get_name
+        'HAProxy'
+      end
+
+      def get_type
+        'HAProxy'
+      end
+
+      def additional_entries
+        entries = []
+
+        css('h2[id]', 'h3[id]').each do |node|
+          entries << [node.content.strip, node['id'], TYPE_BY_SLUG[slug]]
+        end
+
+        type = 'x'
+        @doc.children.each do |node|
+          if node.name == 'h2' && node['id'] =~ /chapter/
+            type = slug.titleize + ': ' + node.content.split('.').last.strip
+          elsif node.name == 'div'
+            node.css('.keyword').each do |n|
+              name = n.at_css('b').content
+              id = n.at_css('a.anchor')['name']
+              entries << [name, URI.escape(id), REPLACE_TYPE[type] || type]
+            end
+          end
+        end
+        entries
+      end
+
+      def include_default_entry?
+        false
+      end
+    end
+  end
+end

+ 62 - 0
lib/docs/scrapers/haproxy.rb

@@ -0,0 +1,62 @@
+module Docs
+  class Haproxy < UrlScraper
+    self.type = 'haproxy'
+    self.root_path = 'intro.html'
+    self.initial_paths = %w(intro.html configuration.html management.html)
+    self.links = {
+      home: 'https://www.haproxy.org/',
+      code: 'https://github.com/haproxy/haproxy/'
+    }
+
+    html_filters.push 'haproxy/clean_html', 'haproxy/entries'
+
+    options[:container] = '#page-wrapper > .row > .col-lg-12'
+
+    options[:follow_links] = false
+
+    options[:attribution] = <<-HTML
+      &copy; 2020 Willy Tarreau, HAProxy contributors<br>
+      Licensed under the GNU General Public License version 2.
+    HTML
+
+    version '2.3' do
+      self.release = '2.3.0'
+      self.base_url = "http://cbonte.github.io/haproxy-dconv/#{self.version}/"
+    end
+
+    version '2.2' do
+      self.release = '2.2.5'
+      self.base_url = "http://cbonte.github.io/haproxy-dconv/#{self.version}/"
+    end
+
+    version '2.1' do
+      self.release = '2.1.10'
+      self.base_url = "http://cbonte.github.io/haproxy-dconv/#{self.version}/"
+    end
+
+    version '2.0' do
+      self.release = '2.0.19'
+      self.base_url = "http://cbonte.github.io/haproxy-dconv/#{self.version}/"
+    end
+
+    version '1.9' do
+      self.release = '1.9.16'
+      self.base_url = "http://cbonte.github.io/haproxy-dconv/#{self.version}/"
+    end
+
+    version '1.8' do
+      self.release = '1.8.27'
+      self.base_url = "http://cbonte.github.io/haproxy-dconv/#{self.version}/"
+    end
+
+    version '1.7' do
+      self.release = '1.7.12'
+      self.base_url = "http://cbonte.github.io/haproxy-dconv/#{self.version}/"
+    end
+
+    def get_latest_version(opts)
+      doc = fetch_doc('http://www.haproxy.org', opts)
+      doc.at_css('table[cols=6]').css('tr')[1].at_css('td').content
+    end
+  end
+end

binární
public/icons/docs/haproxy/16.png


binární
public/icons/docs/haproxy/16@2x.png


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

@@ -0,0 +1 @@
+http://www.haproxy.org/img/HAProxyCommunityEdition_60px.png