我有以下Moo课程:
Nem.Ui.Window = new Class({
Implements: [Options, Events],
options: {
caption: "Ventana",
icon: $empty,
centered: true,
id: $empty,
width: $empty,
height: $empty,
modal: false,
desktop: $empty,
x: $empty,
y: $empty,
layout: $empty
},
initialize: function(options)
{
this.setOptions(options);
/* ... */
},
setHtmlContents: function(content)
{
/* ... */
},
setText: function(text)
{
/* ... */
},
close: function(win)
{
/* ... */
},
/* ... */
});
我想用JsDoc记录下来.我读到您可以在新类中使用@lends [class] .prototype并使用@constructs标记标记initialize.如何标记此类方法和事件?
即:setHtmlContents应该是一个方法,close应该是一个事件.
另外,是否可以以某种方式记录选项下的元素?
解决方法:
您可以使用@function标记方法,并使用@event标记事件,但是由于默认情况下可以正确检测到函数,因此您无需使用@function标记.
选项下的元素可以用@memberOf记录,在您的示例中可以用@memberOf Nem.Ui.Window#记录.然后,它们将在生成的JSDoc中显示为options.optionName.
完整记录的课程版本类似于
/** @class This class represents a closabe UI window with changeable content. */
Nem.Ui.Window = new Class(
/** @lends Nem.Ui.Window# */
{
Implements: [Options, Events],
/** The options that can be set. */
options: {
/**
* Some description for caption.
* @memberOf Nem.Ui.Window#
* @type String
*/
caption: "Ventana",
/**
* ...
*/
icon: $empty,
centered: true,
id: $empty,
width: $empty,
height: $empty,
modal: false,
desktop: $empty,
x: $empty,
y: $empty,
layout: $empty
},
/**
* The constructor. Will be called automatically when a new instance of this class is created.
*
* @param {Object} options The options to set.
*/
initialize: function(options)
{
this.setOptions(options);
/* ... */
},
/**
* Sets the HTML content of the window.
*
* @param {String} content The content to set.
*/
setHtmlContents: function(content)
{
/* ... */
},
/**
* Sets the inner text of the window.
*
* @param {String} text The text to set.
*/
setText: function(text)
{
/* ... */
},
/**
* Fired when the window is closed.
*
* @event
* @param {Object} win The closed window.
*/
close: function(win)
{
/* ... */
},
/* ... */
});
我在初始化时跳过了@constructs,因为那时它根本不会出现在文档中,而且我还没有弄清楚如何使其正常工作.
有关可用标签及其功能的更多信息,请参见jsdoc-toolkit的wiki处的TagReference.