q66 pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=c122992884d9f1136d16e02e6b9def514c321ecf
commit c122992884d9f1136d16e02e6b9def514c321ecf Author: Daniel Kolesa <[email protected]> Date: Mon Aug 15 14:25:04 2016 +0100 docs: remove the mappings module --- src/Makefile_Elua.am | 1 - src/scripts/elua/apps/docgen/doctree.lua | 89 +++++++++++++++++++++++++++++ src/scripts/elua/apps/docgen/mappings.lua | 95 ------------------------------- src/scripts/elua/apps/docgen/stats.lua | 1 - src/scripts/elua/apps/docgen/writer.lua | 4 +- src/scripts/elua/apps/gendoc.lua | 1 - 6 files changed, 91 insertions(+), 100 deletions(-) diff --git a/src/Makefile_Elua.am b/src/Makefile_Elua.am index 798f843..ace5d6f 100644 --- a/src/Makefile_Elua.am +++ b/src/Makefile_Elua.am @@ -68,7 +68,6 @@ eluadocgendir = $(datadir)/elua/apps/docgen eluadocgen_DATA = \ scripts/elua/apps/docgen/doctree.lua \ scripts/elua/apps/docgen/keyref.lua \ - scripts/elua/apps/docgen/mappings.lua \ scripts/elua/apps/docgen/serializers.lua \ scripts/elua/apps/docgen/stats.lua \ scripts/elua/apps/docgen/util.lua \ diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua index 0b686d6..03290b9 100644 --- a/src/scripts/elua/apps/docgen/doctree.lua +++ b/src/scripts/elua/apps/docgen/doctree.lua @@ -503,6 +503,95 @@ M.Event = Node:clone { end } +local decl_to_nspace = function(decl) + local dt = eolian.declaration_type + local decltypes = { + [dt.ALIAS] = "alias", + [dt.STRUCT] = "struct", + [dt.ENUM] = "enum", + [dt.VAR] = "var" + } + local ns = decltypes[decl:type_get()] + if ns then + return ns + elseif decl:type_get() == dt.CLASS then + local ret = M.Class(decl:class_get()):type_str_get() + if not ret then + error("unknown class type for class '" .. decl:name_get() .. "'") + end + return ret + else + error("unknown declaration type for declaration '" + .. decl:name_get() .. "'") + end +end + +M.ref_get = function(str, root) + local decl = eolian.declaration_get_by_name(str) + if decl then + local t = { decl_to_nspace(decl) } + for tok in str:gmatch("[^%.]+") do + t[#t + 1] = tok:lower() + end + if root then t[#t + 1] = true end + return t + end + + -- field or func + local bstr = str:match("(.+)%.[^.]+") + if not bstr then + error("invalid reference '" .. str .. "'") + end + + local sfx = str:sub(#bstr + 1) + + decl = eolian.declaration_get_by_name(bstr) + if decl then + local dt = eolian.declaration_type + local tp = decl:type_get() + if tp == dt.STRUCT or tp == dt.ENUM then + -- TODO: point to the actual item + return M.ref_get(bstr, root) + end + end + + local cl = M.Class.by_name_get(bstr) + local fn + local ftype = M.Function.UNRESOLVED + if not cl then + if sfx == ".get" then + ftype = M.Function.PROP_GET + elseif sfx == ".set" then + ftype = M.Function.PROP_SET + end + local mname + if ftype ~= M.Function.UNRESOLVED then + mname = bstr:match(".+%.([^.]+)") + if not mname then + error("invalid reference '" .. str .. "'") + end + bstr = bstr:match("(.+)%.[^.]+") + cl = M.Class.by_name_get(bstr) + if cl then + fn = cl:function_get_by_name(mname, ftype) + end + end + else + fn = cl:function_get_by_name(sfx:sub(2), ftype) + if fn then ftype = fn:type_get() end + end + + if not fn or not fn:type_str_get() then + error("invalid reference '" .. str .. "'") + end + + local ret = M.ref_get(bstr) + ret[#ret + 1] = fn:type_str_get() + ret[#ret + 1] = fn:name_get():lower() + if root then ret[#ret + 1] = true end + return ret +end + M.scan_directory = function(dir) if not dir then if not eolian.system_directory_scan() then diff --git a/src/scripts/elua/apps/docgen/mappings.lua b/src/scripts/elua/apps/docgen/mappings.lua deleted file mode 100644 index a319789..0000000 --- a/src/scripts/elua/apps/docgen/mappings.lua +++ /dev/null @@ -1,95 +0,0 @@ -local eolian = require("eolian") -local dtree = require("docgen.doctree") - -local M = {} - -local decl_to_nspace = function(decl) - local dt = eolian.declaration_type - local decltypes = { - [dt.ALIAS] = "alias", - [dt.STRUCT] = "struct", - [dt.ENUM] = "enum", - [dt.VAR] = "var" - } - local ns = decltypes[decl:type_get()] - if ns then - return ns - elseif decl:type_get() == dt.CLASS then - local ret = dtree.Class(decl:class_get()):type_str_get() - if not ret then - error("unknown class type for class '" .. decl:name_get() .. "'") - end - return ret - else - error("unknown declaration type for declaration '" - .. decl:name_get() .. "'") - end -end - -M.gen_nsp_ref = function(str, root) - local decl = eolian.declaration_get_by_name(str) - if decl then - local t = { decl_to_nspace(decl) } - for tok in str:gmatch("[^%.]+") do - t[#t + 1] = tok:lower() - end - if root then t[#t + 1] = true end - return t - end - - -- field or func - local bstr = str:match("(.+)%.[^.]+") - if not bstr then - error("invalid reference '" .. str .. "'") - end - - local sfx = str:sub(#bstr + 1) - - decl = eolian.declaration_get_by_name(bstr) - if decl then - local dt = eolian.declaration_type - local tp = decl:type_get() - if tp == dt.STRUCT or tp == dt.ENUM then - -- TODO: point to the actual item - return M.gen_nsp_ref(bstr, root) - end - end - - local cl = dtree.Class.by_name_get(bstr) - local fn - local ftype = dtree.Function.UNRESOLVED - if not cl then - if sfx == ".get" then - ftype = dtree.Function.PROP_GET - elseif sfx == ".set" then - ftype = dtree.Function.PROP_SET - end - local mname - if ftype ~= dtree.Function.UNRESOLVED then - mname = bstr:match(".+%.([^.]+)") - if not mname then - error("invalid reference '" .. str .. "'") - end - bstr = bstr:match("(.+)%.[^.]+") - cl = dtree.Class.by_name_get(bstr) - if cl then - fn = cl:function_get_by_name(mname, ftype) - end - end - else - fn = cl:function_get_by_name(sfx:sub(2), ftype) - if fn then ftype = fn:type_get() end - end - - if not fn or not fn:type_str_get() then - error("invalid reference '" .. str .. "'") - end - - local ret = M.gen_nsp_ref(bstr) - ret[#ret + 1] = fn:type_str_get() - ret[#ret + 1] = fn:name_get():lower() - if root then ret[#ret + 1] = true end - return ret -end - -return M diff --git a/src/scripts/elua/apps/docgen/stats.lua b/src/scripts/elua/apps/docgen/stats.lua index 895e77d..5768a6a 100644 --- a/src/scripts/elua/apps/docgen/stats.lua +++ b/src/scripts/elua/apps/docgen/stats.lua @@ -1,5 +1,4 @@ local eolian = require("eolian") -local eomap = require("docgen.mappings") local is_verbose = false diff --git a/src/scripts/elua/apps/docgen/writer.lua b/src/scripts/elua/apps/docgen/writer.lua index 9683edf..110e00e 100644 --- a/src/scripts/elua/apps/docgen/writer.lua +++ b/src/scripts/elua/apps/docgen/writer.lua @@ -1,7 +1,7 @@ local util = require("util") -local eomap = require("docgen.mappings") local dutil = require("docgen.util") +local dtree = require("docgen.doctree") local M = {} @@ -269,7 +269,7 @@ M.Writer = util.Object:clone { end local title = table.concat(rbuf) self:write_raw("%%") - self:write_link(eomap.gen_nsp_ref(title, true), title) + self:write_link(dtree.ref_get(title, true), title) self:write_raw("%%") if ldot then self:write_raw(".") diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua index 657e067..742ce2a 100644 --- a/src/scripts/elua/apps/gendoc.lua +++ b/src/scripts/elua/apps/gendoc.lua @@ -3,7 +3,6 @@ local getopt = require("getopt") local serializer = require("serializer") -local eomap = require("docgen.mappings") local stats = require("docgen.stats") local dutil = require("docgen.util") local writer = require("docgen.writer") --
