package_api_docs
Provide doc comments for all public APIs.
This rule is available as of Dart 2.0.0.
Details
#DO provide doc comments for all public APIs.
As described in the pub package layout doc,
public APIs consist in everything in your package's lib
folder, minus
implementation files in lib/src
, adding elements explicitly exported with an
export
directive.
For example, given lib/foo.dart
:
export 'src/bar.dart' show Bar;
export 'src/baz.dart';
class Foo { }
class _Foo { }
its API includes:
Foo
(but not_Foo
)Bar
(exported) and- all public elements in
src/baz.dart
All public API members should be documented with ///
doc-style comments.
BAD:
class Bar {
void bar();
}
GOOD:
/// A Foo.
abstract class Foo {
/// Start foo-ing.
void start() => _start();
_start();
}
Advice for writing good doc comments can be found in the Doc Writing Guidelines.
Usage
#To enable the package_api_docs
rule,
add package_api_docs
under linter > rules in your
analysis_options.yaml
file:
linter:
rules:
- package_api_docs
除非另有说明,文档之所提及适用于 Dart 3.5.0 版本,本页面最后更新时间: 2024-09-09。 查看文档源码 或者 报告页面问题。