Search code examples
javascriptdocumentationjsdoc

How to document javascript IIFE modules in JSDoc


I'm trying to figure out how to comment it correctly using 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
    }
})();

I'm doing it this way, but generated document looks terrible. I can not rewrite this part of the code to the ES6 standard. Can you please advice?


Solution

  • After some trying ai found @memberof

    You can use it like this:

    @memberof module:YourModuleName
    

    Do not know, if it is correct, but after that I saw that method is showed in my module doc. page.