官术网_书友最值得收藏!

Documenting your programs

Documenting an application is of utmost importance in software engineering and Dart makes this very easy. The single-line (//) and multiline comments (/* */) are useful (for example, to comment out code or mark lines with // TODO), and they have counterparts /// and /** */ called documentation comments. In these comments (to be placed on the previous line), you can include references to all kinds of objects in your code (classes, methods, fields, and so on) and the Dartdoc tool (in Dart Editor go to Tools | Generate Dartdoc) will generate HTML documentation where these references become links. To demonstrate we will add docs to our banking example (refer to banking_v2doc.dart):

/**
 * A bank account has an [owner], is identified by a [number]
 * and has an amount of money called [balance].
 * The balance is changed through methods [deposit] and [withdraw].
 */
class BankAccount {
  String owner, number;
  double balance;
  DateTime dateCreated, dateModified;

  BankAccount(this.owner, this.number, this.balance)  {
    dateCreated = new DateTime.now();
  }

 /// An amount of money is added to the balance.
  deposit(double amount) {
    
  }

 /// An amount of money is subtracted from the balance.
  withdraw(double amount) {
    
  }
}

This results in the following documentation when viewing banking_v2doc\docs\index.html in a browser:

Documenting your programs
主站蜘蛛池模板: 封开县| 阳东县| 萨嘎县| 竹溪县| 安化县| 临邑县| 永年县| 宜兰市| 白朗县| 泰顺县| 城步| 固始县| 镇江市| 清原| 黔江区| 永川市| 隆德县| 石台县| 湟中县| 远安县| 眉山市| 汉中市| 城固县| 嘉义市| 巴林左旗| 罗江县| 隆子县| 莫力| 昔阳县| 阿尔山市| 梅州市| 兰州市| 和田市| 宣威市| 扶绥县| 简阳市| 青阳县| 平泉县| 温宿县| 梧州市| 祁门县|