You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-22Lines changed: 18 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,13 +13,13 @@ and methods during the build process.
13
13
14
14
The library [`merging_builder`][merging_builder] includes the following (synthetic input) builder classes:
15
15
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.
18
18
19
19
*[`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
23
23
be configured (as opposed to using part files).
24
24
25
25
@@ -32,19 +32,19 @@ In the [example] project provided, the package defining a new
32
32
builder is called `researcher_builder` and the package using this builder is called `researcher`.
33
33
To set up a build system the following steps are required:
34
34
35
-
### Builder Package Setup
35
+
### 1. Builder Package Setup
36
36
37
37
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].
38
38
39
39
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].
40
40
41
41
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.
42
42
* 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)).
44
44
45
45
4. Add a builder configuration: The build extensions for
46
46
[`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
48
48
input files are located in the folder `lib` or a subfolder thereof.
49
49
```Yaml
50
50
builders:
@@ -62,15 +62,16 @@ input files are located in the folder `lib` or a subfolder thereof.
62
62
build_to: source
63
63
```
64
64
65
-
### User Package Setup
65
+
### 2. User Package Setup
66
66
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:
68
68
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`.
70
71
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.
74
75
75
76
```Yaml
76
77
targets:
@@ -109,7 +110,7 @@ use *synthetic input*.
109
110
110
111
### Merging Builder
111
112
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*.
113
114
The builder provides the option to sort the input files in reverse topological order.
114
115
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
115
116
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].
134
135
Output files are specified by using the custom symbol
135
136
`(*)`. 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].
136
137
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.
138
140
## Examples
139
141
140
142
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].
[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
Copy file name to clipboardExpand all lines: example/README.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,12 @@
4
4
5
5
## Introduction
6
6
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*.
8
8
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].
10
11
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.
0 commit comments