-
Notifications
You must be signed in to change notification settings - Fork 482
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
Treat constructor method as proper constructor of an object #689
Comments
This is exactly what i would of expected as well also if the constructor is not defined but class is extended should pull in the def from the parent class |
yeah I'm getting the same issue. is there something we should be doing that we aren't? |
This is a known issue - so far documentation doesn't do any special treatment of |
I have been working on my own theme that does additional processing of the json i will release the theme once completed, but I believe this additional processing should be done befre the theme stage |
Q: Should you document a class like:
Or
I'm leaning toward the former, and trying an implementation now. |
Okay: I have a working branch that does the following:
|
I would have preferred to document the parameters on the constructor. Putting it on the class is just more out of bounds and more likely to get out of sync. (But personally I do not document parameters and just let the inference do it's work.) |
Do other folks feel that way? The reason why I opted for documenting them on the class was mostly that documenting them at the class level felt like the more natural way to express all the documentation in one place, rather than running into the weird case where you have a description at the class level and param details near the constructor and they're combined, and, following that thought, cases where people use params at the class level and also at the constructor level, or descriptions on both. Handling that indecision / merging potentially conflicting details seemed like a source of uncertainty that could be avoided, but maybe it's outweighed by the directness of params sitting near their code position? |
Just to chime in here as one random opinion, I personally prefer putting the constructor parameter documentation above the constructor and the class property documentation above the class as @arv describes. I find this easier to read and maintain, especially when the arguments don't necessarily align with the properties, for example: /**
* A widget object which is used to blah blah blah.
*
* @property {HTMLElement} element - The containing element of the widget.
*/
class Widget {
/**
* Instantiate a widget object.
*
* @param {string} selector - The string selector for the element.
*/
constructor(selector) {
this.element = document.querySelector(selector);
}
} I guess this all comes down to personal preference though. |
In my current use case, I don't want the constructor documented - nor its parameters - because the class is never instantiated by the user (with a kind of factory pattern). Seems like even if I |
Any updates on this? |
At least for me, I've been taking a break from day-to-day work on this project in hope that other folks will join and contribute - so no updates from my side. But contributions / PRs would be incredibly welcome! |
With this minimal class:
Running
node_modules/.bin/documentation serve doc.js
produces the following output with 4.0.0-beta.18:I would expect the constructor not to be displayed as an instance method and it's parameters included in the instantiation example.
The text was updated successfully, but these errors were encountered: