summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-01-26 17:40:16 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-01-26 17:52:00 +0100
commitff8688e169ac26dfa77bfe1445a1e3afa4ab0d5a (patch)
treeae90347a2eb20405b1f541b5eaa54035a221505e
parentebab91182cec0c17e41b74c747b828b8e41ebbab (diff)
docgen: autodocument inherited methods/properties
-rw-r--r--src/scripts/elua/apps/gendoc.lua67
1 files changed, 45 insertions, 22 deletions
diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua
index a1e5ac17a2..19ee12298c 100644
--- a/src/scripts/elua/apps/gendoc.lua
+++ b/src/scripts/elua/apps/gendoc.lua
@@ -985,7 +985,20 @@ find_parent_impl = function(fulln, cl)
985 return pimpl, pcl 985 return pimpl, pcl
986 end 986 end
987 end 987 end
988 -- unreachable with a validated database 988 return nil, cl
989end
990
991local find_parent_doc
992find_parent_doc = function(fulln, cl, ftype)
993 local pimpl, pcl = find_parent_impl(fulln, cl)
994 if not pimpl then
995 return dtree.Doc()
996 end
997 local pdoc = pimpl:doc_get(ftype)
998 if not pdoc:exists() then
999 return find_parent_doc(fulln, pcl, ftype)
1000 end
1001 return pdoc
989end 1002end
990 1003
991build_method = function(impl, cl) 1004build_method = function(impl, cl)
@@ -997,30 +1010,28 @@ build_method = function(impl, cl)
997 1010
998 local doc = impl:doc_get(fn.METHOD) 1011 local doc = impl:doc_get(fn.METHOD)
999 if over and not doc:exists() then 1012 if over and not doc:exists() then
1000 local pimpl, pcl = find_parent_impl(impl:full_name_get(), cl) 1013 doc = find_parent_doc(impl:full_name_get(), cl, fn.METHOD)
1001 f:write_inherited(fn:nspaces_get(pcl)) 1014 end
1002 f:write_nl()
1003 else
1004 f:write_h("Signature", 2)
1005 f:write_code(gen_method_sig(fn, cl))
1006 f:write_nl()
1007 1015
1008 f:write_h("C signature", 2) 1016 f:write_h("Signature", 2)
1009 f:write_code(gen_func_csig(fn, mns), "c") 1017 f:write_code(gen_method_sig(fn, cl))
1010 f:write_nl() 1018 f:write_nl()
1011 1019
1012 local pars = fn:parameters_get() 1020 f:write_h("C signature", 2)
1013 if #pars > 0 then 1021 f:write_code(gen_func_csig(fn, mns), "c")
1014 f:write_h("Parameters", 2) 1022 f:write_nl()
1015 build_parlist(f, pars)
1016 f:write_nl()
1017 end
1018 1023
1019 f:write_h("Description", 2) 1024 local pars = fn:parameters_get()
1020 f:write_raw(impl:doc_get(fn.METHOD):full_get(nil, true)) 1025 if #pars > 0 then
1026 f:write_h("Parameters", 2)
1027 build_parlist(f, pars)
1021 f:write_nl() 1028 f:write_nl()
1022 end 1029 end
1023 1030
1031 f:write_h("Description", 2)
1032 f:write_raw(doc:full_get(nil, true))
1033 f:write_nl()
1034
1024 f:write_editable(mns, "description") 1035 f:write_editable(mns, "description")
1025 f:write_nl() 1036 f:write_nl()
1026 1037
@@ -1028,13 +1039,13 @@ build_method = function(impl, cl)
1028end 1039end
1029 1040
1030build_property = function(impl, cl) 1041build_property = function(impl, cl)
1042 local over = impl:is_overridden(cl)
1031 local fn = impl:function_get() 1043 local fn = impl:function_get()
1032 local pns = fn:nspaces_get(cl) 1044 local pns = fn:nspaces_get(cl)
1033 local f = writer.Writer(pns, cl:full_name_get() .. "." .. fn:name_get()) 1045 local f = writer.Writer(pns, cl:full_name_get() .. "." .. fn:name_get())
1034 1046
1035 local ft = fn:type_get() 1047 local isget = impl:is_prop_get()
1036 local isget = (ft == fn.PROP_GET or ft == fn.PROPERTY) 1048 local isset = impl:is_prop_set()
1037 local isset = (ft == fn.PROP_SET or ft == fn.PROPERTY)
1038 1049
1039 if isget then stats.check_property(fn, cl, fn.PROP_GET) end 1050 if isget then stats.check_property(fn, cl, fn.PROP_GET) end
1040 if isset then stats.check_property(fn, cl, fn.PROP_SET) end 1051 if isset then stats.check_property(fn, cl, fn.PROP_SET) end
@@ -1045,6 +1056,18 @@ build_property = function(impl, cl)
1045 local gdoc = pimp:doc_get(fn.PROP_GET) 1056 local gdoc = pimp:doc_get(fn.PROP_GET)
1046 local sdoc = pimp:doc_get(fn.PROP_SET) 1057 local sdoc = pimp:doc_get(fn.PROP_SET)
1047 1058
1059 if over then
1060 if not doc:exists() then
1061 doc = find_parent_doc(impl:full_name_get(), cl, fn.PROPERTY)
1062 end
1063 if isget and not gdoc:exists() then
1064 gdoc = find_parent_doc(impl:full_name_get(), cl, fn.PROP_GET)
1065 end
1066 if isset and not sdoc:exists() then
1067 sdoc = find_parent_doc(impl:full_name_get(), cl, fn.PROP_SET)
1068 end
1069 end
1070
1048 f:write_h("Signature", 2) 1071 f:write_h("Signature", 2)
1049 f:write_code(gen_prop_sig(fn, cl)) 1072 f:write_code(gen_prop_sig(fn, cl))
1050 f:write_nl() 1073 f:write_nl()