From 15035c02cb643bb7a62ba17d34f6e203e4a2a35c Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Sun, 8 May 2022 16:02:24 -0400 Subject: [PATCH] fix(doc): check if modmt exists before trying to get module prop docs --- nature/commands/doc.lua | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/nature/commands/doc.lua b/nature/commands/doc.lua index 34e81ae..a290cd8 100644 --- a/nature/commands/doc.lua +++ b/nature/commands/doc.lua @@ -58,17 +58,19 @@ commander.register('doc', function(args) local propstr = '' local modDesc = '' local modmt = getmetatable(require(mod)) - 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 - end) + if modmt then + 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 + end) + end + if #props > 0 then + propstr = '\n# Properties\n' .. table.concat(props, '\n') .. '\n' + end + desc = string.format(modDocFormat, modDesc, propstr) end - if #props > 0 then - propstr = '\n# Properties\n' .. table.concat(props, '\n') .. '\n' - end - desc = string.format(modDocFormat, modDesc, propstr) end print(desc .. formattedFuncs) f:close()