summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-02-09 15:58:22 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-02-09 15:58:52 +0100
commit5e50c9d52bf65427b48ab572930a1583d3482ddf (patch)
tree3239ee75c85b5183e72814a7d0d8c609aae235df /src
parent051f277be25017142a74befce5ed586df3967598 (diff)
docs: list all existing implements of a method/property
Diffstat (limited to 'src')
-rw-r--r--src/scripts/elua/apps/docgen/doctree.lua13
-rw-r--r--src/scripts/elua/apps/gendoc.lua50
2 files changed, 62 insertions, 1 deletions
diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua
index c388c0f3c9..042dcabe67 100644
--- a/src/scripts/elua/apps/docgen/doctree.lua
+++ b/src/scripts/elua/apps/docgen/doctree.lua
@@ -210,7 +210,7 @@ M.Class = Node:clone {
210 end, 210 end,
211 211
212 children_get = function(self) 212 children_get = function(self)
213 return revh[self:full_name_get()] 213 return revh[self:full_name_get()] or {}
214 end, 214 end,
215 215
216 functions_get = function(self, ft) 216 functions_get = function(self, ft)
@@ -249,6 +249,10 @@ M.Class = Node:clone {
249 return M.Node.nspaces_get(self, self:type_str_get(), root) 249 return M.Node.nspaces_get(self, self:type_str_get(), root)
250 end, 250 end,
251 251
252 is_same = function(self, other)
253 return self.class == other.class
254 end,
255
252 -- static getters 256 -- static getters
253 257
254 by_name_get = function(name) 258 by_name_get = function(name)
@@ -394,6 +398,10 @@ M.Function = Node:clone {
394 tbl[#tbl + 1] = not not root 398 tbl[#tbl + 1] = not not root
395 end 399 end
396 return tbl 400 return tbl
401 end,
402
403 is_same = function(self, other)
404 return self.func == other.func
397 end 405 end
398} 406}
399 407
@@ -1413,6 +1421,9 @@ M.parse = function()
1413 for cl in eolian.all_classes_get() do 1421 for cl in eolian.all_classes_get() do
1414 local cln = cl:full_name_get() 1422 local cln = cl:full_name_get()
1415 for icl in cl:inherits_get() do 1423 for icl in cl:inherits_get() do
1424 if icl == "Elm.List" then
1425 print("GOT ELM LIST")
1426 end
1416 local t = revh[icl] 1427 local t = revh[icl]
1417 if not t then 1428 if not t then
1418 t = {} 1429 t = {}
diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua
index a184853aa0..524583acaf 100644
--- a/src/scripts/elua/apps/gendoc.lua
+++ b/src/scripts/elua/apps/gendoc.lua
@@ -1015,6 +1015,50 @@ local write_inherited_from = function(f, impl, cl, over)
1015 f:write_i(buf:finish()) 1015 f:write_i(buf:finish())
1016end 1016end
1017 1017
1018local impls_of = {}
1019
1020local get_all_impls_of
1021get_all_impls_of = function(tbl, cl, fn)
1022 for i, imp in ipairs(cl:implements_get()) do
1023 local ofn = imp:function_get()
1024 if ofn:is_same(fn) then
1025 tbl[#tbl + 1] = cl
1026 break
1027 end
1028 end
1029 for i, cln in ipairs(cl:children_get()) do
1030 local icl = dtree.Class.by_name_get(cln)
1031 get_all_impls_of(tbl, icl, fn)
1032 end
1033end
1034
1035local write_ilist = function(f, impl, cl)
1036 local fn = impl:function_get()
1037 local fnn = fn:name_get()
1038 local ocl = fn:implement_get():class_get()
1039 local onm = ocl:full_name_get() .. "." .. fnn
1040 local imps = impls_of[onm]
1041 if not imps then
1042 imps = {}
1043 impls_of[onm] = imps
1044 get_all_impls_of(imps, ocl, fn)
1045 end
1046
1047 f:write_h("Implemented by", 2)
1048 local t = {}
1049 for i, icl in ipairs(imps) do
1050 local buf = writer.Buffer()
1051 local cfn = icl:full_name_get() .. "." .. fnn
1052 if icl:is_same(cl) then
1053 buf:write_b(cfn)
1054 else
1055 buf:write_link(fn:nspaces_get(icl, true), cfn)
1056 end
1057 t[#t + 1] = buf:finish()
1058 end
1059 f:write_list(t)
1060end
1061
1018build_method = function(impl, cl) 1062build_method = function(impl, cl)
1019 local over = impl:is_overridden(cl) 1063 local over = impl:is_overridden(cl)
1020 local fn = impl:function_get() 1064 local fn = impl:function_get()
@@ -1051,6 +1095,9 @@ build_method = function(impl, cl)
1051 f:write_editable(mns, "description") 1095 f:write_editable(mns, "description")
1052 f:write_nl() 1096 f:write_nl()
1053 1097
1098 write_ilist(f, impl, cl)
1099 f:write_nl()
1100
1054 f:finish() 1101 f:finish()
1055end 1102end
1056 1103
@@ -1156,6 +1203,9 @@ build_property = function(impl, cl)
1156 f:write_nl() 1203 f:write_nl()
1157 end 1204 end
1158 1205
1206 write_ilist(f, impl, cl)
1207 f:write_nl()
1208
1159 f:finish() 1209 f:finish()
1160end 1210end
1161 1211