* luci/contrib: fixed anchors in virtual module documentation, only render parameters...
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 9 Aug 2008 16:36:16 +0000 (16:36 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 9 Aug 2008 16:36:16 +0000 (16:36 +0000)
contrib/luadoc/lua/luadoc/doclet/html.lua
contrib/luadoc/lua/luadoc/taglet/standard.lua

index 9a38c87..630c6c4 100644 (file)
@@ -1,11 +1,11 @@
 -------------------------------------------------------------------------------
 -- Doclet that generates HTML output. This doclet generates a set of html files
 -------------------------------------------------------------------------------
 -- 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:
 -- <ul>
 -- <li>index.lp: index of modules and files;</li>
 -- <li>file.lp: documentation for a lua file;</li>
 -- <li>module.lp: documentation for a lua module;</li>
 -- <ul>
 -- <li>index.lp: index of modules and files;</li>
 -- <li>file.lp: documentation for a lua file;</li>
 -- <li>module.lp: documentation for a lua module;</li>
--- <li>function.lp: documentation for a lua function. This is a 
+-- <li>function.lp: documentation for a lua function. This is a
 -- sub-template used by the others.</li>
 -- </ul>
 --
 -- sub-template used by the others.</li>
 -- </ul>
 --
@@ -20,6 +20,7 @@ local luadoc = require"luadoc"
 local package = package
 local string = require"string"
 local table = require"table"
 local package = package
 local string = require"string"
 local table = require"table"
+local luciutil = require "luci.util"
 
 module "luadoc.doclet.html"
 
 
 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
 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))
        -- 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
        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
        env.type = type
        env.luadoc = luadoc
        env.options = options
-       
+
        return lp.include(templatepath, env)
 end
 
        return lp.include(templatepath, env)
 end
 
@@ -93,12 +94,12 @@ function module_link (modulename, doc, from)
        assert(modulename)
        assert(doc)
        from = from or ""
        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
        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
        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 ""
 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")
        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"
        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
        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
                        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)
 
        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
 --             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
        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
 
 --     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)
 function symbol_link (symbol, doc, module_doc, file_doc, from)
        assert(symbol)
        assert(doc)
-       
-       local href = 
+
+       local href =
 --             file_link(symbol, from) or
 --             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")
                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
        if not href then
                logger:error(string.format("unresolved reference to symbol `%s'", symbol))
        end
-       
+
        return href or ""
 end
 
        return href or ""
 end
 
@@ -226,7 +237,7 @@ function start (doc)
                include("index.lp", { doc = doc })
                f:close()
        end
                include("index.lp", { doc = doc })
                f:close()
        end
-       
+
        -- Process modules
        if not options.nomodules then
                for _, modulename in ipairs(doc.modules) do
        -- 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))
                        -- 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)
                        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))
                        -- 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)
                        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
                        f:close()
                end
        end
-       
+
        -- copy extra files
        local f = posix.open(options.output_dir.."luadoc.css", "w")
        io.output(f)
        -- copy extra files
        local f = posix.open(options.output_dir.."luadoc.css", "w")
        io.output(f)
index 4d28655..c02bc98 100644 (file)
@@ -55,7 +55,7 @@ local function check_function (line)
                        return {
                                name = id,
                                private = (l == "local"),
                        return {
                                name = id,
                                private = (l == "local"),
-                               param = util.split("%s*,%s*", param),
+                               param = { } --util.split("%s*,%s*", param),
                        }
                end
        end)
                        }
                end
        end)