From d8a0daaf5832de85b90ed1133c3c43bcac00045d Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Tue, 21 Feb 2017 16:48:16 +0100 Subject: [PATCH] docgen: inherit overridden method/property brief descriptions on class pages --- src/scripts/elua/apps/gendoc.lua | 61 ++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua index 9100f73..7f6a397 100644 --- a/src/scripts/elua/apps/gendoc.lua +++ b/src/scripts/elua/apps/gendoc.lua @@ -665,6 +665,37 @@ local build_igraph = function(cl) return graph end +local find_parent_impl +find_parent_impl = function(fulln, cl) + for i, inh in ipairs(cl:inherits_get()) do + local pcl = dtree.Class.by_name_get(inh) + for j, impl in ipairs(pcl:implements_get()) do + if impl:full_name_get() == fulln then + return impl, pcl + end + end + local pimpl, pcl = find_parent_impl(fulln, pcl) + if pimpl then + return pimpl, pcl + end + end + return nil, cl +end + +local find_parent_briefdoc +find_parent_briefdoc = function(fulln, cl) + local pimpl, pcl = find_parent_impl(fulln, cl) + if not pimpl then + return dtree.Doc():brief_get() + end + local pdoc = pimpl:doc_get(dtree.Function.METHOD, true) + local pdocf = pimpl:fallback_doc_get(true) + if not pdoc:exists() and (not pdocf or not pdocf:exists()) then + return find_parent_briefdoc(fulln, pcl) + end + return pdoc:brief_get(pdocf) +end + local build_functable = function(f, title, ctitle, cl, tbl, over) if #tbl == 0 then return @@ -703,10 +734,15 @@ local build_functable = function(f, title, ctitle, cl, tbl, over) lbuf:write_i(llbuf:finish()) end - nt[#nt + 1] = { - lbuf:finish(), - impl:doc_get(func.METHOD, true):brief_get(impl:fallback_doc_get(true)) - } + local doc = impl:doc_get(func.METHOD, true) + local docf = impl:fallback_doc_get(true) + local bdoc + if over and (not doc:exists() and (not docf or not docf:exists())) then + bdoc = find_parent_briefdoc(impl:full_name_get(), cl) + else + bdoc = doc:brief_get(docf) + end + nt[#nt + 1] = { lbuf:finish(), bdoc } if impl:is_prop_get() or impl:is_prop_set() then build_property(impl, cl) else @@ -984,23 +1020,6 @@ local build_vallist = function(f, pg, ps, title) end end -local find_parent_impl -find_parent_impl = function(fulln, cl) - for i, inh in ipairs(cl:inherits_get()) do - local pcl = dtree.Class.by_name_get(inh) - for j, impl in ipairs(pcl:implements_get()) do - if impl:full_name_get() == fulln then - return impl, pcl - end - end - local pimpl, pcl = find_parent_impl(fulln, pcl) - if pimpl then - return pimpl, pcl - end - end - return nil, cl -end - local find_parent_doc find_parent_doc = function(fulln, cl, ftype) local pimpl, pcl = find_parent_impl(fulln, cl) -- 2.7.4