I have some classes which follow the "Factory Constructor" pattern. These are constructed by calling the factory, not using the new
keyword.
Example:
/**
* Example "Factory Constructor" class
* @class
*/
function MyClass() {
return /** @lends MyClass.prototype */ {
/** One method */
method1: function() { },
/** Another Method */
method2: function() { }
};
}
Also note that the name of the factory is the same as the name of the class (as distinct from something like a static method MyClass.create()).
My problem is that jsdoc keeps insisting on documenting that this class should be constructed with 'new', eg:
I've looked at various other questions (such as this one and this one) and blog posts (eg. this one) but none of them have addressed this specific issue.
I've also tried a few variations, such as
/**
* Example "Factory Constructor" class
* @name MyClass
* @constructs
*/
Outcome: results in the same output as above
Documenting MyClass as a static function like this:
/**
* Example "Factory Constructor" class
* @static
*/
Outcome: MyClass disappears as a class altogether and is only shown as a function, probably as you would expect.