[英]Documenting functions contained in Objects with JSDoc
I'm looking for a way to document functions contained in a Dictionary in Javascript with JSDoc 3. 我正在寻找一种使用JSDoc 3记录Javascript词典中包含的函数的方法。
Even though I tell JSDoc there is a function with @function
, it is not included in the generated documentation. 即使我告诉JSDoc有一个带有@function
的函数,它也不包含在生成的文档中。
Is there a JSDoc tag that could help? 是否有可以帮助您的JSDoc标签? Or is there a more convenient approach than mine? 还是有比我更方便的方法?
Thanks 谢谢
/**
* @namespace Minitel
*/
var Minitel = Minitel || {}
/**
* @callback actionCallback
* @param {Stream} stream The Minitel Stream to which add the Videotex codes
* @param {Object} data Data object
* @param {?number} offsetX X offset
* @param {?number} offsetY Y offset
*/
/**
* Action callbacks
* @member {Object.<string, actionCallback>}
*/
Minitel.actions = {}
/**
* Handles "content-string" actions. The value should already be ready to be
* sent in the stream.
* @function
*/
Minitel.actions["content-string"] = function(stream, data) {
/* ... */
}
/**
* Handles "content-block" actions. It only supports left, center and right
* alignment.
* @function
*/
Minitel.actions["content-block"] = function(stream, data, offsetX, offsetY) {
/* ... */
}
I'm using jsdoc -p -c jsdoc.json app/*.js library/minitel/*.js
to generate the documentation 我正在使用jsdoc -p -c jsdoc.json app/*.js library/minitel/*.js
生成文档
Here is jsdoc.json
: 这是jsdoc.json
:
{
"plugins": ["plugins/markdown"],
"opts": {
"template": "../docdash"
}
}
I am not sure (as jsdoc is not verbose sometimes) but it looks like @member
can not have children. 我不确定(因为jsdoc有时不是很冗长),但看起来@member
不能有孩子。 A solution can be to use @namespace
. 一个解决方案可以是使用@namespace
。
So your actions
will be documented as follows: 因此,您的actions
将记录如下:
/**
* Action callbacks
* @namespace
*/
One issue with @namespace
is that you cannot define a type for it. @namespace
一个问题是您无法为其定义类型。 But in this case all methods are documented even without @function
as static ones. 但是在这种情况下,即使没有@function
作为静态方法,也记录了所有方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.