docs: reverse inheritance hierarchy api in doctree
authorDaniel Kolesa <d.kolesa@osg.samsung.com>
Thu, 9 Feb 2017 14:25:10 +0000 (15:25 +0100)
committerDaniel Kolesa <d.kolesa@osg.samsung.com>
Thu, 9 Feb 2017 14:58:52 +0000 (15:58 +0100)
src/scripts/elua/apps/docgen/doctree.lua

index f8876ce..c388c0f 100644 (file)
@@ -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