我有一个类已记录在案,另一个类正在实现该接口。我如何才能继承文档?
class A {
///Documentation
void documented(){}
}
class B implements A {
var a = A();
///@inherit from A
void documented(){}
}
// later I have instance of B and I would like to have documentation on method.
B().documented(); // documentation is empty
答案 0 :(得分:1)
你可以试试模板:
class A {
/// {@template fooTemplate}
///
/// Your documentation goes here...
///
/// {@endtemplate}
void documented(){}
}
class B implements A {
var a = A();
/// {@macro fooTemplate}
void documented(){}
}
void f() {
B().documented(); // Valid documentation.
}
答案 1 :(得分:1)
您可以省略派生类的重写成员的文档。 dartdoc
会在生成文档时自动从基类复制文档。