Get JSDoc to properly document nested closures

I have a large, well-structured JavaScript object that looks something like this:

/**
 * My 'class' begins here.  JSDoc barfs on this.
 */
var MyClass = (function(window, document, $) {

    return function(options) {

        "use strict";

        var
            x = 123,

            /**
             * This is a "public" function.
             */
            myFunc = function() { /*...*/ },

            /**
             * This is some other "private" function.
             */
            otherFunc = function() { /*...*/ };

        return {
            myFunc: myFunc
        };
    };

})(window, document, window.jQuery);

Essentially, outer closure is used to control the global scope visible by the inner closure, which implements the form of the module template: the inner function is actually a constructor, and its nested functions are efficient methods, and the returned object is actually a list of which parts of it are “public” .

JSDoc hates this.

(For recording, I use JSDoc 3.4.)

@lend @export @namespace @memberof , , , JSDoc - - " "; .

JavaScript, , , . JavaScript : .

JSDoc , JSDoc , , . StackOverflow , jane JavaScript, .

- JSDoc MyClass "class", "" ""? otherFunc @private -, , myFunc @public -, , , , JSDoc , .

+4

Source: https://habr.com/ru/post/1653200/


All Articles