From e0c0b12a941e4d62e2e9960711ac61ef6be80398 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Fri, 12 Aug 2016 14:09:50 +0100 Subject: [PATCH] docs: initial Function in doctree --- src/scripts/elua/apps/docgen/doctree.lua | 95 +++++++++++++++++++++++- src/scripts/elua/apps/docgen/stats.lua | 8 +- src/scripts/elua/apps/gendoc.lua | 32 ++++---- 3 files changed, 113 insertions(+), 22 deletions(-) diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua index f3428eb299..25ffae19d3 100644 --- a/src/scripts/elua/apps/docgen/doctree.lua +++ b/src/scripts/elua/apps/docgen/doctree.lua @@ -183,11 +183,15 @@ M.Class = Node:clone { end, functions_get = function(self, ft) - return self.class:functions_get(ft):to_array() + local ret = {} + for fn in self.class:functions_get(ft) do + ret[#ret + 1] = M.Function(fn) + end + return ret end, function_get_by_name = function(self, fn, ft) - return self.class:function_get_by_name(fn, ft) + return M.Function(self.class:function_get_by_name(fn, ft)) end, events_get = function(self) @@ -238,6 +242,93 @@ M.Class = Node:clone { end } +M.Function = Node:clone { + __ctor = function(self, fn) + self.func = fn + assert(self.func) + end, + + name_get = function(self) + return self.func:name_get() + end, + + type_get = function(self) + return self.func:type_get() + end, + + scope_get = function(self, ft) + return self.func:scope_get(ft) + end, + + full_c_name_get = function(self, ft, legacy) + return self.func:full_c_name_get(ft, legacy) + end, + + legacy_get = function(self, ft) + return self.func:legacy_get(ft) + end, + + doc_get = function(self, ft) + return M.Doc(self.func:documentation_get(ft)) + end, + + is_virtual_pure = function(self, ft) + return self.func:is_virtual_pure(ft) + end, + + is_auto = function(self, ft) + return self.func:is_auto(ft) + end, + + is_empty = function(self, ft) + return self.func:is_empty(ft) + end, + + is_legacy_only = function(self, ft) + return self.func:is_legacy_only(ft) + end, + + is_class = function(self) + return self.func:is_class() + end, + + is_c_only = function(self) + return self.func:is_c_only() + end, + + property_keys_get = function(self, ft) + return self.func:property_keys_get(ft) + end, + + property_values_get = function(self, ft) + return self.func:property_values_get(ft) + end, + + parameters_get = function(self) + return self.func:parameters_get() + end, + + return_type_get = function(self, ft) + return self.func:return_type_get(ft) + end, + + return_default_value_get = function(self, ft) + return self.func:return_default_value_get(ft) + end, + + return_doc_get = function(self, ft) + return M.Doc(self.func:return_documentation_get(ft)) + end, + + return_is_warn_unused = function(self, ft) + return self.func:return_is_warn_unused(ft) + end, + + is_const = function(self) + return self.func:is_const() + end +} + M.Event = Node:clone { __ctor = function(self, ev) self.event = ev diff --git a/src/scripts/elua/apps/docgen/stats.lua b/src/scripts/elua/apps/docgen/stats.lua index f9d6fb655b..a0359d2c88 100644 --- a/src/scripts/elua/apps/docgen/stats.lua +++ b/src/scripts/elua/apps/docgen/stats.lua @@ -142,14 +142,14 @@ M.check_method = function(fn, cl) local fts = eolian.function_type local fulln = cl:full_name_get() .. "." .. fn:name_get() if fn:return_type_get(fts.METHOD) then - if not fn:return_documentation_get(fts.METHOD) then + if not fn:return_doc_get(fts.METHOD):exists() then print_missing(fulln, "method return") stat_incr("mret", true) else stat_incr("mret", false) end end - if not fn:documentation_get(fts.METHOD) then + if not fn:doc_get(fts.METHOD):exists() then print_missing(fulln, "method") stat_incr("method", true) else @@ -176,7 +176,7 @@ M.check_property = function(fn, cl, ft) local fulln = cl:full_name_get() .. "." .. fn:name_get() if fn:return_type_get(ft) then - if not fn:return_documentation_get(ft) then + if not fn:return_doc_get(ft):exists() then print_missing(fulln, pfx .. "etter return") stat_incr(pfx .. "ret", true) else @@ -184,7 +184,7 @@ M.check_property = function(fn, cl, ft) end end - if not fn:documentation_get(fts.PROPERTY) and not fn:documentation_get(ft) then + if not fn:doc_get(fts.PROPERTY):exists() and not fn:doc_get(ft):exists() then print_missing(fulln, pfx .. "etter") stat_incr(pfx .. "etter", true) else diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua index 9833bcd4ac..f4d88c25a1 100644 --- a/src/scripts/elua/apps/gendoc.lua +++ b/src/scripts/elua/apps/gendoc.lua @@ -22,18 +22,18 @@ local get_fallback_fdoc = function(f, ftype) end end if ftype then - return dtree.Doc(f:documentation_get(ftype)) + return f:doc_get(ftype) end return nil end local get_brief_fdoc = function(f, ftype) - return dtree.Doc(f:documentation_get(eolian.function_type.METHOD)) + return f:doc_get(eolian.function_type.METHOD) :brief_get(get_fallback_fdoc(f, ftype)) end local get_full_fdoc = function(f, ftype) - return dtree.Doc(f:documentation_get(eolian.function_type.METHOD)) + return f:doc_get(eolian.function_type.METHOD) :full_get(get_fallback_fdoc(f, ftype)) end @@ -431,7 +431,7 @@ local build_ref = function() end local write_full_fdoc = function(f, fn, ftype) - f:write_raw(dtree.Doc(fn:documentation_get(eolian.function_type.METHOD)) + f:write_raw(fn:doc_get(eolian.function_type.METHOD) :full_get(get_fallback_fdoc(fn, ftype), true)) end @@ -959,7 +959,7 @@ build_method = function(fn, cl) end f:write_h("Description", 3) - f:write_raw(dtree.Doc(fn:documentation_get(eolian.function_type.METHOD)):full_get(nil, true)) + f:write_raw(fn:doc_get(eolian.function_type.METHOD):full_get(nil, true)) f:write_nl() f:finish() @@ -976,9 +976,9 @@ build_property = function(fn, cl) if isget then stats.check_property(fn, cl, fts.PROP_GET) end if isset then stats.check_property(fn, cl, fts.PROP_SET) end - local doc = fn:documentation_get(fts.PROPERTY) - local gdoc = fn:documentation_get(fts.PROP_GET) - local sdoc = fn:documentation_get(fts.PROP_SET) + local doc = fn:doc_get(fts.PROPERTY) + local gdoc = fn:doc_get(fts.PROP_GET) + local sdoc = fn:doc_get(fts.PROP_SET) f:write_h(cl:full_name_get() .. "." .. fn:name_get(), 2) @@ -1007,33 +1007,33 @@ build_property = function(fn, cl) if isget and isset then f:write_h("Description", 3) - if doc or (not gdoc and not sdoc) then - f:write_raw(dtree.Doc(doc):full_get(nil, true)) + if doc:exists() or (not gdoc:exists() and not sdoc:exists()) then + f:write_raw(doc:full_get(nil, true)) end - if (isget and gdoc) or (isset and sdoc) then + if (isget and gdoc:exists()) or (isset and sdoc:exists()) then f:write_nl(2) end end - if isget and gdoc then + if isget and gdoc:exists() then if isset then f:write_h("Getter", 4) else f:write_h("Description", 3) end - f:write_raw(dtree.Doc(gdoc):full_get(nil, true)) - if isset and sdoc then + f:write_raw(gdoc:full_get(nil, true)) + if isset and sdoc:exists() then f:write_nl(2) end end - if isset and sdoc then + if isset and sdoc:exists() then if isget then f:write_h("Setter", 4) else f:write_h("Description", 3) end - f:write_raw(dtree.Doc(sdoc):full_get(nil, true)) + f:write_raw(sdoc:full_get(nil, true)) end f:write_nl()