【问题标题】:How to inherit dart documentation如何继承飞镖文档
【发布时间】:2021-07-13 12:24:45
【问题描述】:

我有一个记录在案的类,另一个正在实现该接口。我怎样才能继承文档?

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

【问题讨论】:

    标签: flutter dart


    【解决方案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. 
    }
    

    【讨论】:

      【解决方案2】:

      您可以省略派生类的被覆盖成员的文档。 dartdoc在生成文档时会自动从基类复制文档。

      【讨论】:

        猜你喜欢
        • 2020-09-20
        • 2020-02-29
        • 2016-06-17
        • 2019-06-03
        • 2014-01-25
        • 1970-01-01
        • 1970-01-01
        • 2021-12-20
        相关资源
        最近更新 更多