Last active
September 15, 2020 13:40
-
-
Save sum-catnip/733cb8dc1208f2e43a55e4c5c0e133c8 to your computer and use it in GitHub Desktop.
my solution to lua docstrings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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