mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
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.
This commit is contained in:
parent
a5ffc1fb3b
commit
acac755eb1
4 changed files with 66 additions and 0 deletions
8
assets/javascripts/views/pages/lua_nginx_module.coffee
Normal file
8
assets/javascripts/views/pages/lua_nginx_module.coffee
Normal file
|
@ -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
lib/docs/filters/lua_nginx_module/clean_html.rb
Normal file
22
lib/docs/filters/lua_nginx_module/clean_html.rb
Normal file
|
@ -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
lib/docs/filters/lua_nginx_module/entries.rb
Normal file
17
lib/docs/filters/lua_nginx_module/entries.rb
Normal file
|
@ -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
lib/docs/scrapers/lua_nginx_module.rb
Normal file
19
lib/docs/scrapers/lua_nginx_module.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue