Skip to content

Commit b5966e9

Browse files
committed
Merge the Reference style guide to the authoring guide.
1 parent 850cdf4 commit b5966e9

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ enough that we can remove the warning.
1616

1717
It is encouraged for you to read the [introduction] to familiarize yourself
1818
with the kind of content the reference is expected to contain and the
19-
conventions it uses. Also, the [style guide] provides more detailed guidelines
19+
conventions it uses. Also, the [Authoring Guide] provides more detailed guidelines
2020
for formatting and content.
2121

2222
## Critiquing the Reference
@@ -72,5 +72,5 @@ helpful for writing the documentation.
7272
[issue tracker]: https://github.com/rust-lang/reference/issues
7373
[playpen]: https://play.rust-lang.org/
7474
[rust-lang/rust]: https://github.com/rust-lang/rust/
75-
[style guide]: STYLE.md
75+
[Authoring Guide]: docs/authoring.md
7676
[unstable]: https://doc.rust-lang.org/nightly/unstable-book/

docs/authoring.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Authoring Guide
22

3+
This document serves as a guide for editors and reviewers.
4+
Some conventions and content guidelines are specified in the [introduction].
5+
6+
[introduction]: ../src/introduction.md
7+
38
## Markdown formatting
49

510
* Use [ATX-style headings][atx] (not Setext) with [sentence case].
@@ -11,15 +16,58 @@
1116
* Code blocks should have an explicit language tag.
1217
* Do not wrap long lines. This helps with reviewing diffs of the source.
1318
* Use [smart punctuation] instead of Unicode characters. For example, use `---` for em-dash instead of the Unicode character. Characters like em-dash can be difficult to see in a fixed-width editor, and some editors may not have easy methods to enter such characters.
19+
* Links should be relative with the `.md` extension.
20+
Links to other rust-lang books that are published with the reference or the standard library API should also be relative so that the linkchecker can validate them.
21+
* The use of reference links is preferred, with shortcuts if appropriate.
22+
Place the sorted link reference definitions at the bottom of the file, or at the bottom of a section if there is an unusually large number of links that are specific to the section.
23+
24+
```
25+
Example of shortcut link: [enumerations]
26+
Example of reference link with label: [block expression][block]
1427
15-
There are automated checks for some of these rules. Run `cargo run --manifest-path style-check/Cargo.toml -- spec` to run them locally.
28+
[block]: expressions/block-expr.md
29+
[enumerations]: types/enum.md
30+
```
31+
* See the [Conventions] section for formatting callouts such as notes, edition differences, and warnings.
32+
33+
There are automated checks for some of these rules. Run `cargo run --manifest-path style-check/Cargo.toml -- src` to run them locally.
1634
1735
[atx]: https://spec.commonmark.org/0.31.2/#atx-headings
1836
[sentence case]: https://apastyle.apa.org/style-grammar-guidelines/capitalization/sentence-case
1937
[smart punctuation]: https://rust-lang.github.io/mdBook/format/markdown.html#smart-punctuation
38+
[conventions]: ../src/introduction.md#conventions
39+
40+
### Code examples
41+
42+
Code examples should use code blocks with triple backticks.
43+
The language should always be specified (such as `rust`).
44+
45+
```rust
46+
println!("Hello!");
47+
```
48+
49+
See <https://rust-lang.github.io/mdBook/format/theme/syntax-highlighting.html#supported-languages> for a list of supported languages.
50+
51+
Rust examples are tested via rustdoc, and should include the appropriate annotations when tests are expected to fail:
52+
53+
* `edition2015` or `edition2018` — If it is edition-specific (see `book.toml` for the default).
54+
* `no_run` — The example should compile successfully, but should not be executed.
55+
* `should_panic` — The example should compile and run, but produce a panic.
56+
* `compile_fail` — The example is expected to fail to compile.
57+
* `ignore` — The example shouldn't be built or tested.
58+
This should be avoided if possible.
59+
Usually this is only necessary when the testing framework does not support it (such as external crates or modules, or a proc-macro), or it contains pseudo-code which is not valid Rust.
60+
An HTML comment such as `<!-- ignore: requires extern crate -->` should be placed before the example to explain why it is ignored.
61+
* `Exxxx` — If the example is expected to fail to compile with a specific error code, include that code so that rustdoc will check that the expected code is used.
62+
63+
See the [rustdoc documentation] for more detail.
64+
65+
[rustdoc documentation]: https://doc.rust-lang.org/rustdoc/documentation-tests.html
2066

2167
## Special markdown constructs
2268

69+
The following are extensions provided by [`mdbook-spec`](https://github.com/rust-lang/spec/tree/main/mdbook-spec).
70+
2371
### Rules
2472

2573
Most clauses should be preceded with a rule.
@@ -66,6 +114,13 @@ Admonitions use a style similar to GitHub-flavored markdown, where the style nam
66114

67115
All this does is apply a CSS class to the blockquote. You should define the color or style of the rule in the `css/custom.css` file if it isn't already defined.
68116

117+
## Style
118+
119+
Idioms and styling to avoid:
120+
121+
* Avoid slashes for alternatives ("program/binary"), use conjunctions or rewrite it ("program or binary").
122+
* Avoid qualifying something as "in Rust", the entire reference is about Rust.
123+
69124
## Content guidelines
70125

71126
The following are guidelines for the content of the spec.
@@ -77,3 +132,8 @@ The spec does not document which targets exist, or the properties of specific ta
77132
* Conditional-compilation keys like `target_os` are specified to exist, but not what their values must be.
78133
* The `windows_subsystem` attribute specifies that it only works on Windows platforms.
79134
* Inline assembly and the `target_feature` attribute specify the architectures that are supported.
135+
136+
### Editions
137+
138+
The main text and flow should document only the current edition.
139+
Whenever there is a difference between editions, the differences should be called out with an "Edition Differences" block.

0 commit comments

Comments
 (0)