How to get @borrows tag working in JSDoc

℡╲_俬逩灬. 提交于 2019-12-07 11:43:55

问题


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() {};

I was expecting this to output documentation for both functions with both exactly the same. However only funcA is only has a description.


回答1:


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.

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.)

So this worked for me:

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

/**
 * @borrows origFunc as exportedFunc
 */
exports = {
  exportedFunc: origFunc,
}

Seems like a bug in @borrows though. (Or at least a bug in the documentation.)



来源:https://stackoverflow.com/questions/29726993/how-to-get-borrows-tag-working-in-jsdoc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!