Skip to content

Commit 41d651b

Browse files
committed
doc: Describe Ctrl+Z / fg workflow on build_runner
This is handy, and I've taught it a few times one-on-one. Write it down so it's more readily discoverable.
1 parent f5d09c4 commit 41d651b

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

README.md

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,26 +226,57 @@ good time to [report them as issues][dart-test-tracker].
226226

227227
### Editing API types
228228

229-
We support Zulip Server 4.0 and later. For API features added in
230-
newer versions, use `TODO(server-N)` comments (like those you see
231-
in the existing code.)
229+
#### Server compatibility
232230

233-
When editing the files in `lib/api/model/`, use the following command
234-
to keep the generated files up to date:
235-
```
236-
$ dart run build_runner watch --delete-conflicting-outputs
237-
```
231+
We support Zulip Server 4.0 and later.
232+
233+
For API features added in newer versions, use `TODO(server-N)`
234+
comments (like those you see in the existing code.)
235+
236+
237+
#### Require all parameters in API constructors
238238

239239
In our API types, constructors should generally avoid default values for
240240
their parameters, even `null`. This means writing e.g. `required this.foo`
241241
rather than just `this.foo`, even when `foo` is nullable.
242-
This is because it's common in the Zulip API for a null or missing value
242+
243+
We do this because it's common in the Zulip API for a null or missing value
243244
to be quite salient in meaning, and not a boring value appropriate for a
244245
default, so that it's best to ensure callers make an explicit choice.
246+
245247
If passing explicit values in tests is cumbersome, a factory function
246248
in `test/example_data.dart` is an appropriate way to share defaults.
247249

248250

251+
#### Generated files
252+
253+
When editing any of the type definitions in our API, you'll need to
254+
keep up to date the corresponding generated code
255+
(which handles converting JSON to and from our types).
256+
257+
To do this, run the following command:
258+
```
259+
$ dart run build_runner watch --delete-conflicting-outputs
260+
```
261+
262+
That `build_runner watch` command watches for changes
263+
in relevant files and updates the generated code as needed.
264+
265+
When the `build_runner watch` command has finished its work and
266+
is waiting for more changes, you may find it convenient to
267+
suspend it by pressing Ctrl+Z before you edit the code further.
268+
While suspended, the command will not run.
269+
After editing the source files further, you can update the
270+
generated files again by running the command `fg` in the
271+
terminal where `build_runner watch` had been running.
272+
The `fg` command causes the suspended command to resume running
273+
(in the foreground, hence the name `fg`), just like it was doing
274+
before Ctrl+Z.
275+
276+
If a PR is missing required updates to these generated files,
277+
CI will fail at the `build_runner` suite.
278+
279+
249280
### Upgrading Flutter
250281

251282
We regularly increment our lower bounds on Flutter and Dart versions,

0 commit comments

Comments
 (0)