From: Jo-Philipp Wich Date: Sat, 9 Aug 2008 16:36:16 +0000 (+0000) Subject: * luci/contrib: fixed anchors in virtual module documentation, only render parameters... X-Git-Tag: 0.8.0~483 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d8ed736906b838eedaf946d640beee549a10df8b;p=oweals%2Fluci.git * luci/contrib: fixed anchors in virtual module documentation, only render parameters to html which have a corresponding @param tag --- diff --git a/contrib/luadoc/lua/luadoc/doclet/html.lua b/contrib/luadoc/lua/luadoc/doclet/html.lua index 9a38c87b5..630c6c475 100644 --- a/contrib/luadoc/lua/luadoc/doclet/html.lua +++ b/contrib/luadoc/lua/luadoc/doclet/html.lua @@ -1,11 +1,11 @@ ------------------------------------------------------------------------------- -- Doclet that generates HTML output. This doclet generates a set of html files --- based on a group of templates. The main templates are: +-- based on a group of templates. The main templates are: -- -- @@ -20,6 +20,7 @@ local luadoc = require"luadoc" local package = package local string = require"string" local table = require"table" +local luciutil = require "luci.util" module "luadoc.doclet.html" @@ -48,12 +49,12 @@ end function include (template, env) -- template_dir is relative to package.path local templatepath = options.template_dir .. template - + -- search using package.path (modified to search .lp instead of .lua local search_path = string.gsub(package.path, "%.lua", "") local templatepath = search(search_path, templatepath) assert(templatepath, string.format("template `%s' not found", template)) - + env = env or {} env.table = table env.io = io @@ -64,7 +65,7 @@ function include (template, env) env.type = type env.luadoc = luadoc env.options = options - + return lp.include(templatepath, env) end @@ -93,12 +94,12 @@ function module_link (modulename, doc, from) assert(modulename) assert(doc) from = from or "" - + if doc.modules[modulename] == nil then -- logger:error(string.format("unresolved reference to module `%s'", modulename)) return end - + local href = "modules/" .. modulename .. ".html" string.gsub(from, "/", function () href = "../" .. href end) return href @@ -116,7 +117,7 @@ end function file_link (to, from) assert(to) from = from or "" - + local href = to href = string.gsub(href, "lua$", "html") href = string.gsub(href, "luadoc$", "html") @@ -136,7 +137,9 @@ function link_to (fname, doc, module_doc, file_doc, from, kind) assert(doc) from = from or "" kind = kind or "functions" - + + --luciutil.dumptable( module_doc ) + if file_doc then for _, func_name in pairs(file_doc[kind]) do if func_name == fname then @@ -144,7 +147,15 @@ function link_to (fname, doc, module_doc, file_doc, from, kind) end end end - + + if module_doc and module_doc[kind] then + for func_name, tbl in pairs(module_doc[kind]) do + if func_name == fname then + return "#" .. fname + end + end + end + local _, _, modulename, fname = string.find(fname, "^(.-)[%.%:]?([^%.%:]*)$") assert(fname) @@ -158,13 +169,13 @@ function link_to (fname, doc, module_doc, file_doc, from, kind) -- logger:error(string.format("unresolved reference to function `%s': module `%s' not found", fname, modulename)) return end - + for _, func_name in pairs(module_doc[kind]) do if func_name == fname then return module_link(modulename, doc, from) .. "#" .. fname end end - + -- logger:error(string.format("unresolved reference to function `%s' of module `%s'", fname, modulename)) end @@ -174,17 +185,17 @@ end function symbol_link (symbol, doc, module_doc, file_doc, from) assert(symbol) assert(doc) - - local href = + + local href = -- file_link(symbol, from) or - module_link(symbol, doc, from) or + module_link(symbol, doc, from) or link_to(symbol, doc, module_doc, file_doc, from, "functions") or link_to(symbol, doc, module_doc, file_doc, from, "tables") - + if not href then logger:error(string.format("unresolved reference to symbol `%s'", symbol)) end - + return href or "" end @@ -226,7 +237,7 @@ function start (doc) include("index.lp", { doc = doc }) f:close() end - + -- Process modules if not options.nomodules then for _, modulename in ipairs(doc.modules) do @@ -234,7 +245,7 @@ function start (doc) -- assembly the filename local filename = out_module(modulename) logger:info(string.format("generating file `%s'", filename)) - + local f = posix.open(filename, "w") assert(f, string.format("could not open `%s' for writing", filename)) io.output(f) @@ -250,7 +261,7 @@ function start (doc) -- assembly the filename local filename = out_file(file_doc.name) logger:info(string.format("generating file `%s'", filename)) - + local f = posix.open(filename, "w") assert(f, string.format("could not open `%s' for writing", filename)) io.output(f) @@ -258,7 +269,7 @@ function start (doc) f:close() end end - + -- copy extra files local f = posix.open(options.output_dir.."luadoc.css", "w") io.output(f) diff --git a/contrib/luadoc/lua/luadoc/taglet/standard.lua b/contrib/luadoc/lua/luadoc/taglet/standard.lua index 4d286557e..c02bc98be 100644 --- a/contrib/luadoc/lua/luadoc/taglet/standard.lua +++ b/contrib/luadoc/lua/luadoc/taglet/standard.lua @@ -55,7 +55,7 @@ local function check_function (line) return { name = id, private = (l == "local"), - param = util.split("%s*,%s*", param), + param = { } --util.split("%s*,%s*", param), } end end)