瀏覽代碼

Added Lua Nginx Module documentation

Only the Nginx directives and the Lua API are relevant for devdocs, all
the rest has been filtered out for now.
Julien Desgats 10 年之前
父節點
當前提交
acac755eb1

+ 8 - 0
assets/javascripts/views/pages/lua_nginx_module.coffee

@@ -0,0 +1,8 @@
+#= require views/pages/base
+
+# this may be used for all GitHub pages
+
+class app.views.LuaNginxModulePage extends app.views.BasePage
+  prepare: ->
+    @highlightCode @findAll('div.highlight-source-lua pre'), 'lua'
+    return

+ 22 - 0
lib/docs/filters/lua_nginx_module/clean_html.rb

@@ -0,0 +1,22 @@
+module Docs
+  class LuaNginxModule
+    class CleanHtmlFilter < Filter
+      def call
+        type = nil
+        doc.children.each do |node|
+          if node.name == 'h1'
+            section = node.content.strip
+            type = section.in?(['Directives', 'Nginx API for Lua']) ? section : nil
+          end
+
+          if type == nil || (node.name == 'ul' && node.previous_element.name == 'h1') || node.content.strip == 'Back to TOC'
+            node.remove()
+          elsif node.name == 'h2'
+            node["id"] = /^user-content-(.+)/.match(node.css('a.anchor').first["id"])[1]
+          end
+        end
+        doc
+      end
+    end
+  end
+end

+ 17 - 0
lib/docs/filters/lua_nginx_module/entries.rb

@@ -0,0 +1,17 @@
+module Docs
+  class LuaNginxModule
+    class EntriesFilter < Docs::EntriesFilter
+      def additional_entries
+        type = nil 
+
+        doc.children.each_with_object [] do |node, entries|
+          if node.name == 'h1'
+            type = node.content.strip
+          elsif node.name == 'h2'
+            entries << [ node.content, node["id"], type ]
+          end
+        end
+      end
+    end
+  end
+end

+ 19 - 0
lib/docs/scrapers/lua_nginx_module.rb

@@ -0,0 +1,19 @@
+module Docs
+  class LuaNginxModule < UrlScraper
+    self.type = 'LuaNginxModule'
+    self.root_path = 'README.markdown'
+
+    html_filters.push 'lua_nginx_module/clean_html', 'lua_nginx_module/entries'
+
+    options[:container] = '#readme > article'
+
+    options[:attribution] = <<-HTML
+      Copyright (C) 2009-2015, by Xiaozhe Wang (chaoslawful) <a href="mailto:chaoslawful@gmail.com">chaoslawful@gmail.com</a>.<br>
+      Copyright (C) 2009-2015, by Yichun "agentzh" Zhang (章亦春) <a href="mailto:agentzh@gmail.com">agentzh@gmail.com</a>, CloudFlare Inc.<br>
+      Licensed under the BSD License.
+    HTML
+
+    self.release = '0.10.0'
+    self.base_url = 'https://github.com/openresty/lua-nginx-module/tree/v0.10.0/'
+  end
+end