MooTools类和JsDoc

Joe*_*ldi 3 javascript documentation mootools class jsdoc

我有以下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)
    {
        /* ... */
    },

    /* ... */
});
Run Code Online (Sandbox Code Playgroud)

我想用JsDoc记录它.我读过你可以@lends [class].prototype在里面使用new Classinitialize@constructs标记标记.我如何标记方法和事件?

IE:setHtmlContents应该是一个方法,close应该是一个事件.

此外,可以用options某种方式记录下的元素吗?

Yin*_*ang 5

您可以使用@function和事件标记方法@event,但由于默认情况下正确检测到函数,因此@function在您的情况下不需要标记.

在您的示例中,options可以记录下面的元素.然后它们将在生成的JSDoc中显示.@memberOf@memberOf Nem.Ui.Window#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)
    {
        /* ... */
    },

    /* ... */

});
Run Code Online (Sandbox Code Playgroud)

我已经跳过了它@constructs,initialize因为它根本不会出现在文档中,我还没弄清楚如何让它正常工作.

有关可用标签及其功能的更多信息,请参阅TagReference维基的jsdoc的工具包中.