summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-02-22 15:54:36 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-02-22 18:29:18 +0100
commit967af33da2d778afbcc7e21fc515728a2c0e0ea6 (patch)
treed6f7d0c12453bca53cdafec6ad38b9b29f6cf4ac
parent6245639b9c0c847abaafd845b630c27e633e37c7 (diff)
docgen: more useful function listings in class pages
Now there are C signatures visible.
-rw-r--r--src/scripts/elua/apps/docgen/writer.lua4
-rw-r--r--src/scripts/elua/apps/gendoc.lua53
2 files changed, 43 insertions, 14 deletions
diff --git a/src/scripts/elua/apps/docgen/writer.lua b/src/scripts/elua/apps/docgen/writer.lua
index fc3e423008..17238eea35 100644
--- a/src/scripts/elua/apps/docgen/writer.lua
+++ b/src/scripts/elua/apps/docgen/writer.lua
@@ -340,7 +340,9 @@ M.Writer = util.Object:clone {
340 end, 340 end,
341 341
342 write_table = function(self, titles, tbl) 342 write_table = function(self, titles, tbl)
343 self:write_raw("^ ", table.concat(titles, " ^ "), " ^\n") 343 if titles then
344 self:write_raw("^ ", table.concat(titles, " ^ "), " ^\n")
345 end
344 for i, v in ipairs(tbl) do 346 for i, v in ipairs(tbl) do
345 self:write_raw("| ", table.concat(v, " | "), " |\n") 347 self:write_raw("| ", table.concat(v, " | "), " |\n")
346 end 348 end
diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua
index 7f6a397cd0..4dbd433bed 100644
--- a/src/scripts/elua/apps/gendoc.lua
+++ b/src/scripts/elua/apps/gendoc.lua
@@ -33,12 +33,14 @@ local get_func_csig_part = function(cn, tp)
33 return dtree.type_cstr_get(tp, cn) 33 return dtree.type_cstr_get(tp, cn)
34end 34end
35 35
36local gen_func_csig = function(f, ns, ftype) 36local gen_func_csig = function(f, ftype, ns)
37 ftype = ftype or f.METHOD 37 ftype = ftype or f.METHOD
38 assert(ftype ~= f.PROPERTY) 38 assert(ftype ~= f.PROPERTY)
39 39
40 local cn = f:full_c_name_get(ftype) 40 local cn = f:full_c_name_get(ftype)
41 keyref.add(cn, ns, "c") 41 if ns then
42 keyref.add(cn, ns, "c")
43 end
42 local rtype = f:return_type_get(ftype) 44 local rtype = f:return_type_get(ftype)
43 45
44 local fparam = "Eo *obj" 46 local fparam = "Eo *obj"
@@ -696,7 +698,7 @@ find_parent_briefdoc = function(fulln, cl)
696 return pdoc:brief_get(pdocf) 698 return pdoc:brief_get(pdocf)
697end 699end
698 700
699local build_functable = function(f, title, ctitle, cl, tbl, over) 701local build_functable = function(f, title, cl, tbl, over)
700 if #tbl == 0 then 702 if #tbl == 0 then
701 return 703 return
702 end 704 end
@@ -705,7 +707,9 @@ local build_functable = function(f, title, ctitle, cl, tbl, over)
705 for i, impl in ipairs(tbl) do 707 for i, impl in ipairs(tbl) do
706 local lbuf = writer.Buffer() 708 local lbuf = writer.Buffer()
707 local func = impl:function_get() 709 local func = impl:function_get()
708 lbuf:write_link(func:nspaces_get(cl, true), func:name_get()) 710 local llbuf = writer.Buffer()
711 llbuf:write_link(func:nspaces_get(cl, true), func:name_get())
712 lbuf:write_b(llbuf:finish())
709 713
710 local ft = dtree.Function.METHOD 714 local ft = dtree.Function.METHOD
711 if impl:is_prop_get() and impl:is_prop_set() then 715 if impl:is_prop_get() and impl:is_prop_set() then
@@ -742,7 +746,25 @@ local build_functable = function(f, title, ctitle, cl, tbl, over)
742 else 746 else
743 bdoc = doc:brief_get(docf) 747 bdoc = doc:brief_get(docf)
744 end 748 end
745 nt[#nt + 1] = { lbuf:finish(), bdoc } 749
750 lbuf:write_nl()
751 local codes = {}
752 if ft ~= dtree.Function.PROPERTY then
753 codes[#codes + 1] = gen_func_csig(func, ft)
754 else
755 codes[#codes + 1] = gen_func_csig(func, dtree.Function.PROP_GET)
756 codes[#codes + 1] = gen_func_csig(func, dtree.Function.PROP_SET)
757 end
758 lbuf:write_code(table.concat(codes, "\n"), "c")
759
760 if bdoc ~= "No description supplied." then
761 lbuf:write_nl()
762 lbuf:write_raw(bdoc)
763 lbuf:write_br()
764 end
765
766 nt[#nt + 1] = { lbuf:finish() }
767
746 if impl:is_prop_get() or impl:is_prop_set() then 768 if impl:is_prop_get() or impl:is_prop_set() then
747 build_property(impl, cl) 769 build_property(impl, cl)
748 else 770 else
@@ -750,7 +772,12 @@ local build_functable = function(f, title, ctitle, cl, tbl, over)
750 end 772 end
751 end 773 end
752 table.sort(nt, function(v1, v2) return v1[1] < v2[1] end) 774 table.sort(nt, function(v1, v2) return v1[1] < v2[1] end)
753 f:write_table({ ctitle, "Brief description" }, nt) 775 for i, item in ipairs(nt) do
776 f:write_raw(item[1])
777 f:write_nl()
778 f:write_br()
779 f:write_nl()
780 end
754 f:write_nl() 781 f:write_nl()
755end 782end
756 783
@@ -798,10 +825,10 @@ local build_class = function(cl)
798 end 825 end
799 end 826 end
800 827
801 build_functable(f, "Methods", "Method name", cl, meths, false) 828 build_functable(f, "Methods", cl, meths, false)
802 build_functable(f, "Properties", "Property name", cl, props, false) 829 build_functable(f, "Properties", cl, props, false)
803 build_functable(f, "Overridden Methods", "Method name", cl, methos, true) 830 build_functable(f, "Overridden Methods", cl, methos, true)
804 build_functable(f, "Overridden Properties", "Property name", cl, propos, true) 831 build_functable(f, "Overridden Properties", cl, propos, true)
805 832
806 f:write_h("Events", 2) 833 f:write_h("Events", 2)
807 local evs = cl:events_get() 834 local evs = cl:events_get()
@@ -1117,7 +1144,7 @@ build_method = function(impl, cl)
1117 f:write_nl() 1144 f:write_nl()
1118 1145
1119 f:write_h("C signature", 2) 1146 f:write_h("C signature", 2)
1120 f:write_code(gen_func_csig(fn, mns), "c") 1147 f:write_code(gen_func_csig(fn, nil, mns), "c")
1121 f:write_nl() 1148 f:write_nl()
1122 1149
1123 local pars = fn:parameters_get() 1150 local pars = fn:parameters_get()
@@ -1181,10 +1208,10 @@ build_property = function(impl, cl)
1181 f:write_h("C signature", 2) 1208 f:write_h("C signature", 2)
1182 local codes = {} 1209 local codes = {}
1183 if isget then 1210 if isget then
1184 codes[#codes + 1] = gen_func_csig(fn, pns, fn.PROP_GET) 1211 codes[#codes + 1] = gen_func_csig(fn, fn.PROP_GET, pns)
1185 end 1212 end
1186 if isset then 1213 if isset then
1187 codes[#codes + 1] = gen_func_csig(fn, pns, fn.PROP_SET) 1214 codes[#codes + 1] = gen_func_csig(fn, fn.PROP_SET, pns)
1188 end 1215 end
1189 f:write_code(table.concat(codes, "\n"), "c") 1216 f:write_code(table.concat(codes, "\n"), "c")
1190 f:write_nl() 1217 f:write_nl()