-
Notifications
You must be signed in to change notification settings - Fork 1.7k
dartdoc is confusing on getters/setters #2798
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
(not sure the best area -- but most bugs seem to be in Area-Site.) Removed Component-Docs label. |
Yes, this came up in the hackathon, very confusing to people. Unclear how to use setter. void set onConnection(void callback(Socket socket)) People wanted to do this: onConnection((Socket socket) => doStuff()); Instead they need to do this: onConnection = (Socket socket) => doStuff(); What about formatting the docs like: void set onConnection = void callback(Socket socket) with a doc comment like cc @munificent. |
This is confusing to me because it looks like it's trying to be Dart syntax, but isn't. It's neither how setters are declared or invoked. I've talked about this with Jacob a bit. The ideal solution is that we will document getters and setters exactly as if they were fields. To a consumer of the API, there is no difference between fields and getters/setters, so there shouldn't be in the docs. The problem is that the Dart language currently allows you to do things with getters and setters that you can't do with fields. For example, the getter and setter can have different types. Or you can have a setter with no getter. Given that getters and setters each have their own docs (because they are defined separately), it also isn't clear which dartdoc would be used if we joined them into a single field-like entry in the generated docs. The last we talked about it, the plan was to document getters/setters like fields when possible (i.e. when the types match and there is a getter) and then fallback to something like the current system when it isn't. But I don't know when I'll get around to doing this. What I'd really like is a better syntax for defining getters and setters in the language so that these problems are avoided, but I don't think that's a priority for Lars and co. |
Good point, it's not exactly Dart syntax. I think treating like fields is a good compromise, as the use case for getters/setters is "you can refactor from fields". |
Removed Area-Site label. |
e.g. http://api.dartlang.org/io/ServerSocket.html
This was causing confusion at the hackathon, especially because of the inline function type
The syntax matches how they are declared, but not how they're used.
It'd be nice to either show the usage form too, or choose a neutral form that looks more like a field.
The text was updated successfully, but these errors were encountered: