dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.29k stars 1.59k forks source link

Parser wrongly creates CommentReference nodes for markdown links. #31761

Open pq opened 6 years ago

pq commented 6 years ago

From @kevmoo on July 19, 2017 19:20

the rfc link below shows us as broken.

SDK 1.25.0-dev.7.0

/// An implementation of [keyed-hash method authentication codes][rfc].
///
/// [rfc]: https://tools.ietf.org/html/rfc2104
///
/// HMAC allows messages to be cryptographically authenticated using any
/// iterated cryptographic hash function.
class Hmac extends Converter<List<int>, Digest> {
...
}

Copied from original issue: dart-lang/linter#750

pq commented 6 years ago

It looks like this is an issue that percolates up from the analyzer (its parser is treating [rfc] as a CommentReference node where it shouldn't). Fixing this properly would involve a repair there.

@kevmoo : can you provide context? Is this happening frequently? How common are links in dartdocs?

pq commented 6 years ago

From @kevmoo on December 31, 2017 21:52

See https://travis-ci.org/dart-lang/markdown/jobs/323208414#L528

Three pretty valid examples in this file...

https://github.com/dart-lang/markdown/blob/0eb8ae2a23295666149f3df0b2b184869c189b82/lib/src/extension_set.dart#L16

@pq – could you open a bug in analyzer on this?

pq commented 6 years ago

@bwilkerson, @scheglov : should I open a fresh bug or just move this one to the SDK repo?

pq commented 6 years ago

From @bwilkerson on January 3, 2018 21:51

I think this is purely an analyzer issue, so moving it makes sense to me.

pq commented 6 years ago

@bwilkerson, @scheglov: should this be moved to another component? (e.g., CFE?)

bwilkerson commented 6 years ago

I don't expect the CFE to parse doc comments, so no.

bwilkerson commented 6 years ago

I believe that this has been fixed. Please let us know if you're still seeing the described behavior.

kevmoo commented 5 years ago

This is still happening with wrapped links

  /// [color] may either be a [String], a [bool], or `null`. If it's a string,
  /// it indicates an [ANSI terminal color
  /// escape](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) that should
kevmoo commented 4 years ago

Also with link references

/// For more details see the source map [version 3 documentation][spec].
/// [spec]: https://docs.google.com/a/google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
srawlins commented 1 year ago

Agree

srawlins commented 4 months ago

Yeah still happening, and comment_references detects the link reference; analyzer should too. It won't be CommonMark bulletproof, but a minimal, 90% correct solution is not difficult.