Skip to content

Commit 6c974f9

Browse files
ehusstraviscross
authored andcommitted
Add more details to the links chapter
1 parent 7c3ec37 commit 6c974f9

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

reference-dev-guide/src/links.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ This chapter explains how links should be handled by the Reference. Several of t
44

55
See also the [linkchecker tests](tests.md#linkcheck) for testing links.
66

7+
## Rule links
8+
9+
[Rules](rules/index.md) can be linked to by their ID using Markdown, with the destination set to the rule ID. Automatic link references allow any rule to be referred to from any page in the book.
10+
11+
```markdown
12+
Direct label link: [names.preludes.lang]
13+
14+
Destination label link (custom link text): [language prelude][names.preludes.lang]
15+
16+
Definition link: [namespace kinds]
17+
18+
[namespace kinds]: names.namespaces.kinds
19+
```
20+
721
## Standard library links
822

923
You should link to the standard library without specifying a URL in a fashion similar to [rustdoc intra-doc links][intra]. Some examples:
@@ -51,3 +65,33 @@ When rendering the Reference locally, by default it uses relative links to confo
5165

5266
[intra]: https://doc.rust-lang.org/rustdoc/write-documentation/linking-to-items-by-name.html
5367
[rel]: tooling/building.md#spec_relative
68+
69+
## Grammar links
70+
71+
Link definitions are automatically generated for all grammar production names. See [grammar automatic linking](grammar.md#automatic-linking) for more.
72+
73+
```markdown
74+
This attribute uses the [MetaWord] syntax.
75+
76+
Explicit grammar links can have the `grammar-` prefix like [Type][grammar-Type].
77+
```
78+
79+
## Outside book links
80+
81+
Links to other books published with the Reference should be relative links pointing to the corresponding book. This allows the links to point to the correct version, to work with the offline docs, and to be checked by the linkchecker. For example:
82+
83+
```markdown
84+
See [`-C panic`].
85+
86+
[`-C panic`]: ../rustc/codegen-options/index.html#panic
87+
```
88+
89+
## Internal links
90+
91+
When possible, internal links should use [rule links](#rule-links) or [grammar links](#grammar-links). Otherwise, links should be relative to the file path and use the `.md` extension.
92+
93+
```markdown
94+
- Rule link: [language prelude][names.preludes.lang]
95+
- Grammar link: [MetaWord]
96+
- Internal link: [Modules](items/modules.md#attributes-on-modules)
97+
```

0 commit comments

Comments
 (0)