Documenting a private constructor using JSDoc

I have a class in which individual methods can be called statically, but will return a new instance of the class for the chain, for example:

var builder = ns .setState('a', 'A') .setState('b', 'B'); 

Where Builder is defined as such:

 /** * @module Builder */ /** * @class Builder */ /** * @private */ function Builder() { this.state = { query: {} }; } Builder.prototype = { /** * @param {string} k - The key * @param {object} v - The value * @return {Builder} */ setState: function(k, v) { var that = (this instanceof Builder) ? this : new Builder(); that[k] = v; return that; } // Other properties and methods… } 

The Builder constructor should never be explicitly called by user code, and therefore I would like it to not appear in documents. However, all the combinations that I tried to use with JSDoc tags (e.g. @constructs , @constructs , etc.) seem to be unable to suppress it from inline documents.

+7
javascript private constructor jsdoc
source share
1 answer

You can use the @ignore directive to achieve this. From the docs:

The @ignore tag indicates that the character in your code should never appear in the documentation. This tag takes precedence over all others.

http://usejsdoc.org/tags-ignore.html

+2
source share

All Articles