diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-07-20 17:28:53 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-07-20 17:28:53 +0800 |
commit | bd51baa6d764293a83d4e955b533e55b57e8e147 (patch) | |
tree | 77192e93b1cc164f4956a17acb042dfa0629a3c5 /tools | |
parent | 15e011e334099a9c0c6bc34399fb90769600210f (diff) | |
download | lua-language-server-bd51baa6d764293a83d4e955b533e55b57e8e147.zip |
update
Diffstat (limited to 'tools')
-rw-r--r-- | tools/love-api.lua | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/love-api.lua b/tools/love-api.lua index bb44c11c..5aec88e0 100644 --- a/tools/love-api.lua +++ b/tools/love-api.lua @@ -51,10 +51,14 @@ local function buildSuper(tp) return (': %s'):format(table.concat(parents, ', ')) end +local function buildDescription(desc) + return ('---%s'):format(desc:gsub('([\r\n])', '%1---')) +end + local function buildFunction(class, func, node) local text = {} text[#text+1] = '---' - text[#text+1] = ('---%s'):format(func.description:gsub('([\r\n])', '%1---')) + text[#text+1] = buildDescription(func.description) text[#text+1] = '---' local params = {} for _, param in ipairs(func.variants[1].arguments or {}) do @@ -108,6 +112,19 @@ local function buildFile(class, defs) end end + for _, tp in ipairs(defs.callbacks or {}) do + text[#text+1] = '' + text[#text+1] = ('---@type %s'):format(getTypeName(tp.name)) + end + + for _, enum in ipairs(defs.enums or {}) do + text[#text+1] = '' + text[#text+1] = ('---@class %s'):format(getTypeName(enum.name)) + for _, constant in ipairs(enum.constants) do + text[#text+1] = ('---@field %s integer # %s'):format(constant.name, constant.description) + end + end + text[#text+1] = '' fsu.saveFile(filePath, table.concat(text, '\n')) |