如何在JSDoc中记录JavaScript IIFE模块

4

我正在尝试通过JSDoc3正确地注释它。

/**
 * Module ...
 *
 * @module Cookie
 * @returns {{create, get, remove}}
 */
const cookie = (function () {

    /**
     * Function to create cookie.
     *
     * @param {String} name - The cookie name.
     * @param {String} value - The cookie value.
     * @param {Boolean} elongate - The flag to extend cookie lifetime.
     */
    const create = (name, value, elongate) => {
    ...
    };

    /**
     * Function to get cookie.
     *
     * @param {String} key - The cookie identificatior to get.
     * @returns {*}
     */
    const get = (key) => {
    ...
    };

    /**
     * Function to remove cookie.
     *
     * @param {String} key - The cookie identificator to remove.
     */
    const remove = (key) => {
    ...
    };

    return {
        create: create,
        get: get,
        remove: remove
    }
})();

我这样做,但生成的文档看起来很糟糕。我不能将此部分代码重写为ES6标准。你能给些建议吗?

2
我也很想知道,似乎 IIFE 内部的所有内容都被忽略了。 - Goowik
1个回答

3

经过一些尝试,我找到了@memberof

你可以像这样使用它:

@memberof module:YourModuleName

不知道是否正确,但在我的模块文档页面中看到了该方法展示。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接