I have a special JS revealing module pattern like in the example below and I am trying to document using JSDoc 3.
The situation is similar to this and this, but my constructor has arguments and there isn't a prototype root variable.
If I put @class in My Module along with @param for config, which seems to be the most correct alternative, it works fine (description, author and dependencies are properly written) but I have to put @instance/@memberof/@name in every prototype member, which is pretty annoying.
If I put @constructor in Constructor every member is properly recognized but the constructor is documented twice.
Then if I remove @class from My Module, the description, @author and @requires never appears. Putting @lends in My Module and @constructs in Constructor produces the same effect.
Changing the code is not a option, it is a widely used pattern in my company.
How to proceed?
var Root = window.Root || {};
/**
* My module
*
* @author ...
* @requires DependencyOne
* @requires DependencyTwo
*/
Root.MyModule = (function(DepOne, DepTwo) {
var _private = {/*...*/};
/**
* Constructor
*
* @param {Object} config
* @param {String} config.prop
*/
function MyModule(config) {
this.config = config;
}
/**
* My attribute
*
* @type {String}
*/
MyModule.prototype.myAttribute = null;
/**
* My function
*
* @param {String} param
* My parameter
*/
MyModule.prototype.myFunction = function(param) {/*...*/}
return MyModule;
})(DependencyOne, DependencyTwo);
Solution: After some tests I figured out how to proceed, using @class
/@constructor
and @memberof
:
var Root = window.Root || {};
Root.MyModule = (function(DepOne, DepTwo) {
var _private = {/*...*/};
/**
* Constructor.
*
* @constructor
* @memberof Root
*
* @requires DependencyOne
* @requires DependencyTwo
*
* @param {Object} config My config
* @param {String} config.prop Property
*/
function MyModule(config) {
this.config = config;
}
/**
* My attribute
*
* @type {String}
*/
MyModule.prototype.myAttribute = null;
/**
* My function
*
* @param {String} param
* My parameter
*/
MyModule.prototype.myFunction = function(param) {/*...*/}
return MyModule;
})(DependencyOne, DependencyTwo);