如何让@borrows 标签在 JSDoc 中工作

McS*_*man 7 jsdoc

我一直很难让 @borrows 标签在 JSDoc 中工作。我一直试图从一个函数中获取文档,并将其作为第二个函数的文档。但我似乎甚至无法让一个简单的例子工作!

/**
 * This is the description for funcA
 */
var funcA = function() {};

/**
 * @borrows funcA as funcB
 */
var funcB = function() {};
Run Code Online (Sandbox Code Playgroud)

我希望这会为两个函数输出完全相同的文档。但是只有 funcA 才有描述。

P.T*_*.T. 4

该@borrows标签似乎不能直接作用于符号,而只是间接作用。例如我有:

/** does amazing things */
function origFunc = function() {};

/**
 * @borrows origFunc as exportedFunc
 */
exports.exportedFunc = origFunc;
Run Code Online (Sandbox Code Playgroud)

但我和你一样,在生成的文档中没有得到任何有用的东西。

这是因为,标签似乎是在容器@borrows上运行的。(如果您在示例中注意到标记位于“util”模块/命名空间上,而不是重命名的符号上。)@borrows

所以这对我有用:

/** does amazing things */
function origFunc = function() {};

/**
 * @borrows origFunc as exportedFunc
 */
exports = {
  exportedFunc: origFunc,
}
Run Code Online (Sandbox Code Playgroud)

看起来像是一个错误@borrows。(或者至少是文档中的错误。)