Skip to content

Commit 583f379

Browse files
committed
Documentation Review #1
* Review, edit and rewrite documentation for example.md and all models of the API.
1 parent 582380d commit 583f379

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+429
-746
lines changed

example/example.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,24 @@
44
import 'package:codelessly_api/codelessly_api.dart';
55
import 'package:json_annotation/json_annotation.dart';
66
7-
part 'my_cool_node.g.dart';
7+
part 'my_node.g.dart';
88
9-
/// At it's core, this is the most basic example of how to create a complete
10-
/// [BaseNode].
9+
/// An example of how to create a new node.
1110
@JsonSerializable()
12-
class MyCoolNode extends BaseNode {
11+
class MyNode extends BaseNode {
1312
@override
14-
final String type = 'myCoolNode';
13+
final String type = 'myNode';
1514
16-
MyCoolNode({
15+
MyNode({
1716
required super.id,
1817
required super.name,
1918
required super.basicBoxLocal,
2019
});
2120
22-
factory MyCoolNode.fromJson(Map json) => _$MyCoolNodeFromJson(json);
21+
factory MyNode.fromJson(Map json) => _$MyNodeFromJson(json);
2322
2423
@override
25-
Map toJson() => _$MyCoolNodeToJson(this);
24+
Map toJson() => _$MyNodeToJson(this);
2625
}
2726
2827
```

lib/src/api/models/action/action.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ part 'action.g.dart';
1010

1111
/// Type of the action to perform on a user interaction.
1212
enum ActionType {
13-
/// Navigate to something.
13+
/// Navigate to a page.
1414
navigation,
1515

1616
/// Open a link.
@@ -28,7 +28,7 @@ enum ActionType {
2828
/// Call a custom function.
2929
callFunction;
3030

31-
/// Displayable string representation of the action type.
31+
/// Displayable string representation of the [ActionType].
3232
String get prettify {
3333
switch (this) {
3434
case ActionType.navigation:
@@ -47,8 +47,6 @@ enum ActionType {
4747
}
4848
}
4949

50-
/// ActionModel is named that way to not conflict with 'Action' from
51-
/// Material file.
5250
/// Holds information about an action to perform on a user interaction.
5351
@JsonSerializable()
5452
class ActionModel with SerializableMixin {

lib/src/api/models/action/link_action.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import 'action.dart';
1010

1111
part 'link_action.g.dart';
1212

13-
/// An action that navigates/opens a link.
13+
/// An action that opens up a link.
1414
@JsonSerializable()
1515
class LinkAction extends ActionModel with EquatableMixin, SerializableMixin {
16-
/// The link to navigate to.
16+
/// The link to open.
1717
final String url;
1818

1919
/// Creates a new [LinkAction] with the given data.

lib/src/api/models/action/navigation_action.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ part 'navigation_action.g.dart';
1212

1313
/// Defines how the navigation should be performed.
1414
enum NavigationType {
15-
/// Navigate to a specified page.
15+
/// Navigate to the specified page.
1616
push,
1717

1818
/// Navigate back from the current page.
@@ -21,7 +21,7 @@ enum NavigationType {
2121
/// Replace the current page with the specified page in the navigation stack.
2222
replace;
2323

24-
/// Displayable string representation of the action type.
24+
/// Displayable string representation of [NavigationType].
2525
String get prettify {
2626
switch (this) {
2727
case NavigationType.push:
@@ -34,15 +34,14 @@ enum NavigationType {
3434
}
3535
}
3636

37-
/// An action that navigates to a new route.
37+
/// An action that navigates to a new page.
3838
@JsonSerializable()
3939
class NavigationAction extends ActionModel
4040
with EquatableMixin, SerializableMixin {
4141
/// Defines how the navigation should be performed.
4242
final NavigationType navigationType;
4343

44-
/// Destination nodeID. Typically, a canvas, dialog or bottom sheet.
45-
// TODO: Rename to "destination".
44+
/// Destination canvas node's ID.
4645
final String destinationId;
4746

4847
/// Creates a new [NavigationAction].

lib/src/api/models/action/set_value_action.dart

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import 'action.dart';
1010

1111
part 'set_value_action.g.dart';
1212

13-
/// An action that sets a value to a property on a node.
13+
/// An action that sets value of a property of the node.
1414
@JsonSerializable()
1515
class SetValueAction extends ActionModel
1616
with EquatableMixin, SerializableMixin {
17-
/// ID of the node to set the value on.
17+
/// ID of the node whose values are to be set.
1818
final String nodeID;
1919

20-
/// Values to set on the node.
20+
/// List of values to be set in the node.
2121
@JsonKey(fromJson: valuesFromJson)
2222
final List<ValueModel> values;
2323

@@ -52,14 +52,19 @@ enum SetValueMode {
5252
/// Sets the value directly.
5353
discrete,
5454

55-
/// Toggles the value before setting it. Only applies to toggleable values
56-
/// like booleans.
55+
/// Toggles the value before setting it.
56+
/// Only applicable on toggleable values, such as booleans.
5757
toggle,
5858

59-
///
59+
/// Syncs the value with the internal value of the node that is performing the
60+
/// action. [syncValue] works only if both the values are of same type.
61+
/// For example, if a checkbox node is performing an action to change the
62+
/// visibility of a node, the visibility will sync with checkbox's internal
63+
/// value, i.e., [checked -> visible] and [unchecked -> invisible].
64+
/// In this case, both the values are of type [bool].
6065
syncValue;
6166

62-
/// Displayable string representation of this enum.
67+
/// Displayable string representation of [SetValueMode].
6368
String get prettify {
6469
switch (this) {
6570
case SetValueMode.discrete:
@@ -72,9 +77,9 @@ enum SetValueMode {
7277
}
7378
}
7479

75-
/// Represents a value to set on a node.
80+
/// Represents a value to set in a node.
7681
abstract class ValueModel<T> with SerializableMixin {
77-
/// The name of the property to set the value on.
82+
/// The name of the property to set the value of.
7883
final String name;
7984

8085
/// Describes how to set the value.
@@ -111,7 +116,7 @@ abstract class ValueModel<T> with SerializableMixin {
111116
List<ValueModel> valuesFromJson(List values) =>
112117
values.map((value) => ValueModel.fromJson(value)).toList();
113118

114-
/// A boolean type of value.
119+
/// Value of boolean type.
115120
@JsonSerializable()
116121
class BoolValue extends ValueModel<bool?> with SerializableMixin {
117122
/// Whether this property is nullable.
@@ -146,7 +151,7 @@ class BoolValue extends ValueModel<bool?> with SerializableMixin {
146151
Map toJson() => _$BoolValueToJson(this);
147152
}
148153

149-
/// An integer type of value.
154+
/// Value of integer type.
150155
@JsonSerializable()
151156
class IntValue extends ValueModel<int> with SerializableMixin {
152157
/// Creates a new [IntValue].
@@ -158,7 +163,8 @@ class IntValue extends ValueModel<int> with SerializableMixin {
158163
assert(mode != SetValueMode.toggle, '${mode.prettify} mode not supported.');
159164
}
160165

161-
/// Creates a new [IntValue] where the default value is 0 and mode is discrete.
166+
/// Creates a new [IntValue] where the default value is 0 and mode is
167+
/// discrete.
162168
const IntValue.discreteZero({
163169
required super.name,
164170
super.value = 0,
@@ -183,7 +189,7 @@ class IntValue extends ValueModel<int> with SerializableMixin {
183189
Map toJson() => _$IntValueToJson(this);
184190
}
185191

186-
/// A double type of value.
192+
/// Value of double type.
187193
@JsonSerializable()
188194
class DoubleValue extends ValueModel<double> with SerializableMixin {
189195
/// Creates a new [DoubleValue].
@@ -195,7 +201,8 @@ class DoubleValue extends ValueModel<double> with SerializableMixin {
195201
assert(mode != SetValueMode.toggle, '${mode.prettify} mode not supported.');
196202
}
197203

198-
/// Creates a new [DoubleValue] where the default value is 0 and mode is discrete.
204+
/// Creates a new [DoubleValue] where the default value is 0 and mode is
205+
/// discrete.
199206
const DoubleValue.discreteZero({
200207
required super.name,
201208
super.value = 0,
@@ -220,7 +227,7 @@ class DoubleValue extends ValueModel<double> with SerializableMixin {
220227
Map toJson() => _$DoubleValueToJson(this);
221228
}
222229

223-
/// A string type of value.
230+
/// Value of string type.
224231
@JsonSerializable()
225232
class StringValue extends ValueModel<String> with SerializableMixin {
226233
/// Creates a new [StringValue].

lib/src/api/models/action/submit_action.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import 'action.dart';
1010

1111
part 'submit_action.g.dart';
1212

13-
/// Represents supported service for submit action.
13+
/// Represents supported services for submit action.
1414
enum SubmitActionService {
15-
/// Mailchimp service for submit action.
15+
/// Mailchimp service.
1616
mailchimp;
1717

18-
/// Displayable string representation of the service.
18+
/// Displayable string representation of [SubmitActionService].
1919
String get prettify {
2020
switch (this) {
2121
case SubmitActionService.mailchimp:
@@ -27,13 +27,13 @@ enum SubmitActionService {
2727
/// An action that submits a form.
2828
@JsonSerializable()
2929
class SubmitAction extends ActionModel with EquatableMixin, SerializableMixin {
30-
/// Submit service to use.
30+
/// Service used to submit the form.
3131
SubmitActionService service;
3232

33-
/// ID of the text field node to submit.
33+
/// ID of the text field node whose content needs to be submitted.
3434
final String primaryTextField;
3535

36-
/// API key for for the submit service.
36+
/// API key used to access the service.
3737
final String apiKey;
3838

3939
/// Creates a new [SubmitAction].
@@ -73,11 +73,11 @@ class MailchimpSubmitAction extends SubmitAction {
7373
final String listID;
7474

7575
/// Optional field to store the first name of the subscriber.
76-
/// It referes to the ID of a text field node.
76+
/// It refers to the ID of a text field node.
7777
final String firstNameField;
7878

7979
/// Optional field to store the last name of the subscriber.
80-
/// It referes to the ID of a text field node.
80+
/// It refers to the ID of a text field node.
8181
final String lastNameField;
8282

8383
/// Creates a new [MailchimpSubmitAction].

lib/src/api/models/alignment.dart

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,8 @@ import '../mixins.dart';
99

1010
part 'alignment.g.dart';
1111

12-
/// AlignmentModel wraps AlignmentData.
13-
/// Having a nullable node property causes issues in the app.
14-
/// The most severe case was with undoManager.registerActionEnd not knowing
15-
/// if the alignment was updated or not, as it uses null for missing values
16-
/// but on alignment, null is a valid option. On Paint there was the same issue,
17-
/// alignment was an optional property and there was no way to know if its value
18-
/// was null or its value wasn't there.
19-
///
20-
/// Even though in nodes constructor the alignment property is nullable,
21-
/// their inner property is not (see mixins.dart).
22-
/// If it is null, it gets assigned AlignmentModel.none.
12+
/// [AlignmentModel] wraps [AlignmentData] and provides standard alignment
13+
/// values such as [topRight] and [bottomCenter] for ease of use.
2314
@JsonSerializable()
2415
class AlignmentModel with EquatableMixin, SerializableMixin {
2516
/// Holds the actual x and y percentage information.
@@ -131,7 +122,7 @@ class AlignmentModel with EquatableMixin, SerializableMixin {
131122
static const AlignmentModel bottomRight =
132123
AlignmentModel(AlignmentData(1.0, 1.0));
133124

134-
/// Whether this alignment one of the [values].
125+
/// Whether this alignment is one of the [values].
135126
bool get isStandard => values.contains(this);
136127

137128
/// Whether this alignment is one of the standard alignments that represent
@@ -159,10 +150,9 @@ class AlignmentModel with EquatableMixin, SerializableMixin {
159150
AlignmentModel.none,
160151
];
161152

162-
/// Allows to create a new instance of this class by copying the current
163-
/// instance and replacing the given fields with the new values.
153+
/// Duplicates this [AlignmentModel] with given data overrides.
164154
AlignmentModel copyWith({AlignmentData? data}) {
165-
return AlignmentModel(data ?? this.data); // Deep copy.
155+
return AlignmentModel(data ?? this.data);
166156
}
167157

168158
@override
@@ -198,7 +188,7 @@ class AlignmentModel with EquatableMixin, SerializableMixin {
198188
}
199189
}
200190

201-
/// A data class that holds the x and y values of an alignment.
191+
/// A data class that holds the x and y values of the alignment.
202192
@JsonSerializable()
203193
class AlignmentData extends Equatable with SerializableMixin {
204194
/// The x value of the alignment that represents how far it is from
@@ -217,8 +207,7 @@ class AlignmentData extends Equatable with SerializableMixin {
217207
@override
218208
List<Object?> get props => [x, y];
219209

220-
/// Allows to create new instance of this class by copying the current
221-
/// instance and replacing the given fields with the new values.
210+
/// Duplicates this [AlignmentData] with given data overrides.
222211
AlignmentData copyWith({double? x, double? y}) =>
223212
AlignmentData(x ?? this.x, y ?? this.y);
224213

0 commit comments

Comments
 (0)