Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How Do I Document an Overloaded Constructor #1017

Closed
gf3 opened this issue May 31, 2015 · 5 comments
Closed

How Do I Document an Overloaded Constructor #1017

gf3 opened this issue May 31, 2015 · 5 comments

Comments

@gf3
Copy link

gf3 commented May 31, 2015

It's not clear in the docs, I'm trying the following but it's only showing the last definition:

/**
 * DateRange class to store ranges and query dates.
 *
 * @constructor
 * @param {(Moment|Date)} start Start of interval
 * @param {(Moment|Date)} end End of interval
 */
/**
 * DateRange class to store ranges and query dates.
 *
 * @constructor
 * @param {!Array} range Array containing start and end dates.
 */
/**
 * DateRange class to store ranges and query dates.
 *
 * @constructor
 * @param {!String} range String formatted as an IS0 8601 time interval
 */
function DateRange(start, end) {
  // ...
}
@hegemonic
Copy link
Contributor

You need to nestle the start and end of each comment together like so:

/**
 * DateRange class to store ranges and query dates.
 *
 * @constructor
 * @param {(Moment|Date)} start Start of interval
 * @param {(Moment|Date)} end End of interval
 *//**
 * DateRange class to store ranges and query dates.
 *
 * @constructor
 * @param {!Array} range Array containing start and end dates.
 *//**
 * DateRange class to store ranges and query dates.
 *
 * @constructor
 * @param {!String} range String formatted as an IS0 8601 time interval
 */
function DateRange(start, end) {
  // ...
}

(In the future, if you have questions, please email the jsdoc-users mailing list. The GitHub issue tracker is for bug reports and feature requests. Thanks!)

@dasa
Copy link
Contributor

dasa commented Jun 2, 2015

The members of the class are repeated for each constructor though. Is that a bug?

@gf3
Copy link
Author

gf3 commented Jun 2, 2015

@hegemonic perhaps this is actually a bug, because nestling them doesn't seem to do anything. the following code:

/**
 * DateRange class to store ranges and query dates.
 *
 * @constructor
 * @param {(Moment|Date)} start Start of interval
 * @param {(Moment|Date)} end End of interval
 *//**
 * DateRange class to store ranges and query dates.
 *
 * @constructor
 * @param {!Array} range Array containing start and end dates.
 *//**
 * DateRange class to store ranges and query dates.
 *
 * @constructor
 * @param {!String} range String formatted as an IS0 8601 time interval
 */
function DateRange(start, end) {
  var parts;
  var s = start;
  var e = end;

  if (arguments.length === 1 || end === undefined) {
    if (start.length === 2) { // Infer array
      s = start[0];
      e = start[1];
    }
    else {
      parts = start.split('/');
      s = parts[0];
      e = parts[1];
    }
  }

  this.start = moment(s);
  this.end   = moment(e);
}

generates the following documentation (i.e. only the first example):

screen shot 2015-06-02 at 1 23 22 pm

using jsdoc 3.3.0

@gf3
Copy link
Author

gf3 commented Jun 2, 2015

you can view the generated documentation here.

@hegemonic
Copy link
Contributor

@gf3 Scroll down and you'll see the other constructors. As @dasa noted, the members are repeated once per constructor.

@dasa, the current behavior is certainly not ideal. Feel free to file a new bug or send a pull request.

@jsdoc jsdoc locked and limited conversation to collaborators Jun 7, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants