Skip to content
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

Dartdoc didn't complain about invalid reference #3661

Open
goderbauer opened this issue Feb 16, 2024 · 4 comments
Open

Dartdoc didn't complain about invalid reference #3661

goderbauer opened this issue Feb 16, 2024 · 4 comments
Labels
P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@goderbauer
Copy link
Contributor

See https://github.com/flutter/flutter/pull/143588/files.

I would have expected that the following doc comment generates a dartdoc error because "SnackBarAction." (note the dot at the end) is not a valid reference. Instead, it silently interprets [SnackBarAction.] as [SnackBarAction] and links to the class. So, we totally missed, that the reference was incomplete.

/// Overrides default value for [SnackBarAction.].
@goderbauer
Copy link
Contributor Author

The rendered HTML also shows the link with a strange extra dot:

Screenshot 2024-02-16 at 11 44 29 AM

@srawlins srawlins added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P2 A bug or feature request we're likely to work on labels Feb 16, 2024
@srawlins
Copy link
Member

This one is tricky though. Not everything between [] is a reference. We should only interpret code in a pattern like \[[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)?)?\] as a reference.

So the correct behavior is probably to just not consider [Foo.] as a reference (which is what the analyzer does). It wouldn't be reported either. Users are generally just allowed to write square brackets with non-code references between.

@goderbauer
Copy link
Contributor Author

Users are generally just allowed to write square brackets with non-code references between.

Really? I thought if I write [Foo] and Foo is not a class or anything else referencable dartdoc throws an error. I have definitely seen dartdoc complain about this.

@srawlins
Copy link
Member

Yes, dartdoc does that. But if you write text that doesn't fit the pattern above, like /// check out list[0] or /// hello [weird parenthetical remark]., then both the analyzer and dartdoc think, "well i don't think they're trying to write any kind of reference to an element..." and does not complain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants