如何让@borrows标记在JSDoc中工作 [英] How to get @borrows tag working in JSDoc
问题描述
我一直很难让@borrows标记在JSDoc中工作.我一直在尝试从一个功能获取文档,而将其作为第二个功能的文档.但是我似乎甚至无法获得一个简单的示例!
I have been having a hard time getting the @borrows tag working in JSDoc. I have been trying to get the documentation from one function and us it as documentation for a second function. But I don't seem to be able to even get a simple example working!
/**
* This is the description for funcA
*/
var funcA = function() {};
/**
* @borrows funcA as funcB
*/
var funcB = function() {};
我期望这会输出两个功能完全相同的文档.但是,只有funcA仅具有描述.
I was expecting this to output documentation for both functions with both exactly the same. However only funcA is only has a description.
推荐答案
@borrows
标记似乎不能直接作用于符号,而只能间接作用.例如,我有:
The @borrows
tag doesn't seem to work directly on a symbol, but only indirectly. For example I had:
/** does amazing things */
function origFunc = function() {};
/**
* @borrows origFunc as exportedFunc
*/
exports.exportedFunc = origFunc;
但是我和您一样,在生成的文档中没有任何有用的信息.
but I, like you, got nothing useful in the generated doc.
这是因为@borrows
标签似乎在容器上运行. (如果您在示例中注意到@borrows
标记位于"util"模块/命名空间上,而不位于重命名的符号上.)
That is because, it seems, that the @borrows
tag operates on a container. (If you'll notice in the examples the @borrows
tag is on the "util" module/namespace, not the renamed symbol.)
所以这对我有用:
/** does amazing things */
function origFunc = function() {};
/**
* @borrows origFunc as exportedFunc
*/
exports = {
exportedFunc: origFunc,
}
虽然看起来像@borrows
中的错误. (或者至少是文档中的错误.)
Seems like a bug in @borrows
though. (Or at least a bug in the documentation.)
这篇关于如何让@borrows标记在JSDoc中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!