From 051f277be25017142a74befce5ed586df3967598 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Thu, 9 Feb 2017 15:25:10 +0100 Subject: [PATCH] docs: reverse inheritance hierarchy api in doctree --- src/scripts/elua/apps/docgen/doctree.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua index f8876ce..c388c0f 100644 --- a/src/scripts/elua/apps/docgen/doctree.lua +++ b/src/scripts/elua/apps/docgen/doctree.lua @@ -144,6 +144,8 @@ M.Doc = Node:clone { end } +local revh = {} + M.Class = Node:clone { -- class types UNKNOWN = eolian.class_type.UNKNOWN, @@ -207,6 +209,10 @@ M.Class = Node:clone { return self.class:inherits_get():to_array() end, + children_get = function(self) + return revh[self:full_name_get()] + end, + functions_get = function(self, ft) local ret = {} for fn in self.class:functions_get(ft) do @@ -1403,6 +1409,18 @@ M.parse = function() if not eolian.all_eo_files_parse() then error("failed parsing eo files") end + -- build reverse inheritance hierarchy + for cl in eolian.all_classes_get() do + local cln = cl:full_name_get() + for icl in cl:inherits_get() do + local t = revh[icl] + if not t then + t = {} + revh[icl] = t + end + t[#t + 1] = cln + end + end end return M -- 2.7.4