链接到Dart注释中的类以获取文档

时间:2018-07-11 04:18:28

标签: dart

是否可以使用Dart文档注释链接到另一个类。

在JavaDoc中,您可以在注释中使用@see com.my.package.Class#method(),当您单击注释时,IDE会将您带到com.my.package.Class。 Dart有等效的语法吗?

1 个答案:

答案 0 :(得分:5)

您可以在DartDoc中使用markdown链接,因此:

/// 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();

[]中的所有内容都是链接。您也可以像[HTTP](https://tools.ietf.org/html/rfc7231)一样进行外部链接,但是如果花括号后面没有任何内容,则将其视为内部DartDoc链接,并且可以像在标识符中注释该标识符那样进行解析。其中包括指向诸如[Object]之类的类或诸如[Object.hashCode]之类的方法的链接。 您必须自己编写“查看”,DartDoc中没有神奇的@标记,只是散文和链接。

您确实需要能够引用该类,因此您不能对尚未在库中导入的类进行dart-doc引用。