docs: remove the mappings module
authorDaniel Kolesa <d.kolesa@osg.samsung.com>
Mon, 15 Aug 2016 13:25:04 +0000 (14:25 +0100)
committerDaniel Kolesa <d.kolesa@osg.samsung.com>
Mon, 15 Aug 2016 13:25:04 +0000 (14:25 +0100)
src/Makefile_Elua.am
src/scripts/elua/apps/docgen/doctree.lua
src/scripts/elua/apps/docgen/mappings.lua [deleted file]
src/scripts/elua/apps/docgen/stats.lua
src/scripts/elua/apps/docgen/writer.lua
src/scripts/elua/apps/gendoc.lua

index 798f843..ace5d6f 100644 (file)
@@ -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 \
index 0b686d6..03290b9 100644 (file)
@@ -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 (file)
index a319789..0000000
+++ /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
index 895e77d..5768a6a 100644 (file)
@@ -1,5 +1,4 @@
 local eolian = require("eolian")
-local eomap = require("docgen.mappings")
 
 local is_verbose = false
 
index 9683edf..110e00e 100644 (file)
@@ -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(".")
index 657e067..742ce2a 100644 (file)
@@ -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")