-
Notifications
You must be signed in to change notification settings - Fork 124
Comment references to unnamed constructors do not match Dart code #1850
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
The first bullet point seems reasonable, although I don't know if there are existing references looking like that that are intended to refer to the class documentation. Dartdoc strips extraneous things like "new " and "()" because it is considered rare to refer to the unnamed constructor. Usually, the class documentation is what people seem to want. If the |
adding @kwalrath, given the report that the () does not work as advertised on Effective Dart. |
We definitely want to be able to refer to constructors (including unnamed one, which we sometimes refer to e.g. from named ones, or from properties, to say "hey look at the guidance on the argument to the constructor", etc). I admit I never tested whether that worked... |
@Hixie You can do so now (and it is done this way in parts of the docs) with |
The documentation for the comment_references lint also claims that
|
With constructor tearoffs, the new canonical way to reference an unnamed constructor is with |
https://github.com/dart-lang/dartdoc/wiki/dartdoc-comment-references hasn't been updated and still refers to |
I just tried this again (using dart 2.16.2), and all of the following now do generate references to the unnamed constructor:
And in all cases, the string within the square brackets is shown verbatim in the generated documentation. |
A specific case for #1663: The Effective Dart guidelines claim:
I just tested this with dartdoc 0.24.1 from the Dart 2.1 SDK, and the unnamed constructor reference doesn't seem to work; it links to the class instead.
https://github.com/dart-lang/dartdoc/wiki/dartdoc-comment-references instead says to use
[MyClass.MyClass]
to reference the unnamed constructor. That does work, but the generated documentation literally hasMyClass.MyClass
, which looks weird since that's not what anybody uses in code. Can we do one (or both) of:[MyClass()]
refer to the unnamed constructor as claimed by Effective Dart? (Or, less desirably, fix the false claim by Effective Dart.)[MyClass.MyClass]
show up asMyClass
(orMyClass()
) in the generated documentation??
The motivation for this was my attempt at removing lingering
new
usage in Flutter API documentation, which was used to disambiguate references to classes from references to constructors (flutter/flutter#24625).The text was updated successfully, but these errors were encountered: