summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-08-09 16:36:16 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-08-09 16:36:16 +0000
commitd8ed736906b838eedaf946d640beee549a10df8b (patch)
tree84ed94332f922530ef152c145ce2eeadbb595ce0
parente4f0c9755137f8c3a09b1c64d30ade3b39c1f95c (diff)
* luci/contrib: fixed anchors in virtual module documentation, only render parameters to html which have a corresponding @param tag
-rw-r--r--contrib/luadoc/lua/luadoc/doclet/html.lua53
-rw-r--r--contrib/luadoc/lua/luadoc/taglet/standard.lua2
2 files changed, 33 insertions, 22 deletions
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:
-- <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>
--
@@ -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)