Skip to content

Commit 276d3ec

Browse files
authored
Merge pull request #2097 from ehuss/contributor-guide
Add a contributor guide
2 parents addd060 + a6c672d commit 276d3ec

31 files changed

Lines changed: 929 additions & 570 deletions

.github/workflows/dev-guide.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Deploy dev-guide
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
env:
8+
MDBOOK_VERSION: 0.5.2
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v6
15+
16+
- name: Install mdbook
17+
run: |
18+
mkdir mdbook
19+
curl -Lf https://github.com/rust-lang/mdBook/releases/download/v${{ env.MDBOOK_VERSION }}/mdbook-v${{ env.MDBOOK_VERSION }}-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
20+
echo `pwd`/mdbook >> $GITHUB_PATH
21+
22+
- name: Build the book
23+
run: |
24+
cd dev-guide
25+
mdbook build
26+
mkdir out
27+
touch out/.nojekyll
28+
mv book out/dev-guide
29+
30+
- name: Upload Artifact
31+
uses: actions/upload-pages-artifact@v3
32+
with:
33+
path: ./dev-guide/out
34+
35+
deploy:
36+
needs: build
37+
38+
permissions:
39+
pages: write
40+
id-token: write
41+
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}
45+
46+
runs-on: ubuntu-latest
47+
steps:
48+
- id: deployment
49+
uses: actions/deploy-pages@v4

.github/workflows/main.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
merge_group:
55

66
env:
7-
MDBOOK_VERSION: 0.5.1
7+
MDBOOK_VERSION: 0.5.2
88

99
jobs:
1010
code-tests:
@@ -97,6 +97,23 @@ jobs:
9797
- name: Test tools
9898
run: cargo test
9999

100+
dev-guide:
101+
name: dev-guide build check
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@master
105+
- name: Install mdbook
106+
env:
107+
MDBOOK_VERSION: 0.5.1
108+
run: |
109+
mkdir bin
110+
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
111+
echo "$(pwd)/bin" >> $GITHUB_PATH
112+
- name: Check dev-guide build
113+
run: |
114+
cd dev-guide
115+
mdbook build
116+
100117
preview:
101118
if: github.event_name == 'pull_request'
102119
runs-on: ubuntu-latest
@@ -143,6 +160,7 @@ jobs:
143160
- code-tests
144161
- style-tests
145162
- mdbook-spec
163+
- dev-guide
146164
# preview is explicitly excluded here since it doesn't run on merge
147165
runs-on: ubuntu-latest
148166
steps:

CONTRIBUTING.md

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,3 @@
1-
Thank you for your interest in contributing to the Rust Reference!
1+
# Contributing to The Rust Reference
22

3-
There are a few ways of helping with the reference: critiquing the reference,
4-
editing the reference, fixing incorrect information, adding examples and
5-
glossary entries, and documenting new or otherwise undocumented features in
6-
Rust.
7-
8-
For a while, the Reference was basically ignored, and Rust continued gaining new
9-
features or changing old ones. It was also basically the introduction document
10-
before the first edition of the Rust book, and constantly in flux from the huge
11-
churn of the language design before v1.0.0. So there's a lot that's wrong, too
12-
teachy for people who should have basic understanding of Rust, or is too shallow
13-
for the Reference. As such, we have the warning saying there's work that needs
14-
to be done. Eventually, we plan to make sure everything is well documented
15-
enough that we can remove the warning.
16-
17-
It is encouraged for you to read the [introduction] to familiarize yourself with
18-
the kind of content the reference is expected to contain and the conventions it
19-
uses. Also, the [Authoring Guide] provides more detailed guidelines for
20-
formatting and content.
21-
22-
## Critiquing the Reference
23-
24-
This is the easiest way to contribute. Basically, as you read the reference, if
25-
you find something confusing, incorrect, or missing, then you can file an issue
26-
against the reference explaining your concerns.
27-
28-
## Editing the Reference
29-
30-
Typos and incorrect links get through from time to time. Should you find them,
31-
we welcome PRs to fix them. Additionally, larger editing jobs that help remove
32-
the number of parentheticals, remove comma splices, italicize term definitions
33-
and other similar tasks are helpful.
34-
35-
## Adding examples and glossary entries
36-
37-
Examples are great. Many people will only read examples and ignore the prose.
38-
Ideally, every facet of every feature will have an example.
39-
40-
Likewise, the reference has a glossary. It doesn't need to explain every facet
41-
of every feature nor contain every definition, but it does need to be expanded
42-
upon. Ideally entries in the glossary link to the associated documentation.
43-
44-
## Adding documentation
45-
46-
There are a lot of features that are not documented at all or are documented
47-
poorly. This is the hardest, but definitely most valuable. Pick an unassigned
48-
issue from the [issue tracker], and write about it.
49-
50-
While writing, you may find it handy to have a [playpen] open to test out what
51-
you are documenting.
52-
53-
Feel free to take information from the standard library and Rustonomicon as
54-
appropriate.
55-
56-
Note that we don't write documentation for purely library features such as
57-
threads and IO and we don't write about Rust in the future. Documentation is
58-
written as if the current stable release of Rust is the last release. The
59-
`master` branch of the reference corresponds to what is **stable** on the
60-
`master` branch ("nightly") of [rust-lang/rust]. If you want to write about
61-
Rust in the future, you want [the Unstable book][unstable].
62-
63-
## Stabilization
64-
65-
When something that alters the language is stabilized, an issue should be
66-
opened on the reference [issue tracker] to track the documentation process.
67-
This should include links to any relevant information, such as the
68-
stabilization PR, the RFC, the tracking issue, and anything else that would be
69-
helpful for writing the documentation.
70-
71-
[Authoring Guide]: docs/authoring.md
72-
[introduction]: src/introduction.md
73-
[issue tracker]: https://github.com/rust-lang/reference/issues
74-
[playpen]: https://play.rust-lang.org/
75-
[rust-lang/rust]: https://github.com/rust-lang/rust/
76-
[unstable]: https://doc.rust-lang.org/nightly/unstable-book/
3+
See the [Reference Developer Guide](https://rust-lang.github.io/reference/dev-guide/) for information on contributing to the Reference.

README.md

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -4,91 +4,4 @@ This document is the primary reference for the Rust programming language.
44

55
## Contributor docs
66

7-
There are several pages for those working on the reference:
8-
9-
* [Authoring guide](https://github.com/rust-lang/reference/blob/master/docs/authoring.md): Guidelines for writing content.
10-
* [Review policy](https://github.com/rust-lang/reference/blob/master/docs/review-policy.md): Guidelines for reviewers.
11-
* [Grammar](https://github.com/rust-lang/reference/blob/master/docs/grammar.md): How the grammar syntax works.
12-
* [Attribute template](https://github.com/rust-lang/reference/blob/master/docs/attribute-template.md): The standard template for documenting an attribute.
13-
14-
## Building
15-
16-
To build the Reference, first clone the project:
17-
18-
```sh
19-
git clone https://github.com/rust-lang/reference.git
20-
cd reference
21-
```
22-
23-
(Alternatively, if you don't want to use `git`, [download][] a ZIP file
24-
of the project, extract it using your preferred tool, and rename the
25-
top-level directory to `reference`.)
26-
27-
[download]: https://github.com/rust-lang/reference/archive/refs/heads/master.zip
28-
29-
### Installing mdbook
30-
31-
The Reference is built using [mdbook].
32-
33-
First, ensure that you have a recent copy of the nightly Rust compiler installed, as this is needed in order to run the tests:
34-
35-
```sh
36-
rustup toolchain install nightly
37-
rustup override set nightly
38-
```
39-
40-
Now, ensure you have `mdbook` installed, as this is needed in order to build the Reference:
41-
42-
```sh
43-
cargo install --locked mdbook
44-
```
45-
46-
[mdbook]: https://rust-lang.github.io/mdBook/
47-
48-
### Running mdbook
49-
50-
`mdbook` provides a variety of different commands and options to help you work on the book:
51-
52-
* `mdbook build --open`: Build the book and open it in a web browser.
53-
* `mdbook serve --open`: Launches a web server on localhost. It also automatically rebuilds the book whenever any file changes and automatically reloads your web browser.
54-
55-
The book contents are driven by a `SUMMARY.md` file, and every file must be linked there. See <https://rust-lang.github.io/mdBook/> for its usage.
56-
57-
### `SPEC_RELATIVE`
58-
59-
The `SPEC_RELATIVE=0` environment variable makes links to the standard library go to <https://doc.rust-lang.org/> instead of being relative, which is useful when viewing locally since you normally don't have a copy of the standard library.
60-
61-
```sh
62-
SPEC_RELATIVE=0 mdbook serve --open
63-
```
64-
65-
The published site at <https://doc.rust-lang.org/reference/> (or local docs using `rustup doc`) does not set this, which means it will use relative links which supports offline viewing and links to the correct version (for example, links in <https://doc.rust-lang.org/1.81.0/reference/> will stay within the 1.81.0 directory).
66-
67-
### `SPEC_DENY_WARNINGS`
68-
69-
The `SPEC_DENY_WARNINGS=1` environment variable will turn all warnings generated by `mdbook-spec` to errors. This is used in CI to ensure that there aren't any problems with the book content.
70-
71-
### `SPEC_RUST_ROOT`
72-
73-
The `SPEC_RUST_ROOT` can be used to point to the directory of a checkout of <https://github.com/rust-lang/rust>. This is used by the test-linking feature so that it can find tests linked to reference rules. If this is not set, then the tests won't be linked.
74-
75-
## Running tests
76-
77-
There are several different kinds of tests you can run (these are enforced on CI):
78-
79-
* `mdbook test`: This will run the inline Rust codeblocks (internally it uses `rustdoc` to do this).
80-
* `cargo xtask style-check`: This will validate some style checks (see [authoring guide](docs/authoring.md)).
81-
* `cargo xtask linkcheck`: This will validate that markdown links aren't broken.
82-
* `cargo xtask test-all`: Runs all tests.
83-
84-
## How is this published?
85-
86-
The process for getting the reference content into a [Rust release](https://doc.rust-lang.org/reference/#rust-releases) and on the website is:
87-
88-
1. Changes are merged to this repository.
89-
2. [Triagebot](https://forge.rust-lang.org/triagebot/doc-updates.html) will automatically synchronize this repository to [rust-lang/rust]. This happens every other week. The reference is tracked in [rust-lang/rust] as a [submodule](https://github.com/rust-lang/rust/tree/master/src/doc).
90-
- This will open a PR on [rust-lang/rust] which needs to be merged, and that can take up to several days.
91-
3. At midnight UTC, whatever is on the default branch of [rust-lang/rust] will be a part of that nightly release, and will be published after a few hours to <https://doc.rust-lang.org/nightly/reference/>.
92-
4. Following Rust's [release process](https://doc.rust-lang.org/book/appendix-07-nightly-rust.html), every 6 weeks, nightly will be promoted to beta (<https://doc.rust-lang.org/beta/reference/>), and then 6 weeks after that it will be promoted to stable (<https://doc.rust-lang.org/stable/reference/>).
93-
94-
[rust-lang/rust]: https://github.com/rust-lang/rust/
7+
See the [Reference Developer Guide](https://rust-lang.github.io/reference/dev-guide/) for information on contributing to the Reference.

STYLE.md

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

dev-guide/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# The Rust Reference Developer Guide
2+
3+
This is the source of the Reference Developer Guide, published at <https://rust-lang.github.io/reference/dev-guide/>. It is written in Markdown using [mdbook]. If you are editing these pages, the best way to view them is to run `mdbook serve --open`. This will start a web server on localhost that you can visit to view the book; it will automatically reload each time you edit a page.
4+
5+
This is published via GitHub Actions to GitHub Pages.
6+
7+
[mdbook]: https://rust-lang.github.io/mdBook/

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+
title = "The Rust Reference Developer Guide"
3+
language = "en"
4+
5+
[output.html]
6+
git-repository-url = "https://github.com/rust-lang/reference/tree/master/dev-guide"
7+
edit-url-template = "https://github.com/rust-lang/reference/edit/master/dev-guide/{path}"
8+
smart-punctuation = true
9+
10+
[output.html.search]
11+
use-boolean-and = true

dev-guide/src/SUMMARY.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Summary
2+
3+
- [Introduction](introduction.md)
4+
- [Contribution process](process/index.md)
5+
- [Stabilization process](process/stabilization.md)
6+
- [Publishing process](publishing.md)
7+
- [Reference tooling](tooling/index.md)
8+
- [Building the Reference](tooling/building.md)
9+
- [mdbook-spec](tooling/mdbook-spec.md)
10+
- [Tests](tests.md)
11+
- [Formatting](formatting/index.md)
12+
- [Markdown](formatting/markdown.md)
13+
- [Admonitions](formatting/admonitions.md)
14+
- [Language rules](rules/index.md)
15+
- [rustc test annotations](rules/test-annotations.md)
16+
- [Examples](examples.md)
17+
- [Links](links.md)
18+
- [Rust grammar](grammar.md)
19+
- [Attributes](attributes.md)
20+
- [Style guide](style.md)
21+
- [Review policy](review-policy.md)
22+
- [Resources](resources.md)

0 commit comments

Comments
 (0)