public_member_api_docs
Document all public members.
此规则自 Dart 2.0 版本起可用。
详情
#DO document all public members.
All non-overriding public members should be documented with ///
doc-style comments.
BAD:
class Bad {
void meh() { }
}
GOOD:
/// A good thing.
abstract class Good {
/// Start doing your thing.
void start() => _start();
_start();
}
In case a public member overrides a member it is up to the declaring member to provide documentation. For example, in the following, Sub
needn't document init
(though it certainly may, if there's need).
GOOD:
/// Base of all things.
abstract class Base {
/// Initialize the base.
void init();
}
/// A sub base.
class Sub extends Base {
@override
void init() { ... }
}
Note that consistent with dart doc
, an exception to the rule is made when documented getters have corresponding undocumented setters. In this case the setters inherit the docs from the getters.
使用方法
#要启用 public_member_api_docs
规则,请在你的 analysis_options.yaml
文件中,在 linter > rules 下添加 public_member_api_docs
:
linter:
rules:
- public_member_api_docs
除非另有说明,否则本网站上的文档反映的是 Dart 3.6.0。页面最后更新于 2025-02-05。 查看源代码 或 报告问题.