public_ member_ api_ docs
Document all public members.
Details
#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.
Enable
#
To enable the
public_member_api_docs
rule, add
public_member_api_docs
under
linter > rules
in your
analysis_options.yaml
file:
linter:
rules:
- public_member_api_docs
If you're instead using the YAML map syntax to configure linter rules,
add
public_member_api_docs: true
under
linter > rules:
linter:
rules:
public_member_api_docs: true
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Report an issue.