summaryrefslogtreecommitdiff
path: root/src/scripts
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2018-09-05 13:12:05 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2018-09-05 13:12:05 +0200
commit1e52108644becc9972c2101046cece23eb3268f9 (patch)
treed5c36faa62c836ee570db32c8610df09d1cbef55 /src/scripts
parent107bb9d2edb8d44beacde099be169383563af23d (diff)
elua: make old documentation generator generate instead of failing
While a rewritten template-based doc generator is pending addition into a separate repository, at least fix this one so that it works in case we decide to go back to it, because right now it's just failing because of out of date code. The fixes here are based on the revamped documentation generator that will be introduced.
Diffstat (limited to 'src/scripts')
-rw-r--r--src/scripts/elua/apps/docgen/doctree.lua23
-rw-r--r--src/scripts/elua/apps/docgen/mono.lua32
2 files changed, 29 insertions, 26 deletions
diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua
index 91f1bd1389..45171ca255 100644
--- a/src/scripts/elua/apps/docgen/doctree.lua
+++ b/src/scripts/elua/apps/docgen/doctree.lua
@@ -44,11 +44,11 @@ M.Node = util.Object:clone {
44 end, 44 end,
45 45
46 name_get = function(self) 46 name_get = function(self)
47 return self.obj:name_get() 47 return self._obj:name_get()
48 end, 48 end,
49 49
50 short_name_get = function(self) 50 short_name_get = function(self)
51 return self.obj:short_name_get() 51 return self._obj:short_name_get()
52 end, 52 end,
53 53
54 namespaces_get = function(self) 54 namespaces_get = function(self)
@@ -107,6 +107,11 @@ local add_since = function(str, since)
107end 107end
108 108
109M.Doc = Node:clone { 109M.Doc = Node:clone {
110 -- duplicate ctor to disable assertion
111 __ctor = function(self, obj)
112 self._obj = obj
113 end,
114
110 summary_get = function(self) 115 summary_get = function(self)
111 if not self._obj then 116 if not self._obj then
112 return nil 117 return nil
@@ -1349,26 +1354,24 @@ M.DocTokenizer = util.Object:clone {
1349 ref_resolve = function(self, root) 1354 ref_resolve = function(self, root)
1350 -- FIXME: unit 1355 -- FIXME: unit
1351 local tp, d1, d2 = self.tok:ref_resolve(eos) 1356 local tp, d1, d2 = self.tok:ref_resolve(eos)
1352 local reft = eolian.doc_ref_type 1357 local reft = eolian.object_type
1353 local ret = {} 1358 local ret = {}
1354 if tp == reft.CLASS or tp == reft.FUNC or tp == reft.EVENT then 1359 if tp == reft.CLASS or tp == reft.FUNCTION or tp == reft.EVENT then
1355 if not class_type_str[d1:type_get()] then 1360 if not class_type_str[d1:type_get()] then
1356 error("unknown class type for class '" 1361 error("unknown class type for class '"
1357 .. d1:name_get() .. "'") 1362 .. d1:name_get() .. "'")
1358 end 1363 end
1359 elseif tp == reft.ALIAS then 1364 elseif tp == reft.TYPEDECL then
1360 elseif tp == reft.STRUCT or tp == reft.STRUCT_FIELD then 1365 elseif tp == reft.ENUM_FIELD or tp == reft.STRUCT_FIELD then
1361 -- TODO: point to field
1362 elseif tp == reft.ENUM or tp == reft.ENUM_FIELD then
1363 -- TODO: point to field 1366 -- TODO: point to field
1364 elseif tp == reft.VAR then 1367 elseif tp == reft.VARIABLE then
1365 else 1368 else
1366 error("invalid reference '" .. self:text_get() .. "'") 1369 error("invalid reference '" .. self:text_get() .. "'")
1367 end 1370 end
1368 for tok in d1:name_get():gmatch("[^%.]+") do 1371 for tok in d1:name_get():gmatch("[^%.]+") do
1369 ret[#ret + 1] = tok:lower() 1372 ret[#ret + 1] = tok:lower()
1370 end 1373 end
1371 if tp == reft.FUNC then 1374 if tp == reft.FUNCTION then
1372 ret[#ret + 1] = func_type_str[d2:type_get()] 1375 ret[#ret + 1] = func_type_str[d2:type_get()]
1373 ret[#ret + 1] = d2:name_get():lower() 1376 ret[#ret + 1] = d2:name_get():lower()
1374 elseif tp == reft.EVENT then 1377 elseif tp == reft.EVENT then
diff --git a/src/scripts/elua/apps/docgen/mono.lua b/src/scripts/elua/apps/docgen/mono.lua
index 430a9ebebd..dbe98de171 100644
--- a/src/scripts/elua/apps/docgen/mono.lua
+++ b/src/scripts/elua/apps/docgen/mono.lua
@@ -87,7 +87,7 @@ local not_verbs = {
87 87
88local get_class_name = function(cls) 88local get_class_name = function(cls)
89 local words = {} 89 local words = {}
90 local klass = cls:full_name_get() 90 local klass = cls:name_get()
91 for word in string.gmatch(klass, "%a+") do 91 for word in string.gmatch(klass, "%a+") do
92 words[#words+1] = word 92 words[#words+1] = word
93 end 93 end
@@ -107,20 +107,20 @@ get_mono_type = function(tp)
107 tpdecl = tp:typedecl_get() 107 tpdecl = tp:typedecl_get()
108 108
109 if tpt == tp.REGULAR then 109 if tpt == tp.REGULAR then
110 if tp:full_name_get() == "string" then 110 if tp:name_get() == "string" then
111 return "System.String" 111 return "System.String"
112 elseif tp:full_name_get() == "list" then 112 elseif tp:name_get() == "list" then
113 ntp = tp:base_type_get() 113 ntp = tp:base_type_get()
114 --assert(btp ~= nil) 114 --assert(btp ~= nil)
115 --ntp = btp:next_type_get() 115 --ntp = btp:next_type_get()
116 return "eina.List<" .. get_mono_type(ntp) .. ">" 116 return "eina.List<" .. get_mono_type(ntp) .. ">"
117 elseif tpdecl then 117 elseif tpdecl then
118 --print("typedecl type is ", tp:full_name_get()) 118 --print("typedecl type is ", tp:name_get())
119 tpt = tpdecl:type_get() 119 tpt = tpdecl:type_get()
120 return get_class_name(tp) --tp:full_name_get() 120 return get_class_name(tp) --tp:name_get()
121 else 121 else
122 --print("regular type is ", tp:full_name_get()) 122 --print("regular type is ", tp:name_get())
123 return tp:full_name_get() 123 return tp:name_get()
124 end 124 end
125 elseif tpt == tp.CLASS then 125 elseif tpt == tp.CLASS then
126 return get_class_name(tp) 126 return get_class_name(tp)
@@ -189,7 +189,7 @@ local find_parent_impl
189find_parent_impl = function(fulln, cl) 189find_parent_impl = function(fulln, cl)
190 for i, pcl in ipairs(cl:inherits_get()) do 190 for i, pcl in ipairs(cl:inherits_get()) do
191 for j, impl in ipairs(pcl:implements_get()) do 191 for j, impl in ipairs(pcl:implements_get()) do
192 if impl:full_name_get() == fulln then 192 if impl:name_get() == fulln then
193 --if get_class_name(impl) == fulln then 193 --if get_class_name(impl) == fulln then
194 return impl, pcl 194 return impl, pcl
195 end 195 end
@@ -224,7 +224,7 @@ local write_description = function(f, impl, func, cl)
224 local doc = impl:doc_get(func.METHOD, true) 224 local doc = impl:doc_get(func.METHOD, true)
225 local docf = impl:fallback_doc_get(true) 225 local docf = impl:fallback_doc_get(true)
226 if over and (not doc:exists() and (not docf or not docf:exists())) then 226 if over and (not doc:exists() and (not docf or not docf:exists())) then
227 bdoc = find_parent_briefdoc(impl:full_name_get(), cl) 227 bdoc = find_parent_briefdoc(impl:name_get(), cl)
228 else 228 else
229 bdoc = doc:brief_get(docf) 229 bdoc = doc:brief_get(docf)
230 end 230 end
@@ -338,7 +338,7 @@ local gen_func_mono_sig = function(f, ftype)
338 pars[#pars + 1] = gen_mono_param(par) 338 pars[#pars + 1] = gen_mono_param(par)
339 end 339 end
340 for i, par in ipairs(vals) do 340 for i, par in ipairs(vals) do
341 print('parameter is value for get, so out') 341 --print('parameter is value for get, so out')
342 pars[#pars + 1] = gen_mono_param(par, true) 342 pars[#pars + 1] = gen_mono_param(par, true)
343 end 343 end
344 344
@@ -382,7 +382,7 @@ local build_functable = function(f, tcl, tbl)
382 table.sort(nt, function(v1, v2) 382 table.sort(nt, function(v1, v2)
383 local cl1, cl2 = v1[0], v2[0] 383 local cl1, cl2 = v1[0], v2[0]
384 if cl1 ~= cl2 then 384 if cl1 ~= cl2 then
385 return cl1:full_name_get() < cl2:full_name_get() 385 return cl1:name_get() < cl2:name_get()
386 end 386 end
387 387
388 local f1, f2 = v1[1], v2[1] 388 local f1, f2 = v1[1], v2[1]
@@ -435,7 +435,7 @@ M.build_inherits = function(cl, t, lvl)
435 cln = ":" .. 'develop:api' .. ":" 435 cln = ":" .. 'develop:api' .. ":"
436 .. table.concat(cln, ":") 436 .. table.concat(cln, ":")
437 lbuf:write_raw("[[", cln, "|", get_class_name(cl), "]]") 437 lbuf:write_raw("[[", cln, "|", get_class_name(cl), "]]")
438 --lbuf:write_link(cl:nspaces_get(true), cl:full_name_get()) 438 --lbuf:write_link(cl:nspaces_get(true), cl:name_get())
439 lbuf:write_raw(" ") 439 lbuf:write_raw(" ")
440 lbuf:write_i("(" .. cl:type_str_get() .. ")") 440 lbuf:write_i("(" .. cl:type_str_get() .. ")")
441 441
@@ -487,7 +487,7 @@ M.write_inherit_functable = function(f, tcl, tbl)
487 if cl ~= prevcl then 487 if cl ~= prevcl then
488 prevcl = cl 488 prevcl = cl
489 f:write_raw("^ ") 489 f:write_raw("^ ")
490 f:write_link(cl:nspaces_get(true), cl:full_name_get()) 490 f:write_link(cl:nspaces_get(true), cl:name_get())
491 f:write_raw(" ^^^") 491 f:write_raw(" ^^^")
492 f:write_nl() 492 f:write_nl()
493 end 493 end
@@ -535,7 +535,7 @@ M.write_functable = function(f, tcl, tbl)
535 -- but we get latest doc every time so it's ok for now 535 -- but we get latest doc every time so it's ok for now
536 local llbuf = writer.Buffer() 536 local llbuf = writer.Buffer()
537 llbuf:write_raw(" [Overridden from ") 537 llbuf:write_raw(" [Overridden from ")
538 llbuf:write_link(ocl:nspaces_get(true), ocl:full_name_get()) 538 llbuf:write_link(ocl:nspaces_get(true), ocl:name_get())
539 llbuf:write_raw("]") 539 llbuf:write_raw("]")
540 f:write_i(llbuf:finish()) 540 f:write_i(llbuf:finish())
541 end 541 end
@@ -562,12 +562,12 @@ end
562 562
563M.build_class = function(cl) 563M.build_class = function(cl)
564 local cln = cl:nspaces_get() 564 local cln = cl:nspaces_get()
565 local fulln = cl:full_name_get() 565 local fulln = cl:name_get()
566 --table.insert(cln, "mono") 566 --table.insert(cln, "mono")
567 cln[#cln] = cln[#cln] .. "_mono" 567 cln[#cln] = cln[#cln] .. "_mono"
568 --printgen("Generating (MONO) class: " .. fulln .. " in ns ", unpack(cln)) 568 --printgen("Generating (MONO) class: " .. fulln .. " in ns ", unpack(cln))
569 local f = writer.Writer(cln, fulln .. " (mono)") 569 local f = writer.Writer(cln, fulln .. " (mono)")
570 f:write_h(cl:full_name_get() .. " (" .. cl:type_str_get() .. ")", 1) 570 f:write_h(cl:name_get() .. " (" .. cl:type_str_get() .. ")", 1)
571 571
572 f:write_h("Description", 2) 572 f:write_h("Description", 2)
573 f:write_raw(cl:doc_get():full_get(nil, true)) 573 f:write_raw(cl:doc_get():full_get(nil, true))