Skip to content

Commit 139538d

Browse files
authored
Merge pull request #4138 from rust-lang/code-style-updates-Here
Document use of rustfmt and dprint for formatting
2 parents cdfa587 + 18ef30b commit 139538d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

CONTRIBUTING.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,35 @@ of the print version. The snapshot files reflect what has been sent or not, so
1111
they only get updated when edits are sent to No Starch. **Do not submit pull
1212
requests changing files in the `nostarch` directory, they will be closed.**
1313

14+
We use [`rustfmt`][rustfmt] to apply standard formatting to Rust code in the
15+
repo and [`dprint`][dprint] to apply standing formatting to the Markdown source
16+
and the non-Rust code in the project.
17+
18+
[rustfmt]: https://github.com/rust-lang/rustfmt
19+
[dprint]: https://dprint.dev
20+
21+
You will normally have `rustfmt` installed if you have a Rust toolchain
22+
installed; if for some reason you do not have a copy of `rustfmt`, you can add
23+
it by running the following command:
24+
25+
```sh
26+
rustup component add rustfmt
27+
```
28+
29+
To install `dprint`, you can run the following command:
30+
31+
```sh
32+
cargo install dprint
33+
```
34+
35+
Or follow the [instructions][install-dprint] on the `dprint` website.
36+
37+
[install-dprint]: https://dprint.dev/install/
38+
39+
To format Rust code, you can run `rustfmt <path to file>`, and to format other
40+
files, you can pass `dprint <path to file>`. Many text editors also have native
41+
support or extensions for both `rustfmt` and `dprint`.
42+
1443
## Checking for Fixes
1544

1645
The book rides the Rust release trains. Therefore, if you see a problem on

0 commit comments

Comments
 (0)