From fa2d17a3f913c4e362fe8d16c536c0ecf800158b Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 9 Aug 2008 17:41:01 +0000 Subject: * luci/contrib: implemented "@cstyle" tag in luadoc to tell whether a "module" is a class or an object instance; changed templates to use instance:function() notation for instances and function() notation for class members. --- contrib/luadoc/lua/luadoc/doclet/html/function.lp | 6 +++--- contrib/luadoc/lua/luadoc/doclet/html/module.lp | 11 ++++++----- contrib/luadoc/lua/luadoc/taglet/standard/tags.lua | 21 ++++++++++++++------- 3 files changed, 23 insertions(+), 15 deletions(-) (limited to 'contrib/luadoc/lua') diff --git a/contrib/luadoc/lua/luadoc/doclet/html/function.lp b/contrib/luadoc/lua/luadoc/doclet/html/function.lp index aa0e25b14..afc645b07 100644 --- a/contrib/luadoc/lua/luadoc/doclet/html/function.lp +++ b/contrib/luadoc/lua/luadoc/doclet/html/function.lp @@ -8,7 +8,7 @@ else end %> -
<%=func.private and "local " or ""%><%=func.name%> (<%=table.concat(func.param, ", ")%>)
+
<%=func.private and "local " or ""%><%=(oop and func.name:gsub("%.",":") or func.name:gsub(".+%.",""))%> (<%=table.concat(func.param, ", ")%>)
<%=func.description or ""%> @@ -56,9 +56,9 @@ end +
diff --git a/contrib/luadoc/lua/luadoc/doclet/html/module.lp b/contrib/luadoc/lua/luadoc/doclet/html/module.lp index 6dca9a9ad..5c2dfa072 100644 --- a/contrib/luadoc/lua/luadoc/doclet/html/module.lp +++ b/contrib/luadoc/lua/luadoc/doclet/html/module.lp @@ -20,12 +20,13 @@
-

Module <%=module_doc.name%>

+

<%=( oop and "Object Instance" or "Class" )%> <%=module_doc.name%>

<%=module_doc.description%>

<%if module_doc.author then%> @@ -44,13 +45,13 @@

Release: <%=module_doc.release%>

<%end%> -<%if #module_doc.functions > 0 then%> +<%if #module_doc.functions > 0 then %>

Functions

<%for _, func_name in ipairs(module_doc.functions) do local func_data = module_doc.functions[func_name]%> - + <%end%> @@ -79,7 +80,7 @@

Functions

<%for _, func_name in ipairs(module_doc.functions) do%> -<%=luadoc.doclet.html.include("function.lp", { doc=doc, module_doc=module_doc, func=module_doc.functions[func_name] })%> +<%=luadoc.doclet.html.include("function.lp", { doc=doc, module_doc=module_doc, func=module_doc.functions[func_name], oop=oop })%> <%end%>
<%end%> @@ -103,6 +104,6 @@

Valid XHTML 1.0!

- + diff --git a/contrib/luadoc/lua/luadoc/taglet/standard/tags.lua b/contrib/luadoc/lua/luadoc/taglet/standard/tags.lua index 980514c5f..d03df82df 100644 --- a/contrib/luadoc/lua/luadoc/taglet/standard/tags.lua +++ b/contrib/luadoc/lua/luadoc/taglet/standard/tags.lua @@ -23,7 +23,7 @@ local function author (tag, block, text) end ------------------------------------------------------------------------------- --- Set the class of a comment block. Classes can be "module", "function", +-- Set the class of a comment block. Classes can be "module", "function", -- "table". The first two classes are automatic, extracted from the source code local function class (tag, block, text) @@ -32,6 +32,12 @@ end ------------------------------------------------------------------------------- +local function cstyle (tag, block, text) + block[tag] = text +end + +------------------------------------------------------------------------------- + local function copyright (tag, block, text) block[tag] = text end @@ -52,7 +58,7 @@ local function field (tag, block, text) local _, _, name, desc = string.find(text, "^([_%w%.]+)%s+(.*)") assert(name, "field name not defined") - + table.insert(block[tag], name) block[tag][name] = desc end @@ -65,7 +71,7 @@ local function name (tag, block, text) if block[tag] and block[tag] ~= text then luadoc.logger:error(string.format("block name conflict: `%s' -> `%s'", block[tag], text)) end - + block[tag] = text end @@ -120,12 +126,12 @@ end local function see (tag, block, text) -- see is always an array block[tag] = block[tag] or {} - + -- remove trailing "." text = string.gsub(text, "(.*)%.$", "%1") - - local s = util.split("%s*,%s*", text) - + + local s = util.split("%s*,%s*", text) + table.foreachi(s, function (_, v) table.insert(block[tag], v) end) @@ -149,6 +155,7 @@ end local handlers = {} handlers["author"] = author handlers["class"] = class +handlers["cstyle"] = cstyle handlers["copyright"] = copyright handlers["description"] = description handlers["field"] = field -- cgit v1.2.3
<%=func_data.private and "local " or ""%><%=func_name%> (<%=table.concat(module_doc.functions[func_name].param, ", ")%>)<%=func_data.private and "local " or ""%><%=(oop and func_name:gsub("%.",":") or func_name:gsub(".+%.",""))%> (<%=table.concat(module_doc.functions[func_name].param, ", ")%>) <%=module_doc.functions[func_name].summary%>