Skip to content

Commit f2d97bf

Browse files
authored
Expand the doc comment for Context (#1902)
This is the main point of interaction for authors of extensions, so docs cover a wide range of information, including how the descriptions will be used in failure output. - Export `ConditionSubject` from `context.dart`. - Use templates for some parts of the doc that describe universal behavior and apply them as macros in the docs for individual methods. - Make the fields in `Extracted` private. This lets the references in docs link to the constructors instead of the fields of the same name. The interface intended for external use is the constructors, so things are simpler if that is the only exposed API. - Fix README example to use label callback.
1 parent da7c667 commit f2d97bf

File tree

3 files changed

+324
-68
lines changed

3 files changed

+324
-68
lines changed

pkgs/checks/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ extension CustomChecks on Subject<CustomType> {
9696
}
9797
9898
Subject<Foo> get someDerivedValue =>
99-
context.nest('has someDerivedValue', (actual) {
99+
context.nest(() => ['has someDerivedValue'], (actual) {
100100
if (_cannotReadDerivedValue(actual)) {
101101
return Extracted.rejection(which: ['cannot read someDerivedValue']);
102102
}

pkgs/checks/lib/context.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
export 'src/checks.dart'
66
show
7-
Subject,
87
CheckFailure,
98
Condition,
9+
ConditionSubject,
1010
Context,
1111
ContextExtension,
1212
Extracted,
1313
FailureDetail,
1414
Rejection,
15+
Subject,
1516
describe,
1617
describeAsync,
1718
softCheck,

0 commit comments

Comments
 (0)