Dart 中 Doc 评论和 Comments 的区别

Differences between Doc comments and Comments in Dart

可能看起来很简单,但我很想知道 Doc Comments 和 Dart Comments 之间的确切区别。

///这是一个文档评论

//这是一条评论

在我看来,在这里提问和回答对其他人也有帮助:)

评论 (//)

注释通常用于注释掉你的代码的某些部分或在你的代码中添加一些注释,你想与你的队友交流。

文档评论 (///)

文档注释用于文档目的。 dartdoc 解析文档注释并创建文档页面。

+--------------------------------------------+-----------------------------------------------------+
| Comments                                   | Doc Comments                                        |
+--------------------------------------------+-----------------------------------------------------+
|  - Comment out some part of your code      | - Anything that you want to document using dartdoc  |
|  - Private APIs                            | - Usually used for public API/Framework/Library     |
|  - Private variable declaration            |                                                     |
|  - Method implementation logic             |                                                     |
|  - Something you need to do in future      |                                                     |
|    for improvements or cleanup purpose etc |                                                     |
+--------------------------------------------+-----------------------------------------------------+

您可以在 Effective Dart - Documentation

中阅读更多相关信息