summaryrefslogtreecommitdiff
path: root/script/plugins
diff options
context:
space:
mode:
authorPaul Emmerich <tandanu@deadlybossmods.com>2024-01-28 13:08:48 +0100
committerPaul Emmerich <tandanu@deadlybossmods.com>2024-01-28 13:08:48 +0100
commit1a1e671b0abd0380d4bd02f7adabda023bda9a64 (patch)
tree67b7e7ee059a1fcdc11fd44e76a6ceb079a2a8dd /script/plugins
parent9185dfad1286942b4914657e4c0e9ad28cb2aaa8 (diff)
downloadlua-language-server-1a1e671b0abd0380d4bd02f7adabda023bda9a64.zip
Add group param for luadoc generated by plugins
This allows binding multiple generated luadoc annotations to a single node easily by explicitly specifying their bind group.
Diffstat (limited to 'script/plugins')
-rw-r--r--script/plugins/astHelper.lua23
1 files changed, 18 insertions, 5 deletions
diff --git a/script/plugins/astHelper.lua b/script/plugins/astHelper.lua
index 506f5e92..bfe2dd27 100644
--- a/script/plugins/astHelper.lua
+++ b/script/plugins/astHelper.lua
@@ -23,14 +23,27 @@ end
---@param ast parser.object
---@param source parser.object local/global variable
---@param classname string
-function _M.addClassDoc(ast, source, classname)
+---@param group table?
+function _M.addClassDoc(ast, source, classname, group)
+ return _M.addDoc(ast, source, "class", classname, group)
+end
+
+--- give the local/global variable a luadoc comment
+---@param ast parser.object
+---@param source parser.object local/global variable
+---@param key string
+---@param value string
+---@param group table?
+function _M.addDoc(ast, source, key, value, group)
if source.type ~= 'local' and not guide.isGlobal(source) then
return false
end
- --TODO fileds
- --TODO callers
- local comment = _M.buildComment("class", classname, source.start - 1)
- return luadoc.buildAndBindDoc(ast, source, comment)
+ local comment = _M.buildComment(key, value, source.start - 1)
+ local doc = luadoc.buildAndBindDoc(ast, source, comment, group)
+ if group then
+ group[#group+1] = doc
+ end
+ return doc
end
---remove `ast` function node `index` arg, the variable will be the function local variable