mirror of https://github.com/Hilbis/Hilbish
fix: remove variables heading if there is none, account for global in new module doc format
parent
f741c2709c
commit
4e244e141f
24
preload.lua
24
preload.lua
|
@ -51,10 +51,7 @@ commander.register('doc', function(args)
|
||||||
These are the global Hilbish functions that are always available and not part of a module.]]
|
These are the global Hilbish functions that are always available and not part of a module.]]
|
||||||
local modDocFormat = [[
|
local modDocFormat = [[
|
||||||
%s
|
%s
|
||||||
|
|
||||||
# Variables
|
|
||||||
%s
|
%s
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
@ -85,11 +82,6 @@ These are the global Hilbish functions that are always available and not part of
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not f then
|
|
||||||
print('Could not find docs for module named ' .. mod .. '.')
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if not funcdocs then
|
if not funcdocs then
|
||||||
funcdocs = f:read '*a'
|
funcdocs = f:read '*a'
|
||||||
end
|
end
|
||||||
|
@ -105,12 +97,24 @@ These are the global Hilbish functions that are always available and not part of
|
||||||
end
|
end
|
||||||
end))
|
end))
|
||||||
|
|
||||||
|
if mod == 'global' or ok then
|
||||||
|
local props = {}
|
||||||
|
local propstr = ''
|
||||||
|
local modDesc = globalDesc
|
||||||
if ok then
|
if ok then
|
||||||
local modmt = getmetatable(require(mod))
|
local modmt = getmetatable(require(mod))
|
||||||
local props = table.map(modmt.__docProp, function(v, k)
|
modDesc = modmt.__doc
|
||||||
|
if modmt.__docProp then
|
||||||
|
-- not all modules have docs for properties
|
||||||
|
props = table.map(modmt.__docProp, function(v, k)
|
||||||
return lunacolors.underline(lunacolors.blue(k)) .. ' > ' .. v
|
return lunacolors.underline(lunacolors.blue(k)) .. ' > ' .. v
|
||||||
end)
|
end)
|
||||||
desc = string.format(modDocFormat, (mod == 'global' and globalDesc or modmt.__doc), table.concat(props, "\n"))
|
end
|
||||||
|
end
|
||||||
|
if #props > 0 then
|
||||||
|
propstr = '\n# Properties\n' .. table.concat(props, '\n') .. '\n'
|
||||||
|
end
|
||||||
|
desc = string.format(modDocFormat, modDesc, propstr)
|
||||||
end
|
end
|
||||||
print(desc .. formattedFuncs)
|
print(desc .. formattedFuncs)
|
||||||
f:close()
|
f:close()
|
||||||
|
|
Loading…
Reference in New Issue