Skip to content

Commit b82955c

Browse files
committed
Follow the authoring guide in the authoring guide
Let's follow our own rules in the authoring guide by, e.g., using `---` rather than the Unicode em-dash character, not wrapping lines, specifying the language for code block sections, etc. To improve formatting, we broke out some descriptions that were in code block sections into the main text. We replaced references to "the spec" with "the reference" for consistency, as that's what most of this document uses. And we made some other small editorial improvements.
1 parent 6c5c972 commit b82955c

File tree

1 file changed

+45
-38
lines changed

1 file changed

+45
-38
lines changed

docs/authoring.md

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
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].
3+
This document serves as a guide for editors and reviewers. Some conventions and content guidelines are specified in the [introduction].
54

65
[introduction]: ../src/introduction.md
76

@@ -12,16 +11,14 @@ Some conventions and content guidelines are specified in the [introduction].
1211
* Files must end with a newline.
1312
* Lines must not end with spaces. Double spaces have semantic meaning, but can be invisible. Use a trailing backslash if you need a hard line break.
1413
* If possible, avoid double blank lines.
15-
* Do not use indented code blocks, use 3+ backticks code blocks instead.
14+
* Do not use indented code blocks; use 3+ backticks code blocks instead.
1615
* Code blocks should have an explicit language tag.
1716
* Do not wrap long lines. This helps with reviewing diffs of the source.
1817
* 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.
18+
* Links should be relative with the `.md` extension. 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.
19+
* The use of reference links is preferred, with shortcuts if appropriate. Place the sorted link reference definitions at the bottom of the file, or at the bottom of a section if there are an unusually large number of links that are specific to the section.
2320

24-
```
21+
```markdown
2522
Example of shortcut link: [enumerations]
2623
Example of reference link with label: [block expression][block]
2724

@@ -33,32 +30,28 @@ Some conventions and content guidelines are specified in the [introduction].
3330
There are automated checks for some of these rules. Run `cargo run --manifest-path style-check/Cargo.toml -- src` to run them locally.
3431

3532
[atx]: https://spec.commonmark.org/0.31.2/#atx-headings
33+
[conventions]: ../src/introduction.md#conventions
3634
[sentence case]: https://apastyle.apa.org/style-grammar-guidelines/capitalization/sentence-case
3735
[smart punctuation]: https://rust-lang.github.io/mdBook/format/markdown.html#smart-punctuation
38-
[conventions]: ../src/introduction.md#conventions
3936

4037
### Code examples
4138

42-
Code examples should use code blocks with triple backticks.
43-
The language should always be specified (such as `rust`).
39+
Code examples should use code blocks with triple backticks. The language should always be specified (such as `rust`).
4440

4541
```rust
4642
println!("Hello!");
4743
```
4844

4945
See <https://rust-lang.github.io/mdBook/format/theme/syntax-highlighting.html#supported-languages> for a list of supported languages.
5046

51-
Rust examples are tested via rustdoc, and should include the appropriate annotations when tests are expected to fail:
47+
Rust examples are tested via rustdoc, and should include the appropriate annotations:
5248

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.
49+
* `edition2015` or `edition2018` --- If it is edition-specific (see `book.toml` for the default).
50+
* `no_run` --- The example should compile successfully, but should not be executed.
51+
* `should_panic` --- The example should compile and run, but produce a panic.
52+
* `compile_fail` --- The example is expected to fail to compile.
53+
* `ignore` --- The example shouldn't be built or tested. This should be avoided if possible. 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. An HTML comment such as `<!-- ignore: requires extern crate -->` should be placed before the example to explain why it is ignored.
54+
* `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.
6255

6356
See the [rustdoc documentation] for more detail.
6457

@@ -70,10 +63,9 @@ The following are extensions provided by [`mdbook-spec`](https://github.com/rust
7063

7164
### Rules
7265

73-
Most clauses should be preceded with a rule.
74-
Rules can be specified in the markdown source with the following on a line by itself:
66+
Most clauses should be preceded with a rule. Rules can be specified in the markdown source with the following on a line by itself:
7567

76-
```
68+
```markdown
7769
r[foo.bar]
7870
```
7971

@@ -87,18 +79,34 @@ In the HTML, the rules are clickable just like headers.
8779

8880
You should link to the standard library without specifying a URL in a fashion similar to [rustdoc intra-doc links][intra]. Some examples:
8981

82+
We can link to the page on `Option`:
83+
84+
```markdown
85+
[`std::option::Option`]
9086
```
91-
Link to Option is [`std::option::Option`]
9287

93-
You can include generics, they are ignored, like [`std::option::Option<T>`]
88+
In these links, generics are ignored and can be included:
9489

95-
You can shorthand things if you don't want the full path in the text,
96-
like [`Option`](std::option::Option).
90+
```markdown
91+
[`std::option::Option<T>`]
92+
```
9793

98-
Macros can use `!`, which also works for disambiguation,
99-
like [`alloc::vec!`] is the macro, not the module.
94+
If we don't want the full path in the text, we can write:
10095

101-
Explicit namespace disambiguation is also supported, such as [`std::vec`](mod@std::vec).
96+
```markdown
97+
[`Option`](std::option::Option)
98+
```
99+
100+
Macros can end in `!`. This can be helpful for disambiguation. For example, this refers to the macro rather than the module:
101+
102+
```markdown
103+
[`alloc::vec!`]
104+
```
105+
106+
Explicit namespace disambiguation is also supported:
107+
108+
```markdown
109+
[`std::vec`](mod@std::vec)
102110
```
103111

104112
[intra]: https://doc.rust-lang.org/rustdoc/write-documentation/linking-to-items-by-name.html
@@ -107,7 +115,7 @@ Explicit namespace disambiguation is also supported, such as [`std::vec`](mod@st
107115

108116
Admonitions use a style similar to GitHub-flavored markdown, where the style name is placed at the beginning of a blockquote, such as:
109117

110-
```
118+
```markdown
111119
> [!WARNING]
112120
> This is a warning.
113121
```
@@ -118,22 +126,21 @@ All this does is apply a CSS class to the blockquote. You should define the colo
118126

119127
Idioms and styling to avoid:
120128

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.
129+
* Avoid slashes for alternatives ("program/binary"); use conjunctions or rewrite it ("program or binary").
130+
* Avoid qualifying something as "in Rust"; the entire reference is about Rust.
123131

124132
## Content guidelines
125133

126-
The following are guidelines for the content of the spec.
134+
The following are guidelines for the content of the reference.
127135

128136
### Targets
129137

130-
The spec does not document which targets exist, or the properties of specific targets. The spec may refer to *platforms* or *target properties* where required by the language. Some examples:
138+
The reference does not document which targets exist, or the properties of specific targets. The reference may refer to *platforms* or *target properties* where required by the language. Some examples:
131139

132140
* Conditional-compilation keys like `target_os` are specified to exist, but not what their values must be.
133141
* The `windows_subsystem` attribute specifies that it only works on Windows platforms.
134142
* Inline assembly and the `target_feature` attribute specify the architectures that are supported.
135143

136144
### Editions
137145

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.
146+
The main text and flow should document only the current edition. Whenever there is a difference between editions, the differences should be called out with an "Edition Differences" block.

0 commit comments

Comments
 (0)