ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

javascript-MooTools类和JsDoc

2019-10-24 04:36:28  阅读:272  来源: 互联网

标签:mootools jsdoc javascript class documentation


我有以下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.

标签:mootools,jsdoc,javascript,class,documentation
来源: https://codeday.me/bug/20191024/1917872.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有