Skip to content

Commit 4ec7225

Browse files
committed
Updated Dart docs.
1 parent 166d5e5 commit 4ec7225

File tree

7 files changed

+61
-69
lines changed

7 files changed

+61
-69
lines changed

README.md

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ and methods during the build process.
1313

1414
The library [`merging_builder`][merging_builder] includes the following (synthetic input) builder classes:
1515

16-
* [`MergingBuilder`][class-merging-builder] reads **several input files** and writes
17-
merged output to **one output file** to a custom location.
16+
* [`MergingBuilder`][class-merging-builder] reads *several input files* and writes
17+
merged output to *one output file* to a custom location.
1818

1919
* [`StandaloneBuilder`][StandaloneBuilder] reads one or several input files and
20-
writes standalone files to a custom location. In this context, **standalone**
21-
means the output files may be written to a **custom folder** and
22-
not only the **extension** but the **name** of the output file can
20+
writes standalone files to a custom location. In this context, *standalone*
21+
means the output files may be written to a *custom folder* and
22+
not only the *extension* but the *name* of the output file can
2323
be configured (as opposed to using part files).
2424

2525

@@ -32,19 +32,19 @@ In the [example] project provided, the package defining a new
3232
builder is called `researcher_builder` and the package using this builder is called `researcher`.
3333
To set up a build system the following steps are required:
3434

35-
### Builder Package Setup
35+
### 1. Builder Package Setup
3636

3737
1. Get dependencies: Include [`merging_builder`][merging_builder], [`build`][build] as *dependencies* in the file `pubspec.yaml`. In the [example] mentioned here, the generator also requires the packages [`analyzer`][analyzer] and [`source_gen`][source_gen].
3838

3939
2. Create a generator: Create a custom generator that extends [`MergingGenerator`][MergingGenerator]. In [example] `generateItemForAnnotatedElement` reads a list of strings while `generateMergedContent` merges the data and generates output that is written to [researchers.dart].
4040

4141
3. Create a builder: Create an instance of [`MergingBuilder`][MergingBuilder]. Following the example of [`source_gen`][source_gen], builders are typically placed in a file called: `builder.dart` located in the `lib` folder of the builder package.
4242
* Input sources may be specified using wildcard characters supported by [`Glob`][Glob].
43-
* The builder definition includes the default values of the *options* `input_files`, `output_file`, `header`, `footer`, and `sort_assets`. These options can be overwritten by the user of the builder by specifying them explicitly in the file `build.yaml` located in the package `researcher` (see step 5).
43+
* The builder definition includes the default values of the *options* `input_files`, `output_file`, `header`, `footer`, and `sort_assets`. These options can be overwritten by the user of the builder by specifying them explicitly in the file `build.yaml` located in the package `researcher` (see step 1 in section [User Package Setup](#1-builder-package-setup)).
4444

4545
4. Add a builder configuration: The build extensions for
4646
[`MergingBuilder`][MergingBuilder] must be specified using the notation
47-
available for **synthetic input**. For example, `"$lib$"` indicates that the
47+
available for *synthetic input*. For example, `"$lib$"` indicates that the
4848
input files are located in the folder `lib` or a subfolder thereof.
4949
```Yaml
5050
builders:
@@ -62,15 +62,16 @@ input files are located in the folder `lib` or a subfolder thereof.
6262
build_to: source
6363
```
6464

65-
### User Package Setup
65+
### 2. User Package Setup
6666

67-
The following steps are performed in the package that is using the custom builder.
67+
The following steps are performed in the package that is using the custom builder:
6868

69-
1. Add dependencies: Add the builder package and [`build_runner`][build_runner] as *dev_dependencies* in the file `pubspec.yaml`.
69+
1. Add dependencies: Add the custom builder package and
70+
[`build_runner`][build_runner] as a *dev_dependencies* in the file `pubspec.yaml`.
7071

71-
2. Builder configuration: Add the builder to the list of known builders and configure
72-
the available options.
73-
The sample `build.yaml` file is shown below.
72+
2. Builder configuration: Add the builder to the list of known builders
73+
and configure the available options (thus overwriting the default values).
74+
A sample `build.yaml` file is shown below.
7475

7576
```Yaml
7677
targets:
@@ -109,7 +110,7 @@ use *synthetic input*.
109110

110111
### Merging Builder
111112

112-
[`MergingBuilder`][MergingBuilder] reads **several input files** and writes merged output to **one output file**.
113+
[`MergingBuilder`][MergingBuilder] reads *several input files* and writes merged output to *one output file*.
113114
The builder provides the option to sort the input files in reverse topological order.
114115
If the input file `a.dart` includes file `b.dart` then `a.dart` will be listed *after* `b.dart`. This option may be useful when
115116
generating code that needs to list variables or call functions in order of dependence.
@@ -134,7 +135,8 @@ wild-card notation supported by [`Glob`][Glob].
134135
Output files are specified by using the custom symbol
135136
`(*)`. For example, the output path `output\assistant_(*).dart` is interpreted such that `(*)` is replaced with the input file name (excluding the file extension). For more details, see the file [`example\researcher_builder\builder.dart`][builder.dart].
136137

137-
Limitations: For builders extending [`StandaloneBuilder`][StandaloneBuilder] it is recommended to initiate the build command (see point 7 in the next section) from the root directory of the package the build is applied to.
138+
Limitations: For builders extending [`StandaloneBuilder`][StandaloneBuilder] it is recommended to initiate the build command
139+
from the root directory of the package the build is applied to.
138140
## Examples
139141

140142
For further information on how to use [`MergingBuilder`][MergingBuilder] see [example].
@@ -173,22 +175,16 @@ Please file feature requests and bugs at the [issue tracker].
173175

174176
[Glob]: https://pub.dev/packages/glob
175177

176-
[LibDir]: https://pub.dev/documentation/merging_builder/latest/merging_builder/LibDir-class.html
177-
178178
[MergingBuilder]: https://pub.dev/documentation/merging_builder/latest/merging_builder/MergingBuilder-class.html
179179

180180
[merging_builder]: https://pub.dev/packages/merging_builder
181181

182182
[MergingGenerator]: https://pub.dev/documentation/merging_builder/latest/merging_builder/MergingGenerator-class.html
183183

184-
[PackageDir]: https://pub.dev/documentation/merging_builder/latest/merging_builder/PackageDir-class.html
185-
186184
[researchers.dart]: https://github.com/simphotonics/merging_builder_example/blob/main/researcher/lib/output/researchers.dart
187185

188186
[source_gen]: https://pub.dev/packages/source_gen
189187

190188
[source_gen_test]: https://pub.dev/packages/source_gen_test
191189

192190
[StandaloneBuilder]: https://pub.dev/documentation/merging_builder/latest/merging_builder/StandaloneBuilder-class.html
193-
194-
[Writing a Builder using a synthetic input]: https://github.com/dart-lang/build/blob/master/docs/writing_an_aggregate_builder.md#writing-the-builder-using-a-synthetic-input

example/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
## Introduction
66

7-
The package [`merging_builder`][merging_builder] provides a Dart builder that reads **several input files** and writes the merged output to **one output file**.
7+
The package [`merging_builder`][merging_builder] provides a Dart builder that reads *several input files* and writes the merged output to *one output file*.
88

9-
The [example] presented here contains two packages. The package [`researcher_builder`][researcher_builder] depends on [`merging_builder`][merging_builder] in order to define the builder [`add_names_builder`][add_names_builder] and the merging generator [`add_names_generator`][add_names_generator].
9+
The projec provided as an [example] contains two packages:
10+
* The package [`researcher_builder`][researcher_builder] depends on [`merging_builder`][merging_builder] in order to define the builder [`add_names_builder`][add_names_builder] and the merging generator [`add_names_generator`][add_names_generator].
1011

11-
The package [`researcher`][researcher] depends on [`researcher_builder`][researcher_builder], specified as a *dev_dependency*, in order to access the builder [`add_names_builder`][add_names_builder] during the build process.
12+
* The package [`researcher`][researcher] depends on [`researcher_builder`][researcher_builder], specified as a *dev_dependency*, in order to access the builder [`add_names_builder`][add_names_builder] during the build process.
1213

1314
## Build Setup
1415

images/merging_builder.svg

Lines changed: 28 additions & 28 deletions
Loading

lib/src/builders/formatter.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// Typedef of a function that can be provided to
2-
/// [MergingBuilder] and [StandAloneBuilder]
2+
/// `MergingBuilder` and `StandAloneBuilder`
33
/// constructors in the form of the parameter `formatter`.
44
/// * The function is used to format the builder output before it
55
/// is written to a file.

0 commit comments

Comments
 (0)