Skip to content

Commit 30cb211

Browse files
committed
Move standard library links to the links chapter
1 parent cd8c177 commit 30cb211

File tree

3 files changed

+38
-28
lines changed

3 files changed

+38
-28
lines changed

contributor-guide/src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
- [Admonitions](formatting/admonitions.md)
1313
- [Language rules]()
1414
- [rustc test annotations]()
15-
- [Examples]()
15+
- [Examples](examples.md)
1616
- [Links]()
1717
- [Rust grammar](grammar.md)
1818
- [Attributes](attributes.md)

contributor-guide/src/examples.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Examples
2+
3+
## Example code blocks
4+
5+
Code examples should use code blocks with triple backticks. The language should always be specified (such as `rust`).
6+
7+
```rust
8+
println!("Hello!");
9+
```
10+
11+
See the [mdBook supported languages] for a list of supported languages.
12+
13+
## rustdoc attributes
14+
15+
Rust examples are [tested via rustdoc], and should include the appropriate annotations:
16+
17+
- `edition2015`, `edition2018`, etc. --- If it is edition-specific (see `book.toml` for the default).
18+
- `no_run` --- The example should compile successfully, but should not be executed.
19+
- `should_panic` --- The example should compile and run, but produce a panic.
20+
- `compile_fail` --- The example is expected to fail to compile.
21+
- `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.
22+
- `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.
23+
24+
See the [rustdoc documentation] for more detail.
25+
26+
## Combining examples
27+
28+
When demonstrating success cases, many such cases may be included in a single code block. For failure cases, however, each example must appear in a separate code block so that the tests can ensure that each case indeed fails and fails with the appropriate error code or codes.
29+
30+
## Testing examples
31+
32+
The Rust code blocks are tested in CI. You can verify the samples pass by running [`mdbook test`].
33+
34+
[`mdbook test`]: tests.md#inline-tests
35+
[mdBook supported languages]: https://rust-lang.github.io/mdBook/format/theme/syntax-highlighting.html#supported-languages
36+
[rustdoc documentation]: https://doc.rust-lang.org/rustdoc/documentation-tests.html
37+
[tested via rustdoc]: tests.md#inline-tests

docs/authoring.md

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,6 @@ This document serves as a guide for editors and reviewers. Some conventions and
44

55
[introduction]: ../src/introduction.md
66

7-
### Code examples
8-
9-
Code examples should use code blocks with triple backticks. The language should always be specified (such as `rust`).
10-
11-
```rust
12-
println!("Hello!");
13-
```
14-
15-
See <https://rust-lang.github.io/mdBook/format/theme/syntax-highlighting.html#supported-languages> for a list of supported languages.
16-
17-
Rust examples are tested via rustdoc, and should include the appropriate annotations:
18-
19-
* `edition2015`, `edition2018`, etc. --- If it is edition-specific (see `book.toml` for the default).
20-
* `no_run` --- The example should compile successfully, but should not be executed.
21-
* `should_panic` --- The example should compile and run, but produce a panic.
22-
* `compile_fail` --- The example is expected to fail to compile.
23-
* `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.
24-
* `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.
25-
26-
When demonstrating success cases, many such cases may be included in a single code block. For failure cases, however, each example must appear in a separate code block so that the tests can ensure that each case indeed fails and fails with the appropriate error code or codes.
27-
28-
See the [rustdoc documentation] for more detail.
29-
30-
[rustdoc documentation]: https://doc.rust-lang.org/rustdoc/documentation-tests.html
31-
32-
You can verify the samples pass by running `mdbook test`.
33-
347
### Linkcheck
358

369
To verify that links are not broken, run `cargo xtask linkcheck`.

0 commit comments

Comments
 (0)