如何用LuaDoc记录一个闭包?

如何用LuaDoc记录一个闭包?,lua,luadoc,Lua,Luadoc,假设我有一个返回闭包的函数: --- Agent constructor -- @return A function describing the behavior of the agent Agent = function(data) return function(arg1, arg2, ...) end end 然后我有一个变量来接收闭包: SugarAgent = Agent{ metabolism=5, health=3 } LuaDoc中是否有记录上述构造的标准方法?您可以

假设我有一个返回闭包的函数:

--- Agent constructor
-- @return A function describing the behavior of the agent
Agent = function(data)
   return function(arg1, arg2, ...) end
end
然后我有一个变量来接收闭包:

SugarAgent = Agent{ metabolism=5, health=3 }

LuaDoc中是否有记录上述构造的标准方法?

您可以通过手动指定文档名称和类型来实现:

--- This is a SugarAgent
-- @name SugarAgent
-- @class function
-- @return Some value
SugarAgent = Agent{ metabolism=5, health=3 }

请看

如果我试图记录AgentsGar函数,您能举个例子说明doc会做什么,但是您的答案与我想要的非常接近。对不起,它实际上是
@class
,而不是
@type
(请参阅)。有人试图用正确的信息编辑帖子,但编辑被拒绝,因为它“不正确”。叹气。