Skip to content

Commit 9743740

Browse files
committed
Move conventions to a dedicated chapter
The intent here is to tie together the different conventions used in the book (with the grammar), and to provide a more focused place to house this content. I've also noticed this is a more common approach to including this kind of content.
1 parent afcfa09 commit 9743740

File tree

3 files changed

+61
-60
lines changed

3 files changed

+61
-60
lines changed

src/SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
[Introduction](introduction.md)
44

5-
- [Grammar notation](notation.md)
5+
- [Notational conventions](conventions.md)
6+
- [Grammar notation](notation.md)
67

78
- [Lexical structure](lexical-structure.md)
89
- [Input format](input-format.md)

src/conventions.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Notational conventions
2+
3+
## Conventions
4+
5+
Like all technical books, this book has certain conventions in how it displays information. These conventions are documented here.
6+
7+
* Statements that define a term contain that term in *italics*. Whenever that term is used outside of that chapter, it is usually a link to the section that has this definition.
8+
9+
An *example term* is an example of a term being defined.
10+
11+
* The main text describes the latest stable edition. Differences to previous editions are separated in edition blocks:
12+
13+
> [!EDITION-2018]
14+
> Before the 2018 edition, the behavior was this. As of the 2018 edition, the behavior is that.
15+
16+
* Notes that contain useful information about the state of the book or point out useful, but mostly out of scope, information are in note blocks.
17+
18+
> [!NOTE]
19+
> This is an example note.
20+
21+
* Example blocks show an example that demonstrates some rule or points out some interesting aspect. Some examples may have hidden lines which can be viewed by clicking the eye icon that appears when hovering or tapping the example.
22+
23+
> [!EXAMPLE]
24+
> This is a code example.
25+
> ```rust
26+
> println!("hello world");
27+
> ```
28+
29+
* Warnings that show unsound behavior in the language or possibly confusing interactions of language features are in a special warning box.
30+
31+
> [!WARNING]
32+
> This is an example warning.
33+
34+
* Code snippets inline in the text are inside `<code>` tags.
35+
36+
Longer code examples are in a syntax highlighted box that has controls for copying, executing, and showing hidden lines in the top right corner.
37+
38+
```rust
39+
# // This is a hidden line.
40+
fn main() {
41+
println!("This is a code example");
42+
}
43+
```
44+
45+
All examples are written for the latest edition unless otherwise stated.
46+
47+
* The grammar and lexical productions are described in the [Notation] chapter.
48+
49+
r[example.rule.label]
50+
* Rule identifiers appear before each language rule enclosed in square brackets. These identifiers provide a way to refer to and link to a specific rule in the language ([e.g.][example rule]). The rule identifier uses periods to separate sections from most general to most specific ([destructors.scope.nesting.function-body] for example). On narrow screens, the rule name will collapse to display `[*]`.
51+
52+
The rule name can be clicked to link to that rule.
53+
54+
> [!WARNING]
55+
> The organization of the rules is currently in flux. For the time being, these identifier names are not stable between releases, and links to these rules may fail if they are changed. We intend to stabilize these once the organization has settled so that links to the rule names will not break between releases.
56+
57+
* Rules that have associated tests will include a `Tests` link below them (on narrow screens, the link is `[T]`). Clicking the link will pop up a list of tests, which can be clicked to view the test. For example, see [input.encoding.utf8].
58+
59+
Linking rules to tests is an ongoing effort. See the [Test summary](test-summary.md) chapter for an overview.

src/introduction.md

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -45,64 +45,6 @@ That said, there is no wrong way to read this book. Read it however you feel hel
4545
> [!NOTE]
4646
> For known bugs and omissions in this book, see our [GitHub issues]. If you see a case where the compiler behavior and the text here do not agree, file an issue so we can think about which is correct.
4747
48-
### Conventions
49-
50-
Like all technical books, this book has certain conventions in how it displays information. These conventions are documented here.
51-
52-
* Statements that define a term contain that term in *italics*. Whenever that term is used outside of that chapter, it is usually a link to the section that has this definition.
53-
54-
An *example term* is an example of a term being defined.
55-
56-
* The main text describes the latest stable edition. Differences to previous editions are separated in edition blocks:
57-
58-
> [!EDITION-2018]
59-
> Before the 2018 edition, the behavior was this. As of the 2018 edition, the behavior is that.
60-
61-
* Notes that contain useful information about the state of the book or point out useful, but mostly out of scope, information are in note blocks.
62-
63-
> [!NOTE]
64-
> This is an example note.
65-
66-
* Example blocks show an example that demonstrates some rule or points out some interesting aspect. Some examples may have hidden lines which can be viewed by clicking the eye icon that appears when hovering or tapping the example.
67-
68-
> [!EXAMPLE]
69-
> This is a code example.
70-
> ```rust
71-
> println!("hello world");
72-
> ```
73-
74-
* Warnings that show unsound behavior in the language or possibly confusing interactions of language features are in a special warning box.
75-
76-
> [!WARNING]
77-
> This is an example warning.
78-
79-
* Code snippets inline in the text are inside `<code>` tags.
80-
81-
Longer code examples are in a syntax highlighted box that has controls for copying, executing, and showing hidden lines in the top right corner.
82-
83-
```rust
84-
# // This is a hidden line.
85-
fn main() {
86-
println!("This is a code example");
87-
}
88-
```
89-
90-
All examples are written for the latest edition unless otherwise stated.
91-
92-
* The grammar and lexical productions are described in the [Notation] chapter.
93-
94-
r[example.rule.label]
95-
* Rule identifiers appear before each language rule enclosed in square brackets. These identifiers provide a way to refer to and link to a specific rule in the language ([e.g.][example rule]). The rule identifier uses periods to separate sections from most general to most specific ([destructors.scope.nesting.function-body] for example). On narrow screens, the rule name will collapse to display `[*]`.
96-
97-
The rule name can be clicked to link to that rule.
98-
99-
> [!WARNING]
100-
> The organization of the rules is currently in flux. For the time being, these identifier names are not stable between releases, and links to these rules may fail if they are changed. We intend to stabilize these once the organization has settled so that links to the rule names will not break between releases.
101-
102-
* Rules that have associated tests will include a `Tests` link below them (on narrow screens, the link is `[T]`). Clicking the link will pop up a list of tests, which can be clicked to view the test. For example, see [input.encoding.utf8].
103-
104-
Linking rules to tests is an ongoing effort. See the [Test summary](test-summary.md) chapter for an overview.
105-
10648
## Contributing
10749

10850
We welcome contributions of all kinds.
@@ -112,7 +54,6 @@ You can contribute to this book by opening an issue or sending a pull request to
11254
[book]: ../book/index.html
11355
[cargo book]: ../cargo/index.html
11456
[cargo reference]: ../cargo/reference/index.html
115-
[example rule]: example.rule.label
11657
[expressions chapter]: expressions.html
11758
[file an issue]: https://github.com/rust-lang/reference/issues
11859
[github issues]: https://github.com/rust-lang/reference/issues

0 commit comments

Comments
 (0)