From 6de8a1f1316557f2669566990c2c2ee1254c08cd Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Fri, 12 Aug 2016 14:16:57 +0100 Subject: [PATCH] docs: namespace generator for funcs in doctree --- src/scripts/elua/apps/docgen/doctree.lua | 19 +++++++++++++++++++ src/scripts/elua/apps/docgen/mappings.lua | 10 ---------- src/scripts/elua/apps/gendoc.lua | 6 +++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua index c8df5cae83..2b143f726d 100644 --- a/src/scripts/elua/apps/docgen/doctree.lua +++ b/src/scripts/elua/apps/docgen/doctree.lua @@ -260,6 +260,15 @@ M.Function = Node:clone { return self.func:type_get() end, + type_str_get = function(self) + return ({ + [eolian.function_type.PROPERTY] = "property", + [eolian.function_type.PROP_GET] = "property", + [eolian.function_type.PROP_SET] = "property", + [eolian.function_type.METHOD] = "method" + })[self:type_get()] + end, + scope_get = function(self, ft) return self.func:scope_get(ft) end, @@ -330,6 +339,16 @@ M.Function = Node:clone { is_const = function(self) return self.func:is_const() + end, + + nspaces_get = function(self, cl, root) + local tbl = cl:nspaces_get() + tbl[#tbl + 1] = self:type_str_get() + tbl[#tbl + 1] = self:name_get():lower() + if root then + tbl[#tbl + 1] = true + end + return tbl end } diff --git a/src/scripts/elua/apps/docgen/mappings.lua b/src/scripts/elua/apps/docgen/mappings.lua index 66648ae61d..dc97de5268 100644 --- a/src/scripts/elua/apps/docgen/mappings.lua +++ b/src/scripts/elua/apps/docgen/mappings.lua @@ -58,16 +58,6 @@ M.gen_nsp_eo = function(eobj, subn, root) return tbl end -M.gen_nsp_func = function(fn, cl, root) - local tbl = cl:nspaces_get() - tbl[#tbl + 1] = M.funct_to_str[fn:type_get()] - tbl[#tbl + 1] = fn:name_get():lower() - if root then - tbl[#tbl + 1] = true - end - return tbl -end - M.gen_nsp_ref = function(str, root) local decl = eolian.declaration_get_by_name(str) if decl then diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua index f2c70356cf..9668a13d77 100644 --- a/src/scripts/elua/apps/gendoc.lua +++ b/src/scripts/elua/apps/gendoc.lua @@ -367,7 +367,7 @@ local build_functable = function(f, title, ctitle, cl, tp) local nt = {} for i, v in ipairs(t) do local lbuf = writer.Buffer() - lbuf:write_link(eomap.gen_nsp_func(v, cl, true), v:name_get()) + lbuf:write_link(v:nspaces_get(cl, true), v:name_get()) local pt = propt_to_type[v:type_get()] if pt then lbuf:write_raw(" ") @@ -937,7 +937,7 @@ local build_vallist = function(f, pg, ps, title) end build_method = function(fn, cl) - local f = writer.Writer(eomap.gen_nsp_func(fn, cl)) + local f = writer.Writer(fn:nspaces_get(cl)) stats.check_method(fn, cl) f:write_h(cl:full_name_get() .. "." .. fn:name_get(), 2) @@ -965,7 +965,7 @@ build_method = function(fn, cl) end build_property = function(fn, cl) - local f = writer.Writer(eomap.gen_nsp_func(fn, cl)) + local f = writer.Writer(fn:nspaces_get(cl)) local fts = eolian.function_type local ft = fn:type_get()