Skip to content

Commit a4e4e35

Browse files
committed
docs: add missing documentation comments for public members
1 parent 96b4f50 commit a4e4e35

23 files changed

+176
-0
lines changed

packages/dogs_core/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ linter:
2020
- avoid_void_async
2121
- avoid_print
2222
- prefer_final_locals
23+
- public_member_api_docs
2324

2425
# Uncomment the following section to specify additional rules.
2526

packages/dogs_core/lib/dogs_schema.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,57 @@
11
import "dogs_core.dart";
22

3+
/// Creates a schema type representing a string.
34
SchemaType string() => SchemaType.string;
45

6+
/// Creates a schema type representing an integer.
57
SchemaType integer() => SchemaType.integer;
68

9+
/// Creates a schema type representing a number.
710
SchemaType number() => SchemaType.number;
811

12+
/// Creates a schema type representing a boolean.
913
SchemaType boolean() => SchemaType.boolean;
1014

15+
/// Creates a schema type representing any value.
1116
SchemaType any() => SchemaType.any;
1217

18+
/// Creates a schema type representing an object with the given properties.
1319
SchemaType object(Map<String, SchemaType> properties) {
1420
return SchemaType.object(
1521
fields:
1622
properties.entries.map((e) => SchemaField(e.key, e.value)).toList());
1723
}
1824

25+
/// Creates a schema type representing an array of the given item type.
1926
SchemaType array(SchemaType itemType) {
2027
return SchemaType.array(itemType);
2128
}
2229

30+
/// Creates a schema type representing a reference to another schema by its serial name.
2331
SchemaType ref(String serialName) {
2432
return SchemaType.reference(serialName);
2533
}
2634

35+
/// Creates a schema type representing a string-keyed map with values of the given item type.
2736
SchemaType map(SchemaType itemType) {
2837
return SchemaType.map(itemType);
2938
}
3039

40+
/// Creates a schema type representing an enumeration of the given string values.
3141
SchemaType enumeration(List<String> values) {
3242
return SchemaType.string.property(SchemaProperties.$enum, values);
3343
}
3444

45+
/// Extension methods for SchemaType to provide a fluent API for schema definitions.
3546
extension SchemaTypeExtension on SchemaType {
47+
48+
/// Makes this schema type an array of itself.
3649
SchemaType array() => SchemaType.array(this);
3750

51+
/// Marks this schema type as optional (nullable).
3852
SchemaType optional() => this..nullable = true;
3953

54+
/// Adds a custom property to the schema.
4055
SchemaType property(String key, dynamic value) =>
4156
this..properties[key] = value;
4257

@@ -82,6 +97,7 @@ extension SchemaTypeExtension on SchemaType {
8297
throw ArgumentError("Max is not supported for $this");
8398
}
8499

100+
/// Requires the value to be larger than the given value.
85101
SchemaType gt(double value) {
86102
if (type == SchemaCoreType.number || type == SchemaCoreType.integer) {
87103
return property(SchemaProperties.minimum, value)
@@ -91,6 +107,7 @@ extension SchemaTypeExtension on SchemaType {
91107
throw ArgumentError("Gt is not supported for $this");
92108
}
93109

110+
/// Requires the value to be larger than or equal to the given value.
94111
SchemaType gte(double value) {
95112
if (type == SchemaCoreType.number || type == SchemaCoreType.integer) {
96113
return property(SchemaProperties.minimum, value);
@@ -99,6 +116,7 @@ extension SchemaTypeExtension on SchemaType {
99116
throw ArgumentError("Gte is not supported for $this");
100117
}
101118

119+
/// Requires the value to be less than the given value.
102120
SchemaType lt(double value) {
103121
if (type == SchemaCoreType.number || type == SchemaCoreType.integer) {
104122
return property(SchemaProperties.maximum, value)
@@ -108,6 +126,8 @@ extension SchemaTypeExtension on SchemaType {
108126
throw ArgumentError("Lt is not supported for $this");
109127
}
110128

129+
130+
/// Requires the value to be less than or equal to the given value.
111131
SchemaType lte(double value) {
112132
if (type == SchemaCoreType.number || type == SchemaCoreType.integer) {
113133
return property(SchemaProperties.maximum, value);
@@ -116,18 +136,30 @@ extension SchemaTypeExtension on SchemaType {
116136
throw ArgumentError("Lte is not supported for $this");
117137
}
118138

139+
/// Requires the value to be a positive number (greater than 0).
119140
SchemaType positive() => gte(0);
141+
142+
/// Requires the value to be a negative number (less than 0).
120143
SchemaType negative() => lte(0);
144+
145+
/// Requires the value to be a non-negative number (0 or greater).
121146
SchemaType nonNegative() => gte(0);
147+
148+
/// Requires the value to be a non-positive number (0 or less).
122149
SchemaType nonPositive() => lte(0);
150+
151+
/// Sets both the minimum and maximum values to the given length.
123152
SchemaType length(int length) => min(length).max(length);
153+
154+
/// Requires all items in the array to be unique.
124155
SchemaType unique() {
125156
if (this is! SchemaArray) {
126157
throw ArgumentError("Unique is only supported for arrays");
127158
}
128159
return property(SchemaProperties.uniqueItems, true);
129160
}
130161

162+
/// Sets the serial name for this schema type. Only supported for objects.
131163
SchemaType serialName(String serialName) {
132164
if (this is! SchemaObject) {
133165
throw ArgumentError("Serial name is only supported for objects");

packages/dogs_core/lib/src/converters/enum.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ typedef EnumToString<T> = String Function(T?);
2525
/// A [DogConverter] that allows for the conversion of enum values to and from strings.
2626
abstract class GeneratedEnumDogConverter<T extends Enum> extends DogConverter<T>
2727
with OperationMapMixin<T>, EnumConverter<T> {
28+
29+
/// Creates a new [GeneratedEnumDogConverter].
2830
GeneratedEnumDogConverter();
2931

32+
/// Creates a new associated [GeneratedEnumDogConverter] with the given [serialName].
3033
GeneratedEnumDogConverter.structured({required String serialName})
3134
: super(
3235
isAssociated: true, struct: DogStructure<T>.synthetic(serialName));
@@ -90,6 +93,7 @@ class RuntimeEnumConverter extends SimpleDogConverter<String>
9093
@override
9194
final List<String> values;
9295

96+
/// Creates a new [RuntimeEnumConverter] with the given [values] and [serialName].
9397
RuntimeEnumConverter(this.values, String serialName)
9498
: super(serialName: serialName);
9599

packages/dogs_core/lib/src/engine.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ class DogEngine with MetadataMixin {
585585
}
586586
}
587587

588+
/// A plugin 'middleware' function that can be used to modify a [DogEngine] instance.
588589
typedef DogPlugin = void Function(DogEngine engine);
589590

590591
/// Converts a [value] to the given [IterableKind]. If the value is a [Iterable]

packages/dogs_core/lib/src/extensions.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ extension StructureExtensions on DogStructure {
280280
structure: this);
281281
}
282282

283+
/// Returns a debug string representation of this structure.
283284
String toDebugString(DogEngine? engine) {
284285
final buffer = StringBuffer();
285286
buffer.writeln("Structure: $serialName");

packages/dogs_core/lib/src/global.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ const DeepCollectionEquality deepEquality = DeepCollectionEquality();
3838
@internal
3939
int compareTypeHashcodes(Type a, Type b) => a.hashCode.compareTo(b.hashCode);
4040

41+
/// Entrypoint for enabling and configuring a [DogEngine].
42+
///
43+
/// You can provide a list of [DogPlugin]s, which will be applied in the given order.
44+
/// If [global] is true (default), the configured engine will be set as the global
45+
/// singleton and can be accessed via [dogs].
4146
DogEngine configureDogs({
4247
required List<DogPlugin> plugins,
4348
bool global = true,

packages/dogs_core/lib/src/hooks.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ const ExcludeNull excludeNull = ExcludeNull();
193193
/// A **field** and **class** level serialization hook that excludes fields
194194
/// with a `null` value from the serialized map.
195195
class ExcludeNull extends SerializationHook with FieldSerializationHook {
196+
197+
/// A **field** and **class** level serialization hook that excludes fields
198+
/// with a `null` value from the serialized map.
196199
const ExcludeNull();
197200

198201
@override

packages/dogs_core/lib/src/opmodes/modes/validation.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,12 @@ class _InlineValidationMode<T, IR> extends ValidationMode<T>
7474
annotator(value, engine, _ir);
7575
}
7676

77+
/// An interface for things that can be converted to an [AnnotationResult]
7778
abstract interface class AnnotationResultLike {
79+
/// Converts this to an [AnnotationResult].
7880
AnnotationResult asAnnotationResult();
81+
82+
/// Combines this with another [AnnotationResultLike].
7983
AnnotationResult operator +(AnnotationResultLike? other);
8084
}
8185

@@ -89,6 +93,7 @@ class AnnotationResult implements AnnotationResultLike {
8993
required this.messages,
9094
});
9195

96+
/// Returns true if this result contains any error messages.
9297
bool get hasErrors => messages.isNotEmpty;
9398

9499
/// Translates all messages in this result using [engine].

packages/dogs_core/lib/src/projections.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ extension ProjectionExtension on DogEngine {
237237
}
238238
}
239239

240+
// ignore: public_member_api_docs
240241
typedef Supplier<T> = T Function();
241242

242243
/// Creates a reusable list of projections that can be applied to a document.
@@ -259,6 +260,7 @@ final class Projection<T> {
259260
{DogEngine? engine, this.tree, this.type, this.useFieldMap = false})
260261
: engine = engine ?? dogs;
261262

263+
/// Creates a new projection that uses field maps for instantiating the final object.
262264
Projection.fieldMap({DogEngine? engine, this.tree, this.type})
263265
: engine = engine ?? dogs,
264266
useFieldMap = true;
@@ -451,6 +453,9 @@ class Projections {
451453
return $clone(map)..addAll(result);
452454
}
453455

456+
/// Moves the value at [from] to [to] in the given [map]. If [delete] is true,
457+
/// the value at [from] is deleted after being moved. Returns a new map with
458+
/// the updated values and leaves the original map untouched.
454459
static Map<String, dynamic> $move(
455460
Map<String, dynamic> map, String from, String to, bool delete) {
456461
final isWildcard = from.endsWith(".*");

packages/dogs_core/lib/src/schema/contributors.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ SchemaType _extractItemSchemaType(SchemaType type) => switch (type) {
66
_ => type,
77
};
88

9+
/// A contributor that adds standard collection validation annotations
910
class CollectionValidationContributor
1011
extends SchemaStructureMaterializationContributor {
1112
@override
@@ -25,6 +26,7 @@ class CollectionValidationContributor
2526
}
2627
}
2728

29+
/// A contributor that adds standard string validation annotations
2830
class StringValidationContributor
2931
extends SchemaStructureMaterializationContributor {
3032
@override
@@ -54,6 +56,7 @@ class StringValidationContributor
5456
}
5557
}
5658

59+
/// A contributor that adds standard number validation annotations
5760
class NumberValidationContributor
5861
extends SchemaStructureMaterializationContributor {
5962
@override

0 commit comments

Comments
 (0)