Skip to content

Instantly share code, notes, and snippets.

@sum-catnip
Last active September 15, 2020 13:40
Show Gist options
  • Save sum-catnip/733cb8dc1208f2e43a55e4c5c0e133c8 to your computer and use it in GitHub Desktop.
Save sum-catnip/733cb8dc1208f2e43a55e4c5c0e133c8 to your computer and use it in GitHub Desktop.
my solution to lua docstrings
local function doc(string)
return setmetatable({doc = string}, {
__concat = function(t, f)
if type(f) == 'function'
then t.func = f; return t
else f.doc = t.doc .. '\n' .. f.doc; return f
end
end,
__call = function(t, ...) return t.func(...) end
})
end
local yeet =
doc('kektop') ..
doc('topkek') ..
function(a, b, c)
print('kektop', a, b, c)
end
yeet('a', 'b', 'c')
print(yeet.doc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment