-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Identifiers in dartdocs with parens /// [functionName()]
do not generate navigation regions
#47553
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
@srawlins and @jcollins-g have been looking at making the analysis server and dartdoc more consistent. I don't know what dartdoc currently does with parens, but if it doesn't accept them then we ought to consider updating the Effective Dart docs. |
Parentheses are supported by dartdoc's syntax. It results in a "callable hint", which dartdoc uses in resolution to disambiguate constructors prior to tearoffs and |
Thanks for filing @DanTup . I personally prefer to remove the We could try to gather some data on how often we see My current plans are to add two features to comment references:
I'm happy to leave this open to consider supporting |
As far as I can tell, you're right that I'm ambivalent on the question about whether to continue supporting parens. It sounds like Dartdoc's need for then has probably been resolved, but on the other hand there might be legacy docs that are using them that might not get cleaned up quickly. |
@bwilkerson Yes, it has been mostly resolved with constructor tearoffs and |
I would support removing the parentheses recommendation from Effective Dart once constructor-tearoffs are in stable, possibly adding a section for how to refer to the unnamed constructor via |
@munificent For the discussion around Effective Dart. |
I've no opinion here (beyond thinking Effective Dart and the server should be consistent), so feel free to close this if the plan is just to remove the recommendation (and/or move it to track that) :-) |
I agree "Effective Dart" should only advocate something that actually works. :) For what it's worth, I personally do like using parentheses in doc comments to refer to functions because I think it's clearer to the reader what's being referred to. |
Hello! Just leaving my opinion here as a Dart user. |
As a different opinion, I don't like the parentheses. A link of I'd expect the content of the If you want to control what's inside the link text, I'd expect to use ``[ |
I don't know about for generated Dartdoc pages, but at least some of the discussion above relates to reading the raw source code in the editor (and being able to Ctrl+Click to jump to the related function). Using the example above does result in a clickable link on the second part - although I'm not sure if you meant |
Ah, I was thinking it should be a "reference style link", probably mixin Wiki-syntax with plain markdown. I guess a normal |
Ah, ofc, that probably does make more sense. We could potentially insert the signature automatically (as fake text, like the closing labels) although I'm not sure if the benefit would justify the effort in doing that (and the inserted text part wouldn't be clickable). |
To elaborate on what Janice wrote above, Dartdoc uses the trailing parens ( However, one is also allowed to declare an instance method with the same name as a constructor, in which case the parentheses would not, semantically, really disambiguate. We could just stick to a rule that "parens hint toward a constructor; no parens hint toward an instance member." 🤷 |
TIL! It always bugged me that I can't have static and instance members with the same name - that feels a little more odd given constructor names seem exempt :-) I think using the parens as only a hint and not a rule would be better though. It seems odd to require parens when there's no ambiguity. It also seems a little odd that I can't use parens on a function. |
I think we're suggesting the same thing 😄 . I wouldn't suggest requiring parens broadly. Just that, in the handful of cases in the universe where a class has a constructor and instance member with the same name, and you really want to refer to them in doc comments, |
About the colouring, here in this comment you can see that the ![]() From #59910 (comment), I feel like this is a good place to point out about the missing docs on this:
|
Dots are actually uncoloured in the editor too: We only add semantic tokens to the class name and member name so they're just the default surrounding colour (which in the editor is nothing, so it's the default color from the theme). We could perhaps use the custom "reset" token we use in interpolation to reset the colours, which would make them the same default colour as the editor - although it may rely on knowing where they are (I'm not sure if we currently get a range for "int.parse" here, or just two isolated ranges for "int" and "parse"). |
One more thing I'm not sure it should work but things like |
It does not work; the request for that feature is #47444. |
This came up at Dart-Code/Dart-Code#3611 and I was going to look at fixing in the analysis_server, but I think it may require parser changes (@bwilkerson?).
In the Effective Dart docs in the description of identifiers in doc comments it says:
However given this code:
The second reference does not generate a navigation target, so cannot be used to navigate to the function. I don't know if including parens is common, but since the docs suggest they're useful, it seems like this should work.
@bwilkerson I had a look thinking this might be something handled in the server, but I ended up in
/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart
(parseCommentReferencesInText
) so perhaps it needs supporting there (I'm less certain of the implications of making changes there, although happy to have a go if it should be straight-forward).The text was updated successfully, but these errors were encountered: