[devdocsgjs/main: 1325/1867] Add HAProxy documentation




commit 450adb5e722670503feeebac8432a611d5c46282
Author: Phil Scherer <pnscher evoforge org>
Date:   Wed Dec 2 23:35:01 2020 +0000

    Add HAProxy documentation

 .../javascripts/templates/pages/about_tmpl.coffee  |   5 ++
 assets/stylesheets/application.css.scss            |   1 +
 assets/stylesheets/pages/_haproxy.scss             |  28 ++++++++++
 lib/docs/filters/haproxy/clean_html.rb             |  46 +++++++++++++++
 lib/docs/filters/haproxy/entries.rb                |  49 ++++++++++++++++
 lib/docs/scrapers/haproxy.rb                       |  62 +++++++++++++++++++++
 public/icons/docs/haproxy/16.png                   | Bin 0 -> 24501 bytes
 public/icons/docs/haproxy/16 2x png                | Bin 0 -> 24066 bytes
 public/icons/docs/haproxy/SOURCE                   |   1 +
 9 files changed, 192 insertions(+)
---
diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee 
b/assets/javascripts/templates/pages/about_tmpl.coffee
index 913e00dd..0cebc816 100644
--- a/assets/javascripts/templates/pages/about_tmpl.coffee
+++ b/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',
diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss
index 3f283cc0..175d96a6 100644
--- a/assets/stylesheets/application.css.scss
+++ b/assets/stylesheets/application.css.scss
@@ -62,6 +62,7 @@
         'pages/go',
         'pages/graphite',
         'pages/gnuplot',
+        'pages/haproxy',
         'pages/haskell',
         'pages/jekyll',
         'pages/jquery',
diff --git a/assets/stylesheets/pages/_haproxy.scss b/assets/stylesheets/pages/_haproxy.scss
new file mode 100755
index 00000000..24c49b47
--- /dev/null
+++ b/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); }
+}
diff --git a/lib/docs/filters/haproxy/clean_html.rb b/lib/docs/filters/haproxy/clean_html.rb
new file mode 100755
index 00000000..5df47477
--- /dev/null
+++ b/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
diff --git a/lib/docs/filters/haproxy/entries.rb b/lib/docs/filters/haproxy/entries.rb
new file mode 100755
index 00000000..167340fd
--- /dev/null
+++ b/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
diff --git a/lib/docs/scrapers/haproxy.rb b/lib/docs/scrapers/haproxy.rb
new file mode 100644
index 00000000..0a3aa752
--- /dev/null
+++ b/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
diff --git a/public/icons/docs/haproxy/16.png b/public/icons/docs/haproxy/16.png
new file mode 100644
index 00000000..6f3577c7
Binary files /dev/null and b/public/icons/docs/haproxy/16.png differ
diff --git a/public/icons/docs/haproxy/16 2x png b/public/icons/docs/haproxy/16 2x png
new file mode 100644
index 00000000..ef48b36f
Binary files /dev/null and b/public/icons/docs/haproxy/16 2x png differ
diff --git a/public/icons/docs/haproxy/SOURCE b/public/icons/docs/haproxy/SOURCE
new file mode 100644
index 00000000..a5558641
--- /dev/null
+++ b/public/icons/docs/haproxy/SOURCE
@@ -0,0 +1 @@
+http://www.haproxy.org/img/HAProxyCommunityEdition_60px.png


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]