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

Support standard class constructor JSDoc #1091

Open
jaydenseric opened this issue Jun 12, 2018 · 3 comments
Open

Support standard class constructor JSDoc #1091

jaydenseric opened this issue Jun 12, 2018 · 3 comments

Comments

@jaydenseric
Copy link
Contributor

The way that documentation.js forces us to document classes is incorrect:

/**
 * A foo.
 * @param {*} value Value.
 */
class Foo {
  constructor(value) {
    this.value = value
  }
}

Here is the standard way:

/**
 * A foo.
 */
class Foo {
  /**
   * Constructs a new foo.
   * @param {*} value Value.
   */
  constructor(value) {
    this.value = value
  }
}

Attempting to use the standard approach will result in documentation not appearing, or the constructor docs take over the class description.

Not only is the documentation.js way unintuitive and a common gotcha, but it causes problems using JSDoc linters that expect a standard approach. This ESLint config will report an error that the constructor is missing JSDoc:

{
  "rules": {
      "require-jsdoc": ["error", {
        "require": {
          "ClassDeclaration": true,
          "MethodDefinition": true
        }
      }]
    }
}

There is no way to configure the ESLint require-jsdoc to ignore constructor. You can't use normal eslint ignore rule directive comments (// eslint-disable-next-line require-jsdoc) as a workaround due to #1090. You're just stuck 😔

As part of a fix:

Related:

@balupton
Copy link

balupton commented Jul 11, 2018

I was wondering why my constructor wasn't being outputted in all the documentation. This explains it.

I really hope this can get fixed.

@Berkmann18
Copy link

Berkmann18 commented Nov 13, 2018

@balupton Same here, I was oblivious as to why the documentation wasn't showing anything from the constructor's doclet when it was valid.

@tmcw
Copy link
Member

tmcw commented Nov 13, 2018

Please peruse the current maintenance status. I eagerly review and merge PRs, so the way to get this done is by doing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants