Skip to content

Commit 04b72ff

Browse files
committed
Migrate CONTRIBUTING.md to an mdbook
We had a suggestion that the dev docs would be easier to read if there was a table of contents. Rather than making one by hand I thought using mdbook would be better.
1 parent 285929f commit 04b72ff

File tree

14 files changed

+424
-355
lines changed

14 files changed

+424
-355
lines changed

.github/workflows/deploy-docs.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ on:
66
- stable
77
- master
88

9-
# Builds docs for both stable and master branches.
10-
# stable is placed in the root of the gh-pages branch, while master is placed at /devel
9+
# Builds all docs for both stable and master branches.
10+
# In the gh-pages branch, we place:
11+
# stable user-guide at /
12+
# master user-guide at /devel
13+
# master dev-guide at /dev-guide
1114

1215
jobs:
1316
doc:
@@ -36,6 +39,10 @@ jobs:
3639
cd doc/user-guide
3740
mdbook build
3841
mv book ${{ runner.temp }}/book/devel
42+
# Build dev-guide for master
43+
cd ../dev-guide
44+
mdbook build
45+
mv book ${{ runner.temp }}/book/dev-guide
3946
- name: Deploy to GitHub
4047
run: |
4148
cd ${{ runner.temp }}/book

.github/workflows/test-docs.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ jobs:
2121
mkdir mdbook
2222
curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.6/mdbook-v0.4.6-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
2323
echo "`pwd`/mdbook" >> $GITHUB_PATH
24-
- name: Build book
24+
- name: Build user-guide
2525
run: |
2626
cd doc/user-guide
27+
mdbook build
28+
- name: Build dev-guide
29+
run: |
30+
cd doc/dev-guide
2731
mdbook build

CONTRIBUTING.md

Lines changed: 0 additions & 351 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ documentation on installing and using Rustup.
2121

2222
## Contributing
2323

24-
See [CONTRIBUTING.md](CONTRIBUTING.md) for information on contributing to Rustup.
24+
See [**The Rustup dev guide**](https://rust-lang.github.io/rustup/dev-guide) for information on contributing to Rustup.
2525

2626
## License
2727

doc/dev-guide/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
book

doc/dev-guide/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# rustup documentation
2+
3+
This directory contains rustup's developer / contributing documentation.
4+
5+
## Building the book
6+
7+
Building the book requires [mdBook](https://github.com/rust-lang/mdBook). To get it:
8+
9+
```console
10+
$ cargo install mdbook
11+
```
12+
13+
To build the book:
14+
15+
```console
16+
$ mdbook build
17+
```
18+
19+
`mdbook` provides a variety of different commands and options to help you work
20+
on the book:
21+
22+
* `mdbook build --open`: Build the book and open it in a web browser.
23+
* `mdbook serve`: Launches a web server on localhost. It also automatically
24+
rebuilds the book whenever any file changes and automatically reloads your
25+
web browser.
26+
27+
The book contents are driven by the [`SUMMARY.md`](src/SUMMARY.md) file, and
28+
every file must be linked there.

doc/dev-guide/book.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[book]
2+
authors = ["The Rust Project Developers"]
3+
language = "en"
4+
multilingual = false
5+
src = "src"
6+
title = "The Rustup developer guide"
7+
8+
[output.html]
9+
edit-url-template = "https://github.com/rust-lang/rustup/edit/master/doc/dev-guide/{path}"
10+
git-repository-url = "https://github.com/rust-lang/rustup/tree/master/doc/dev-guide"
11+
site-url = "https://rust-lang.github.io/rustup/dev-guide"

doc/dev-guide/src/SUMMARY.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Summary
2+
3+
- [Introduction](index.md)
4+
- [Coding standards](coding-standards.md)
5+
- [Version numbers](version-numbers.md)
6+
- [Release process](release-process.md)
7+
- [Tips and tricks](tips-and-tricks.md)
8+
- [Tracing](tracing.md)

doc/dev-guide/src/coding-standards.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
# Coding standards
3+
4+
Generally we just follow good sensible Rust practices, clippy and so forth.
5+
However there are some practices we've agreed on that are not machine-enforced;
6+
meeting those requirements in a PR will make it easier to merge.
7+
8+
## Import grouping
9+
10+
In each file the imports should be grouped into at most 4 groups in the
11+
following order:
12+
13+
1. stdlib
14+
2. non-repository local crates
15+
3. repository local other crates
16+
4. this crate
17+
18+
Separate each group with a blank line, and rustfmt will sort into a canonical
19+
order. Any file that is not grouped like this can be rearranged whenever the
20+
file is touched - we're not precious about having it done in a separate commit,
21+
though that is helpful.
22+
23+
## No direct use of process state outside rustup::currentprocess
24+
25+
The `rustup::currentprocess` module abstracts the global state that is
26+
`std::env::args`, `std::env::vars`, `std::io::std*`, `std::process::id`,
27+
`std::env::current_dir` and `std::process::exit` permitting threaded tests of
28+
the CLI logic; use `process()` rather than those APIs directly.
29+
30+
## Clippy lints
31+
32+
We do not enforce lint status in the checks done by GitHub Actions, because
33+
clippy is a moving target that can make it hard to merge for little benefit.
34+
35+
We do ask that contributors keep the clippy status clean themselves.
36+
37+
Minimally, run `cargo +beta clippy --all --all-targets -- -D warnings` before
38+
submitting code.
39+
40+
If possible, adding `--all-features` to the command is useful, but will require
41+
additional dependencies like `libcurl-dev`.
42+
43+
Regular contributors or contributors to particularly OS-specific code should
44+
also make sure that their clippy checking is done on at least Linux and Windows,
45+
as OS-conditional code is a common source of unused imports and other small
46+
lints, which can build up over time.
47+
48+
For developers using BSD/Linux/Mac OS, there are Windows VM's suitable for such
49+
development tasks for use with virtualbox and other hypervisors are downloadable
50+
from
51+
[Microsoft](https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/).
52+
Similarly, there are many Linux and Unix operating systems images available for
53+
developers whose usual operating system is Windows. Currently Rustup has no Mac
54+
OS specific code, so there should be no need to worry about Mac VM images.
55+
56+
Clippy is also run in GitHub Actions, in the `General Checks / Checks` build
57+
task, but not currently run per-platform, which means there is no way to find
58+
out the status of clippy per platform without running it on that platform as a
59+
developer.
60+
61+
### import rustup-macros::{integration,unit}_test into test modules
62+
63+
These test helpers add pre-and-post logic to tests to enable the use of tracing
64+
inside tests, which can be helpful for tracking down behaviours in larger tests.

doc/dev-guide/src/index.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Contributing to rustup
2+
3+
1. Fork it!
4+
2. Create your feature branch: `git checkout -b my-new-feature`
5+
3. Test it: `cargo test --features=test`
6+
4. Lint it: `cargo +beta clippy --all --all-targets -- -D warnings`
7+
8+
> We use `cargo clippy` to ensure high-quality code and to enforce a set of best practices for Rust programming. However, not all lints provided by `cargo clippy` are relevant or applicable to our project.
9+
> We may choose to ignore some lints if they are unstable, experimental, or specific to our project.
10+
> If you are unsure about a lint, please ask us in the [rustup Discord channel](https://discord.com/channels/442252698964721669/463480252723888159).
11+
12+
5. Commit your changes: `git commit -am 'Add some feature'`
13+
6. Push to the branch: `git push origin my-new-feature`
14+
7. Submit a pull request :D
15+
16+
For developing on `rustup` itself, you may want to install into a temporary
17+
directory, with a series of commands similar to this:
18+
19+
```bash
20+
cargo build
21+
mkdir home
22+
RUSTUP_HOME=home CARGO_HOME=home target/debug/rustup-init --no-modify-path -y
23+
```
24+
25+
You can then try out `rustup` with your changes by running `home/bin/rustup`, without
26+
affecting any existing installation. Remember to keep those two environment variables
27+
set when running your compiled `rustup-init` or the toolchains it installs, but _unset_
28+
when rebuilding `rustup` itself.
29+
30+
If you wish to install your new build to try out longer term in your home directory
31+
then you can run `cargo dev-install` which is an alias in `.cargo/config` which
32+
runs `cargo run -- --no-modify-path -y` to install your build into your homedir.
33+
34+
We use `rustfmt` to keep our codebase consistently formatted. Please ensure that
35+
you have correctly formatted your code (most editors will do this automatically
36+
when saving) or it may not pass the CI tests.
37+
38+
Unless you explicitly state otherwise, any contribution intentionally
39+
submitted for inclusion in the work by you, as defined in the
40+
Apache-2.0 license, shall be dual licensed as in the README, without any
41+
additional terms or conditions.

0 commit comments

Comments
 (0)