q66 pushed a commit to branch master. http://git.enlightenment.org/tools/edocgen.git/commit/?id=5b4dd817938bd1affd2d1c397edabfefa2825a77
commit 5b4dd817938bd1affd2d1c397edabfefa2825a77 Author: Daniel Kolesa <[email protected]> Date: Mon Dec 17 16:35:49 2018 +0100 remove mono module, as C# documentation will be DocFx --- docgen/mono.lua | 493 -------------------------------------------------------- gendoc.lua | 4 - 2 files changed, 497 deletions(-) diff --git a/docgen/mono.lua b/docgen/mono.lua deleted file mode 100644 index d0efb9e..0000000 --- a/docgen/mono.lua +++ /dev/null @@ -1,493 +0,0 @@ - -local writer = require("docgen.writer") - -local eolian = require("eolian") -local eoutils = require("docgen.eolian_utils") -local docm = require("docgen.doc") - -local eos - -local M = {} - -local propt_to_type = { - [eolian.function_type.PROPERTY] = "(get, set)", - [eolian.function_type.PROP_GET] = "(get)", - [eolian.function_type.PROP_SET] = "(set)", -} - -local verbs = { - "add", - "get", - "is", - "del", - "thaw", - "freeze", - "save", - "wait", - "eject", - "raise", - "lower", - "load", - "dup", - "reset", - "unload", - "close", - "set", - "interpolate", - "has", - "grab", - "check", - "find", - "ungrab", - "unset", - "clear", - "pop", - "new", - "peek", - "push", - "update", - "show", - "move", - "hide", - "calculate", - "resize", - "attach", - "pack", - "unpack", - "emit", - "call", - "append" -} - -local not_verbs = { - "below", - "above", - "name", - "unfreezable", - "value", - "r", - "g", - "b", - "a", - "finalize", - "destructor", - "to", - "circle", - "rect", - "path", - "commands", - "type", - "colorspace", - "op", - "type", - "properties", - "status", - "status", - "relative", - "ptr", - "pair", - "pos", - "end" -} - -local get_class_name = function(cls) - local words = {} - local klass = cls:name_get() - for word in string.gmatch(klass, "%a+") do - words[#words+1] = word - end - for i = 1, #words -1 do - words[i] = string.lower(words[i]) - end - return table.concat(words, '.') -end - -local get_mono_type -get_mono_type = function(tp) - if not tp then - return "void " - end - - tpt = tp:type_get() - tpdecl = tp:typedecl_get() - - if tpt == eolian.type_type.REGULAR then - if tp:name_get() == "string" then - return "System.String" - elseif tp:name_get() == "list" then - ntp = tp:base_type_get() - --assert(btp ~= nil) - --ntp = btp:next_type_get() - return "eina.List<" .. get_mono_type(ntp) .. ">" - elseif tpdecl then - --print("typedecl type is ", tp:name_get()) - tpt = tpdecl:type_get() - return get_class_name(tp) --tp:name_get() - else - --print("regular type is ", tp:name_get()) - return tp:name_get() - end - elseif tpt == eolian.type_type.CLASS then - return get_class_name(tp) - else - return "unknown" - end -end - - -local is_verb = function(word) - for i = 1, #verbs do - if verbs[i] == word then - return true - end - end - return false -end - -local mono_method_name_get = function(f, ftype) - local cn = f:name_get(ftype) - - local words = {} - - for word in string.gmatch(cn, "%a+") do - words[#words+1] = word - end - - if #words > 1 and is_verb(words[#words]) then - local tmp = words[#words] - words[#words] = words[1] - words[1] = tmp - end - - for i = 1, #words do - words[i] = words[i]:gsub("^%l", string.upper) - end - - if ftype == eolian.function_type.PROP_GET then - table.insert(words, 1, "Get") - elseif ftype == eolian.function_type.PROP_SET then - table.insert(words, 1, "Set") - end - - return table.concat(words) -end - -local gen_mono_param = function(par, out) - local part = par:type_get() - out = out or (par:direction_get() == eolian.parameter_dir.OUT) - if out then - out = "out " - else - out = "" - end - - return out .. get_mono_type(par:type_get()) .. ' ' .. par:name_get() - --local tstr = part:c_type_get() - --return out .. eoutils.type_cstr_get(tstr, par:name_get()) -end - -local get_func_mono_sig_part = function(cn, tp) - return get_mono_type(tp) .. " " .. cn -end - -local write_scope = function(f, func) - local ftt = { - [eolian.object_scope.PROTECTED] = "protected", - [eolian.object_scope.PRIVATE] = "private" - } - if func:is_class() then - f:write_raw(" ") - f:write_m("class") - end - if func:type_get() == eolian.function_type.PROPERTY then - local ft1, ft2 = ftt[func:scope_get(eolian.function_type.PROP_GET)], - ftt[func:scope_get(eolian.function_type.PROP_SET)] - if ft1 and ft1 == ft2 then - f:write_raw(" ") - f:write_m(ft1) - elseif ft1 or ft2 then - local s = "" - if ft1 then - s = s .. ft1 .. " get" .. (ft2 and ", " or "") - end - if ft2 then - s = s .. ft2 .. " set" - end - f:write_raw(" ") - f:write_m(s) - end - else - local ft = ftt[func:scope_get(func:type_get())] - if ft then - f:write_raw(" ") - f:write_m(ft) - end - end -end - -local write_function = function(f, func, cl) - local llbuf = writer.Buffer() - llbuf:write_link(eoutils.func_nspaces_get(func, cl, true), func:name_get()) - f:write_b(llbuf:finish()) - - local pt = propt_to_type[func:type_get()] - if pt then - f:write_raw(" ") - local llbuf = writer.Buffer() - llbuf:write_b(pt) - f:write_i(llbuf:finish()) - end -end - -local gen_func_mono_sig = function(f, ftype) - ftype = ftype or eolian.function_type.METHOD - assert(ftype ~= eolian.function_type.PROPERTY) - - local cn = mono_method_name_get(f, ftype) - local rtype = f:return_type_get(ftype) - local prefix = "" - local suffix = "" - - if f:is_class() then - prefix = "static " - elseif f:is_const() or ftype == eolian.function_type.PROP_GET then - suffix = " const" - end - - if f:type_get() == eolian.function_type.METHOD then - local pars = f:parameters_get():to_array() - local cnrt = get_func_mono_sig_part(cn, rtype) - for i = 1, #pars do - pars[i] = gen_mono_param(pars[i]) - end - return prefix .. cnrt .. "(" .. table.concat(pars, ", ") .. ")" .. suffix .. ";" - end - - local keys = f:property_keys_get(ftype):to_array() - local vals = f:property_values_get(ftype):to_array() - - if ftype == eolian.function_type.PROP_SET then - local cnrt = get_func_mono_sig_part(cn, rtype) - local pars = {} - for i, par in ipairs(keys) do - pars[#pars + 1] = gen_mono_param(par) - end - for i, par in ipairs(vals) do - pars[#pars + 1] = gen_mono_param(par) - end - return cnrt .. "(" .. table.concat(pars, ", ") .. ");" - end - - -- getters - local cnrt - if not rtype then - if #vals == 1 then - cnrt = get_func_mono_sig_part(cn, vals[1]:type_get()) - table.remove(vals, 1) - else - cnrt = get_func_mono_sig_part(cn) - end - else - cnrt = get_func_mono_sig_part(cn, rtype) - end - local pars = {} - for i, par in ipairs(keys) do - pars[#pars + 1] = gen_mono_param(par) - end - for i, par in ipairs(vals) do - --print('parameter is value for get, so out') - pars[#pars + 1] = gen_mono_param(par, true) - end - - return cnrt .. "(" .. table.concat(pars, ", ") .. ");" -end - -M.build_inherits = function(cl, t, lvl) - t = t or {} - lvl = lvl or 0 - local lbuf = writer.Buffer() - if lvl > 0 then - local cln = eoutils.obj_nspaces_get(cl, true) - cln[#cln] = nil - cln[#cln] = cln[#cln] .. "_mono" - cln = ":" .. 'develop:api' .. ":" - .. table.concat(cln, ":") - lbuf:write_raw("[[", cln, "|", get_class_name(cl), "]]") - --lbuf:write_link(eoutils.obj_nspaces_get(cl, true), cl:name_get()) - lbuf:write_raw(" ") - lbuf:write_i("(" .. eoutils.class_type_str_get(cl) .. ")") - - t[#t + 1] = { lvl - 1, lbuf:finish() } - end - - for acl in cl:inherits_get() do - M.build_inherits(acl, t, lvl + 1) - end - return t -end - -M.build_inherit_summary = function(cl, buf) - buf = buf or writer.Buffer() - buf:write_raw(" => ") - - local cln = eoutils.obj_nspaces_get(cl, true) - cln[#cln] = nil - cln[#cln] = cln[#cln] .. "_mono" - cln = ":" .. 'develop:api' .. ":" - .. table.concat(cln, ":") - buf:write_raw("[[", cln, "|", get_class_name(cl), "]]") - buf:write_raw(" ") - buf:write_i("(" .. eoutils.class_type_str_get(cl) .. ")") - - local inherits = cl:inherits_get():to_array() - if #inherits ~= 0 then - M.build_inherit_summary(inherits[1], buf) - end - return buf -end - -M.write_inherit_functable = function(f, tcl, tbl) - if #tbl == 0 then - return - end - local nt = eoutils.sorted_funclist_get(tcl, tbl) - - local prevcl = tcl - for i, wt in ipairs(nt) do - local cl = wt[0] - local func = wt[1] - local impl = wt[2] - - local func = impl:function_get() - - -- class grouping for inheritance - if cl ~= prevcl then - prevcl = cl - f:write_raw("^ ") - f:write_link(eoutils.obj_nspaces_get(cl, true), cl:name_get()) - f:write_raw(" ^^^") - f:write_nl() - end - - -- scope - f:write_raw("| ") - write_scope(f, func) - f:write_raw(" | ") - -- function - write_function(f, func, cl) - f:write_raw(" | ") - -- description - local desc = docm.impl_description_get(eos, impl, cl) - if desc then - f:write_raw(desc) - end - f:write_raw(" |") - f:write_nl() - end - f:write_nl() -end - -M.write_functable = function(f, tcl, tbl) - if #tbl == 0 then - return - end - local nt = eoutils.sorted_funclist_get(tcl, tbl) - - local wrote = false - for i, wt in ipairs(nt) do - local cl = wt[0] - local func = wt[1] - local impl = wt[2] - - local ocl = impl:class_get() - local func = impl:function_get() - local over = eoutils.impl_is_overridden(impl, cl) - - -- function - write_function(f, func, cl) - -- scope - write_scope(f, func) - - -- overrides - if over then - -- TODO: possibly also mention which part of a property was - -- overridden and where, get/set override point might differ! - -- but we get latest doc every time so it's ok for now - local llbuf = writer.Buffer() - llbuf:write_raw(" [Overridden from ") - llbuf:write_link(eoutils.obj_nspaces_get(ocl, true), ocl:name_get()) - llbuf:write_raw("]") - f:write_i(llbuf:finish()) - end - - -- description - f:write_br(true) - f:write_raw("> ") - local desc = docm.impl_description_get(eos, impl, cl) - if desc then - f:write_raw(desc) - end - - -- code snippets - f:write_nl() - local codes = {} - if func:type_get() ~= eolian.function_type.PROPERTY then - codes[#codes + 1] = gen_func_mono_sig(func, func:type_get()) - else - codes[#codes + 1] = gen_func_mono_sig(func, eolian.function_type.PROP_GET) - codes[#codes + 1] = gen_func_mono_sig(func, eolian.function_type.PROP_SET) - end - f:write_code(table.concat(codes, "\n"), "c") - f:write_br(true) - end - f:write_nl() -end - -M.build_class = function(cl) - local cln = eoutils.obj_nspaces_get(cl) - local fulln = cl:name_get() - --table.insert(cln, "mono") - cln[#cln] = cln[#cln] .. "_mono" - --printgen("Generating (MONO) class: " .. fulln .. " in ns ", unpack(cln)) - local f = writer.Writer(cln, fulln .. " (mono)") - f:write_h(cl:name_get() .. " (" .. eoutils.class_type_str_get(cl) .. ")", 1) - - f:write_h("Description", 2) - f:write_raw(docm.full_str_get(eos, cl:documentation_get(), nil, true)) - f:write_nl(2) - - f:write_editable(cln, "description") - f:write_nl() - - local inherits = cl:inherits_get():to_array() - if #inherits ~= 0 then - f:write_h("Inheritance", 2) - - f:write_raw(M.build_inherit_summary(inherits[1]):finish()) - f:write_nl() - - f:write_folded("Full hierarchy", function() - f:write_list(M.build_inherits(cl)) - end) - f:write_nl() - end - - local meths, omeths, ievs = eoutils.callables_get(cl) - - f:write_h("Members", 2) - M.write_functable(f, cl, meths, true) - if #omeths ~= 0 then - f:write_h("Inherited", 3) - end - M.write_inherit_functable(f, cl, omeths, false) - - f:finish() -end - -M.init = function(eosh) - eos = eosh -end - -return M - - diff --git a/gendoc.lua b/gendoc.lua index b6cea56..6861cc8 100644 --- a/gendoc.lua +++ b/gendoc.lua @@ -12,7 +12,6 @@ local stats = require("docgen.stats") local dutil = require("docgen.util") local writer = require("docgen.writer") local keyref = require("docgen.keyref") -local mono = require("docgen.mono") local eos @@ -420,8 +419,6 @@ local build_class = function(cl) local f = writer.Writer(cln, fulln) printgen("Generating class: " .. fulln) - --mono.build_class(cl) - f:write_h(cl:name_get() .. " (" .. eoutils.class_type_str_get(cl) .. ")", 1) f:write_h("Description", 2) @@ -862,7 +859,6 @@ getopt.parse { parse(st) eoutils.build_class_children(eos) - --mono.init(eos) if st == "clist" then for cl in eos:classes_get() do --
