Skip to content

Commit 3895ccf

Browse files
authored
A few tweaks to macro docs
1 parent 8c074f3 commit 3895ccf

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/content/language/macros.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: Learn about the experimental macros feature as it develops.
77
***currently under development*** which adds support for
88
[static meta-programming][motivation] to the Dart language.
99

10-
A Dart macro is a user-defineable piece of code that takes in other code as parameters
10+
A Dart macro is a user-definable piece of code that takes in other code as parameters
1111
and operates on it in real-time to create, modify, or add declarations.
1212

1313
You can think about the macro system in two parts: using macros and writing macros.
@@ -56,10 +56,11 @@ and a `fromJson` deserialization constructor.
5656

5757
2. Run `dart --version` and make sure you have Dart version `3.5.0-152` or later.
5858

59-
3. [Add the package][] to your pubspec and retrieve
60-
its dependencies.
59+
3. Edit the [SDK constraint][] in your pubspec to require that Dart version: `sdk: ^3.5.0-152`
6160

62-
4. [Add the experiment][] to the `analysis_options.yaml`
61+
4. [Add the package][] `json` to `dependencies` in your pubspec and run `pub get`.
62+
63+
5. [Add the experiment][] to the `analysis_options.yaml`
6364
file at the root of your project:
6465

6566
```yaml
@@ -68,18 +69,19 @@ and a `fromJson` deserialization constructor.
6869
- macros
6970
```
7071
71-
5. Import the package in the file you plan to use it:
72+
6. Import the package in the file you plan to use it:
7273
7374
```dart
7475
import 'package:json/json.dart';
7576
```
7677

77-
6. Run your project with the experiment flag:
78+
7. Run your project with the experiment flag:
7879

7980
```console
8081
dart run --enable-experiment=macros bin/my_app.dart
8182
```
8283

84+
[SDK constraint]: /tools/pub/pubspec#sdk-constraints
8385
[Add the package]: /guides/packages
8486
[Add the experiment]: /tools/experiment-flags#using-experiment-flags-with-the-dart-analyzer-command-line-and-ide
8587

@@ -136,7 +138,7 @@ adjust in real time alongside your application code:
136138

137139
### Trigger custom diagnostics
138140

139-
The `JsonCodable` macro has built-in diagnostics that are emmitted just like
141+
The `JsonCodable` macro has built-in diagnostics that are emitted just like
140142
diagnostics from the language itself. For example, if you try to manually
141143
declare a `toJson` method where the macro is applied, the analyzer will emit
142144
the error:

0 commit comments

Comments
 (0)