summaryrefslogtreecommitdiff
path: root/tools/lovr-api.lua
diff options
context:
space:
mode:
authorC3pa <41503714+C3pa@users.noreply.github.com>2022-05-28 21:10:54 +0200
committerC3pa <41503714+C3pa@users.noreply.github.com>2022-05-28 21:10:54 +0200
commita570167f3cd6a6ee05d08022b88689685202efff (patch)
tree91c98509652d909fd768fc885663e432413036ac /tools/lovr-api.lua
parent7eaec047d708e84a7c29dd9d70e306d90fac412d (diff)
downloadlua-language-server-a570167f3cd6a6ee05d08022b88689685202efff.zip
Add optional for overloads
Diffstat (limited to 'tools/lovr-api.lua')
-rw-r--r--tools/lovr-api.lua5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/lovr-api.lua b/tools/lovr-api.lua
index d61bfdb7..dfa2bff8 100644
--- a/tools/lovr-api.lua
+++ b/tools/lovr-api.lua
@@ -128,10 +128,11 @@ local function buildDocFunc(variant, overload)
if param.name == '...' then
params[#params+1] = '...'
else
+ local optional = (param.type == 'table' and isTableOptional(param.table) or (param.default ~= nil)) and '?' or ''
if param.name:find '^[\'"]' then
- params[#params+1] = ('%s: %s|%q'):format(param.name:sub(2, -2), getTypeName(param.type), param.name)
+ params[#params+1] = ('%s%s: %s|%q'):format(param.name:sub(2, -2), optional, getTypeName(param.type), param.name)
else
- params[#params+1] = ('%s: %s'):format(param.name, getTypeName(param.type))
+ params[#params+1] = ('%s%s: %s'):format(param.name, optional, getTypeName(param.type))
end
end
end