Is there a way to link to another class using Dart documentation comments.
In JavaDoc you could use @see com.my.package.Class#method()
in your comment and when you click the comment, the IDE takes you to the com.my.package.Class
. Is there an equivalent syntax for Dart?
For historical reasons, dart doc supports two syntaxes of doc comments: /// (“C# style”) and /** ... */ (“JavaDoc style”). We prefer /// because it's more compact. /** and */ add two content-free lines to a multiline doc comment.
Dart Multi-Line Comment: Dart Multiline comment is used to comment out a whole section of code. It uses '/*' and '*/' to start and end a multi-line comment respectively.
*/ /// Documentation /// /// This is what you should use to document your classes. Generally, documentation comments with three slashes are used for documenting your code. Anything you think will stay in the code forever should use this style of comments.
You can use markdown links in DartDoc, so:
/// Floos the ploink.
///
/// The [Ploink] provided as [ploink] is [Ploink.floo]'d.
///
/// Returns the [Floo] resulting from the `floo`'ing of [ploink].
///
/// See also [FlooPloinker] for a class that does the same.
Floo flooThePloink(Ploink ploink) => ploink.floo();
Anything inside [
and ]
are links. You can also do external links as [HTTP](https://tools.ietf.org/html/rfc7231)
, but if there is nothing after the braces, it's considered an internal DartDoc link and is resolved like that identifier would be in the thing being commented on. That includes links to classes like [Object]
or methods like [Object.hashCode]
.
You have to write the "see" yourself, there are no magical @
markers in DartDoc, just prose and links.
You do need to be able to reference the class, so you can't do a dart-doc reference to a class you haven't imported in the library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With