I've got a class where individual methods may be called statically but will return a new instance of class in order to 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 is never supposed to be called explicitly by user code and thus I'd like it not to show up in the docs. However, all of the combinations I've tried with JSDoc tags (e.g. @private
, @constructs
, etc.) can't seem to suppress it from the built docs.
From version 3.5.0 of jsDoc, you can use tag @hideconstructor on the class, telling jsDoc
not to include the constructor into documentation.
/**
* @class Builder
*
* @hideconstructor
*/
function Builder() {
// implementation
}
You should be able to use the @ignore
directive to achieve this. From the docs:
The
@ignore
tag indicates that a symbol in your code should never appear in the documentation. This tag takes precedence over all others.
http://usejsdoc.org/tags-ignore.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With