Very nice !
I have made some modifications to list only the LuaRT modules, using the terms "property" or "method" when more appropriate. The final "list.txt" generated file is then opened in a new window.
PS:
Mike, I know you can't wait to check out all the other LuaRT modules 😆😆😆
And yes, most of the features are already there, all of this in just 200Kb !! 👍️
local modules = {
console = require("console"),
crypto = require("crypto"),
net = require("net"),
sys = require("sys"),
ui = require("ui"),
zip = require("zip")
}
local function indexsort(x, y)
x, y = tostring(x), tostring(y)
local lx, ly = x:lower(), y:lower()
if lx ~= ly then return lx < ly end
return x < y
end
local function makeindex(obj)
local index = {}
for key in pairs(obj) do
table.insert(index, key)
end
table.sort(index, indexsort)
return index
end
local file = sys.File("list.txt")
local badtypes = {["nil"] = true, boolean = true, number = true, string = true, ["function"] = true, thread = true, userdata = true}
function prettyprint(obj, level, prefix)
level = level or 0
prefix = prefix or ""
index = makeindex(obj)
local value
local properties = {}
for i, key in ipairs(index) do
if type(key) == "string" then
value = obj[key]
local _type = type(value)
if level == 2 then
_type = "method"
local propname = key:match("[gs]+et_(%w+)")
if propname then
_type = "property"
key = propname
if not properties[propname] then
properties[propname] = true
else
goto done
end
end
end
file:writeln(("\t"):rep(level) .. prefix .. key .. " = " .. _type)
end
::done::
if not badtypes[type(value)] then
prettyprint(value, level + 1)
end
end
end
file:open("write")
prettyprint(modules)
file:close()
sys.cmd(file.filename)