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 \
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
+++ /dev/null
-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
local eolian = require("eolian")
-local eomap = require("docgen.mappings")
local is_verbose = false
local util = require("util")
-local eomap = require("docgen.mappings")
local dutil = require("docgen.util")
+local dtree = require("docgen.doctree")
local M = {}
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(".")
local serializer = require("serializer")
-local eomap = require("docgen.mappings")
local stats = require("docgen.stats")
local dutil = require("docgen.util")
local writer = require("docgen.writer")