sagittarian
sagittarian

Reputation: 1104

How do document a class that is returned from a function call with jsDoc

I have a large existing Javascript codebase, most of which is organized in classes created by a custom library. Most of it is similar to this:

/** 
 * @memberOf nameSpace.subNameSpace1
 * @class 
 */
nameSpace.subNameSpace1.ClassName1 = nameSpace.subNameSpace2.ClassName2.subClass({
  ctor: function () {

  },

  /**
   * method1 is a special method that does special things.
   * @param config {Object}
   * @returns {Boolean}
   */
  method1: function (config) {
  },

  method2: function () {
  }
})

The subClass method is defined on the Object prototype and creates a class that inherits from the object it's called on. I want to document the methods of classes that are created in this way, but unfortunately documentation like above documentation for method1 is not picked up by jsDoc (the documentation for the class itself works fine). How can I document these methods in a way that jsDoc will understand?

Upvotes: 1

Views: 250

Answers (1)

sagittarian
sagittarian

Reputation: 1104

It turns out that using the latest version of jsdoc from npm solved the problem, and it recognizes that these methods are part of the given class if properly annotated with @function

Upvotes: 1

Related Questions