You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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].
5
4
6
5
[introduction]: ../src/introduction.md
7
6
@@ -12,16 +11,14 @@ Some conventions and content guidelines are specified in the [introduction].
12
11
* Files must end with a newline.
13
12
* 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.
14
13
* 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.
16
15
* Code blocks should have an explicit language tag.
17
16
* Do not wrap long lines. This helps with reviewing diffs of the source.
18
17
* 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.
23
20
24
-
```
21
+
```markdown
25
22
Example of shortcut link: [enumerations]
26
23
Example of reference link with label: [block expression][block]
27
24
@@ -33,32 +30,28 @@ Some conventions and content guidelines are specified in the [introduction].
33
30
There are automated checks for some of these rules. Run `cargo run --manifest-path style-check/Cargo.toml -- src` to run them locally.
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`).
44
40
45
41
```rust
46
42
println!("Hello!");
47
43
```
48
44
49
45
See <https://rust-lang.github.io/mdBook/format/theme/syntax-highlighting.html#supported-languages> for a list of supported languages.
50
46
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:
52
48
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.
62
55
63
56
See the [rustdoc documentation] for more detail.
64
57
@@ -70,10 +63,9 @@ The following are extensions provided by [`mdbook-spec`](https://github.com/rust
70
63
71
64
### Rules
72
65
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:
75
67
76
-
```
68
+
```markdown
77
69
r[foo.bar]
78
70
```
79
71
@@ -87,18 +79,34 @@ In the HTML, the rules are clickable just like headers.
87
79
88
80
You should link to the standard library without specifying a URL in a fashion similar to [rustdoc intra-doc links][intra]. Some examples:
89
81
82
+
We can link to the page on `Option`:
83
+
84
+
```markdown
85
+
[`std::option::Option`]
90
86
```
91
-
Link to Option is [`std::option::Option`]
92
87
93
-
You can include generics, they are ignored, like [`std::option::Option<T>`]
88
+
In these links, genericsare ignored and can be included:
94
89
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
+
```
97
93
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:
100
95
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,7 +115,7 @@ Explicit namespace disambiguation is also supported, such as [`std::vec`](mod@st
107
115
108
116
Admonitions use a style similar to GitHub-flavored markdown, where the style name is placed at the beginning of a blockquote, such as:
109
117
110
-
```
118
+
```markdown
111
119
> [!WARNING]
112
120
> This is a warning.
113
121
```
@@ -118,22 +126,21 @@ All this does is apply a CSS class to the blockquote. You should define the colo
118
126
119
127
Idioms and styling to avoid:
120
128
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.
123
131
124
132
## Content guidelines
125
133
126
-
The following are guidelines for the content of the spec.
134
+
The following are guidelines for the content of the reference.
127
135
128
136
### Targets
129
137
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:
131
139
132
140
* Conditional-compilation keys like `target_os` are specified to exist, but not what their values must be.
133
141
* The `windows_subsystem` attribute specifies that it only works on Windows platforms.
134
142
* Inline assembly and the `target_feature` attribute specify the architectures that are supported.
135
143
136
144
### Editions
137
145
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