如何在 dartdoc 中引用构造函数和运算符?
How to refer to constructors and operators in dartdoc?
Dart Language Tour 涵盖文档注释,并表示:
Inside a documentation comment, the Dart compiler ignores all text unless it
is enclosed in brackets. Using brackets, you can refer to classes, methods,
fields, top-level variables, functions, and parameters. The names in brackets
are resolved in the lexical scope of the documented program element.
我可能希望能够引用范围内的任何内容,但我在弄清楚如何引用命名和未命名的构造函数以及运算符时遇到了问题。
我创建了一个带有文档注释的测试库:
/// # Thingy
///
/// Blah [GLOBAL] blah [function] blah [Thingy] blah [Thingy.property] blah
/// [Thingy.virtualProperty] blah [Thingy.named] blah [Thingy.method]
/// blah [Thingy.operator+].
/// Try these: [Thingy.named()] blah [Thingy.()] blah [Thingy()].
library Thingy;
const int GLOBAL = 0;
void function(int arg) {}
/// A class.
///
/// Blah [GLOBAL] blah [function] blah [Thingy] blah [property] blah
/// [virtualProperty] blah [named] blah [method] blah [operator+].
/// Try these: [Thingy.named()] blah [Thingy.()] blah [Thingy()].
class Thingy {
int property;
int get virtualProperty => 0;
set virtualProperty(int arg) {}
Thingy(int arg) {}
Thingy.named(int arg) {}
/// A method.
///
/// Blah [GLOBAL] blah [function] blah [Thingy] blah [property] blah
/// [virtualProperty] blah [named] blah [method] blah [operator+] blah
/// [arg].
/// Try these: [Thingy.named()] blah [Thingy.()] blah [Thingy()].
void method(int arg) {}
Thingy operator+(int arg) => null;
}
Dartdoc 生成的库、class 和方法文档看起来像:
Blah GLOBAL blah function blah Thingy blah property blah
virtualProperty blah named
blah method blah operator+
...
Try these: Thingy.named
blah Thingy.()
blah Thingy()
.
(不是实际的 Dartdoc 输出 - 只是看起来的样子。Dart 语言教程 URL 用于模拟链接。)
大多数引用都有效,但我如何引用构造函数和运算符?
构造函数用 new
引用
/// [new MyClass]
/// [new MyClass.someNamedConstructor]
我还没有找到引用运算符的方法
/// [operator ==] or [==] seem not to work
Effective Dart: Documentation 记录 dart 文档注释,包括参考文献。
Dart Language Tour 涵盖文档注释,并表示:
Inside a documentation comment, the Dart compiler ignores all text unless it is enclosed in brackets. Using brackets, you can refer to classes, methods, fields, top-level variables, functions, and parameters. The names in brackets are resolved in the lexical scope of the documented program element.
我可能希望能够引用范围内的任何内容,但我在弄清楚如何引用命名和未命名的构造函数以及运算符时遇到了问题。
我创建了一个带有文档注释的测试库:
/// # Thingy
///
/// Blah [GLOBAL] blah [function] blah [Thingy] blah [Thingy.property] blah
/// [Thingy.virtualProperty] blah [Thingy.named] blah [Thingy.method]
/// blah [Thingy.operator+].
/// Try these: [Thingy.named()] blah [Thingy.()] blah [Thingy()].
library Thingy;
const int GLOBAL = 0;
void function(int arg) {}
/// A class.
///
/// Blah [GLOBAL] blah [function] blah [Thingy] blah [property] blah
/// [virtualProperty] blah [named] blah [method] blah [operator+].
/// Try these: [Thingy.named()] blah [Thingy.()] blah [Thingy()].
class Thingy {
int property;
int get virtualProperty => 0;
set virtualProperty(int arg) {}
Thingy(int arg) {}
Thingy.named(int arg) {}
/// A method.
///
/// Blah [GLOBAL] blah [function] blah [Thingy] blah [property] blah
/// [virtualProperty] blah [named] blah [method] blah [operator+] blah
/// [arg].
/// Try these: [Thingy.named()] blah [Thingy.()] blah [Thingy()].
void method(int arg) {}
Thingy operator+(int arg) => null;
}
Dartdoc 生成的库、class 和方法文档看起来像:
Blah GLOBAL blah function blah Thingy blah property blah virtualProperty blah
named
blah method blahoperator+
...Try these:
Thingy.named
blahThingy.()
blahThingy()
.
(不是实际的 Dartdoc 输出 - 只是看起来的样子。Dart 语言教程 URL 用于模拟链接。)
大多数引用都有效,但我如何引用构造函数和运算符?
构造函数用 new
/// [new MyClass]
/// [new MyClass.someNamedConstructor]
我还没有找到引用运算符的方法
/// [operator ==] or [==] seem not to work
Effective Dart: Documentation 记录 dart 文档注释,包括参考文献。