summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-02-23 18:17:22 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-02-23 18:17:22 +0100
commit4405d1fc7e4989faac8d90650ee9d79d87cf5ead (patch)
treeae07be1642ebcaddb3f374db4908a5e1aba30327
parentdcac79d5b6e3d282319bf441871d0453163e53c2 (diff)
docgen: initial support for inherited events listing
-rw-r--r--src/scripts/elua/apps/gendoc.lua56
1 files changed, 36 insertions, 20 deletions
diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua
index 7b0b3f4172..508b3257e8 100644
--- a/src/scripts/elua/apps/gendoc.lua
+++ b/src/scripts/elua/apps/gendoc.lua
@@ -795,7 +795,7 @@ end
795-- finds all stuff that is callable on a class, respecting 795-- finds all stuff that is callable on a class, respecting
796-- overrides and not duplicating, does a depth-first search 796-- overrides and not duplicating, does a depth-first search
797local find_callables 797local find_callables
798find_callables = function(cl, omeths, written) 798find_callables = function(cl, omeths, events, written)
799 for i, inh in ipairs(cl:inherits_get()) do 799 for i, inh in ipairs(cl:inherits_get()) do
800 local pcl = dtree.Class.by_name_get(inh) 800 local pcl = dtree.Class.by_name_get(inh)
801 for j, impl in ipairs(pcl:implements_get()) do 801 for j, impl in ipairs(pcl:implements_get()) do
@@ -806,8 +806,38 @@ find_callables = function(cl, omeths, written)
806 written[fid] = true 806 written[fid] = true
807 end 807 end
808 end 808 end
809 find_callables(pcl, omeths, written) 809 for i, ev in ipairs(pcl:events_get()) do
810 events[#events + 1] = { pcl, ev }
811 end
812 find_callables(pcl, omeths, events, written)
813 end
814end
815
816local build_evtable = function(f, title, cl, tbl)
817 if #tbl == 0 then
818 return
819 end
820 f:write_h(title, 2)
821 local nt = {}
822 local oclass = not cl
823 for i, ev in ipairs(tbl) do
824 local lbuf = writer.Buffer()
825 local evn
826 if oclass then
827 cl = ev[1]
828 ev = ev[2]
829 evn = cl:full_name_get() .. "." .. ev:name_get()
830 else
831 evn = ev:name_get()
832 end
833 lbuf:write_link(ev:nspaces_get(cl, true), evn)
834 nt[#nt + 1] = {
835 lbuf:finish(), ev:doc_get():brief_get()
836 }
837 build_event(ev, cl)
810 end 838 end
839 table.sort(nt, function(v1, v2) return v1[1] < v2[1] end)
840 f:write_table({ "Event name", "Brief description" }, nt)
811end 841end
812 842
813local build_class = function(cl) 843local build_class = function(cl)
@@ -838,6 +868,7 @@ local build_class = function(cl)
838 f:write_nl() 868 f:write_nl()
839 869
840 local written = {} 870 local written = {}
871 local ievs = {}
841 local meths, methos, omeths = {}, {}, {} 872 local meths, methos, omeths = {}, {}, {}
842 for i, impl in ipairs(cl:implements_get()) do 873 for i, impl in ipairs(cl:implements_get()) do
843 local func = impl:function_get() 874 local func = impl:function_get()
@@ -848,29 +879,14 @@ local build_class = function(cl)
848 meths[#meths + 1] = impl 879 meths[#meths + 1] = impl
849 end 880 end
850 end 881 end
851 find_callables(cl, omeths, written) 882 find_callables(cl, omeths, ievs, written)
852 883
853 build_functable(f, "Members", cl, meths) 884 build_functable(f, "Members", cl, meths)
854 build_functable(f, "Overrides", cl, methos) 885 build_functable(f, "Overrides", cl, methos)
855 build_functable(f, "Others", nil, omeths) 886 build_functable(f, "Others", nil, omeths)
856 887
857 f:write_h("Events", 2) 888 build_evtable(f, "Events", cl, cl:events_get())
858 local evs = cl:events_get() 889 build_evtable(f, "Inherited Events", nil, ievs)
859 if #evs == 0 then
860 f:write_raw("This class does not define any events.\n")
861 else
862 local nt = {}
863 for i, ev in ipairs(evs) do
864 local lbuf = writer.Buffer()
865 lbuf:write_link(ev:nspaces_get(cl, true), ev:name_get())
866 nt[#nt + 1] = {
867 lbuf:finish(), ev:doc_get():brief_get()
868 }
869 build_event(ev, cl)
870 end
871 table.sort(nt, function(v1, v2) return v1[1] < v2[1] end)
872 f:write_table({ "Event name", "Brief description" }, nt)
873 end
874 890
875 f:finish() 891 f:finish()
876end 892end