How to inherit dart documentation

Viewed 186

I have one class that is documented, and another one is implementing that interface. How can I inherit the documentation as well?

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

2 Answers

If your derived class doesn't need to add any additional documentation, you can just omit documentation for the overridden members in the derived class. dartdoc will automatically copy the documentation from the base class when generating documentation.

You can try template:

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. 
}
Related