Is there a way to prepend the namespace to the constructor in JSDoc? - e.g. new foo.Bar()

15 views Asked by At

I've been building out a project using rigorous JSDoc comments for the dual-benefit of intellisense and getting some documentation built out. The project uses pre-ES5 and pre-module logic for how everything is set up:

  • All of our classes are stored under a namespace, we'll call it ct for the sake of the question.
  • If we declare a Checkbox class under the ct namespace, it would be initialized with a call of new ct.Checkbox(opts)

I've figured out how to handle all the quirks related to my project structure except for one: JSDoc outputs the constructor in documentation as new Checkbox, which does not match the implementation. So my question is:

How can I include the namespace prefix in the outputted constructor? Can I accomplish this somehow with a tag I include on the constructor function? Would I need to make a custom JSDoc template that does this for me? Would I need to combo the markup plugin and @hideconstructor tags to ham-fistedly replicate this?

The format of the Checkbox class looks something like this:

/**
 * @memberof ct
 * @class
 * @classdesc A checkbox input entity
 * @extends ct.Base
 *
 * @param opts {ct.Checkbox#Options}
 */
ct.Checkbox = function(opts) { ct.Init(this, arguments); };
ct.Checkbox.prototype = ct.Inherit(ct.Base, /** @lends ct.Checkbox.prototype */ {
    /** @type string */ _id: null,
    /** @type boolean */ _value: null,

    ...

});

This leads to this (snipped) picture of the JSDoc output: JSDoc output snippet

As you can see (hopefully... I've been having weird cert issues with imgur lately), the ct prefix is entirely missing from the constructor, as well as the class' name. I would like to prefix the name with the namespace as well, but that's relatively minor compared to the constructor.

0

There are 0 answers