-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
49 lines (45 loc) · 1006 Bytes
/
Copy pathinit.lua
File metadata and controls
49 lines (45 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
-- This Lua module is invoked by LDoc to save output
-- in JSON format, which is then used by ldoc2mkdoc
local json = require("json")
function filterEntryItem(_entry, item)
if item["params"] then
local params = item["params"]
local paramsList = {}
local paramsMap = params["map"] or {}
for k, v in pairs(params) do
if tonumber(k) then
paramsList[tonumber(k)] = v
end
end
item["paramsList"] = paramsList
item["paramsMap"] = paramsMap
end
end
local seen = {}
local function recurse(v, name)
if type(v) == "table" then
if seen[v] then
return "RECURSIVE"
else
seen[v] = true
for k, v2 in pairs(v) do
v[k] = recurse(v2, name .. "." .. tostring(k))
end
seen[v] = nil
end
elseif type(v) == "function" then
return "FUNCTION"
end
return v
end
return {
filter = function (t)
recurse(t, "root")
for _, entry in pairs(t) do
for __, item in pairs(entry["items"]) do
filterEntryItem(entry, item)
end
end
print(json.encode.encode(t))
end
}