-
Notifications
You must be signed in to change notification settings - Fork 1.7k
public_member_api_docs should not require docs for trivial constructors #57361
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
Comments
We should still say something. And that something shouldn't be trivial. For example, it should talk about whether bar or baz can be null, what requirements there are on their values, what constructing one of these objects implies, what the lifecycle will be, whether you're required to dispose of the object, whether the object is 'const', etc. |
These would be documented in the respective fields' doc comments.
These would be documented in the class' doc comment.
The constructor must have the Flutter can require to document every constructor in its own code base. In general though, requiring it is more likely to lead to filler doc comments than good documentation. If enough projects consider documenting trivial constructors important, then perhaps the linter could provide more knobs, e.g. |
I agree that relevant documentation should also be in the field docs, and indeed in some cases in the class docs. But it should also be in the constructor docs. The constructor docs are what you see in your IDE when you're typing the constructor, for instance. Users shouldn't have to chase down every last reference just to know how to use a constructor. A class can have a mix of const constructors and non-const constructors. In that case, it can be useful for the non-const constructors to discuss the const constructors and describe the implications of using one instead of the other. I agree that we shouldn't have filler docs. (Filler docs are a violation of Flutter' style guide.) I'm fine with having more knobs. My concern here is only over whether we are able to configure Flutter's analysis the way we want it to get good results. |
Another option (not supported yet) would be to make the lint parametric. Then we could say something like:
But anyway... Focusing on the now, it'd be great to get a sense for what we need to do minimally to make @yjbanov, @Hixie : is changing this behavior a blocker for flutter? |
No, the current situation is workable for us. |
Cool. Thanks. |
I like the parametric option. |
Any plans for considering this?
As @yjbanov mentioned, it could be documented, but even nowadays we have Sound null safety, where we strictly indicate whether or not a value can be null, so it's no longer necessary to document such case. While it sometimes might be interesting to document more complex constructors, for most of the cases we already know what they will do. I also think that the parametric solution would be desirable 🤞 |
I don't think there is good consensus on any new rules here, except that configurability would be good :) |
There are situations when doc comments are not useful in a constructor:
The following is common in classes used as annotations:
Even when the constructor has parameters, if the parameters assign to public fields that are documented, there isn't much to say in the constructor:
@pq @Hixie
The text was updated successfully, but these errors were encountered: