【问题标题】:How to document functions with JSDoc如何使用 JSDoc 记录函数
【发布时间】:2013-05-30 00:30:54
【问题描述】:

JSDoc 似乎没有接受我的大部分功能。这是一个例子:

/**
 * Function one.
 */
(function one() {
    /**
     * Function two.
     */
    function two() {
        /**
         * Function three.
         */
        function three() {
        }
    }
})();

var four = {
    /**
     * Function five/six.
     */
    five: function six() {
    },
    /**
     * Function seven/eight.
     */
    seven: function eight() {
    },
};

nine.ten = {
    /**
     * Function eleven/twelve.
     */
    eleven: function twelve() {
        /**
         * Function thirteen/fourteen.
         */
        var thirteen = function fourteen() {
        };
    },
    /**
     * Function fifteen/sixteen.
     */
    fifteen: function sixteen() {
    },
};

/**
 * Function eighteen
 */
seventeen(function eighteen() {
});

/**
 * Function twenty.
 */
nineteen(function twenty() {
    /**
     * Function twentyTwo.
     */
    twentyOne(function twentyTwo() {
    });
});

/**
 * Function twentyThree.
 */
function twentyThree() {
}

JSDoc 只使用函数二十三。其余的都完全错过了。

我做错了什么?

【问题讨论】:

  • 我以前从未使用过 JSDoc,但看了他们的文档,我不确定为什么你的任何东西都可以工作。我认为你需要回去阅读 JSDoc 的文档。例如,我认为four 应该记录为@namespace(对于您的 IIFE)。而且我认为你需要在特定的地方使用@name@lends

标签: javascript documentation standards documentation-generation jsdoc


【解决方案1】:

这是一个可以为您提供更多 JSDoc(3) 输出的示例:

/**
 * Function one.
 * @namespace one
 */
(function one() {
    /**
     * Function two.
     * @namespace two
     * @memberof one
     */
    function two() {
        /**
         * Function three.
         * @memberof one.two
         */
        function three() {
        }
    }
})();

【讨论】:

    猜你喜欢
    • 2015-07-12
    • 2012-08-12
    • 1970-01-01
    • 2017-11-05
    • 2011-12-25
    • 1970-01-01
    • 2015-02-10
    • 1970-01-01
    • 2013-12-09
    相关资源
    最近更新 更多