@@ -25,7 +25,7 @@ pub struct Bar;
25
25
```
26
26
27
27
Unlike normal Markdown, ` [bar][Bar] ` syntax is also supported without needing a
28
- ` [Bar]: ... ` reference link, and links are case-sensitive .
28
+ ` [Bar]: ... ` reference link.
29
29
30
30
Backticks around the link will be stripped, so `` [`Option`] `` will correctly
31
31
link to ` Option ` .
@@ -34,17 +34,8 @@ link to `Option`.
34
34
35
35
You can refer to anything in scope, and use paths, including ` Self ` , ` self ` , ` super ` , and
36
36
` crate ` . Associated items (functions, types, and constants) are supported, but [ not for blanket
37
- trait implementations] [ #79682 ] . Rustdoc also supports linking to the following primitives, which
38
- have no path and cannot be imported:
39
-
40
- - [ ` slice ` ] ( ../std/primitive.slice.html )
41
- - [ ` array ` ] ( ../std/primitive.array.html )
42
- - [ ` tuple ` ] ( ../std/primitive.tuple.html )
43
- - [ ` unit ` ] ( ../std/primitive.unit.html )
44
- - [ ` fn ` ] ( ../std/primitive.fn.html )
45
- - [ ` pointer ` ] ( ../std/primitive.pointer.html ) , ` * ` , ` *const ` , or ` *mut `
46
- - [ ` reference ` ] ( ../std/primitive.reference.html ) , ` & ` , or ` &mut `
47
- - [ ` never ` ] ( ../std/primitive.never.html ) or ` ! `
37
+ trait implementations] [ #79682 ] . Rustdoc also supports linking to all primitives listed in
38
+ [ the standard library documentation] ( ../std/index.html#primitives ) .
48
39
49
40
[ #79682 ] : https://github.com/rust-lang/rust/pull/79682
50
41
@@ -84,7 +75,7 @@ struct MySpecialFormatter;
84
75
85
76
Paths in Rust have three namespaces: type, value, and macro. Item names must be unique within
86
77
their namespace, but can overlap with items in other namespaces. In case of ambiguity,
87
- rustdoc will warn about the ambiguity and ask you to disambiguate .
78
+ rustdoc will warn about the ambiguity and suggest a disambiguator .
88
79
89
80
``` rust
90
81
/// See also: [`Foo`](struct@Foo)
@@ -96,24 +87,8 @@ struct Foo {}
96
87
fn Foo () {}
97
88
```
98
89
99
- The following prefixes can be used:
100
-
101
- - ` struct@ `
102
- - ` enum@ `
103
- - ` type@ `
104
- - ` trait@ `
105
- - ` union@ `
106
- - ` const@ `
107
- - ` static@ `
108
- - ` value@ `
109
- - ` fn@ ` / ` function@ ` / ` method@ `
110
- - ` mod@ ` / ` module@ `
111
- - ` prim@ ` / ` primitive@ `
112
- - ` macro@ `
113
- - ` derive@ `
114
-
115
- These prefixes will be stripped when displayed in the documentation, so ` [struct@Foo] `
116
- will be rendered as ` Foo ` .
90
+ These prefixes will be stripped when displayed in the documentation, so ` [struct@Foo] ` will be
91
+ rendered as ` Foo ` .
117
92
118
93
You can also disambiguate for functions by adding ` () ` after the function name,
119
94
or for macros by adding ` ! ` after the macro name:
@@ -134,6 +109,15 @@ Links are resolved in the scope of the module where the item is defined, even
134
109
when the item is re-exported. If a link from another crate fails to resolve, no
135
110
warning is given.
136
111
112
+ ``` rust
113
+ mod inner {
114
+ /// Link to [f()]
115
+ pub struct S ;
116
+ pub fn f () {}
117
+ }
118
+ pub use inner :: S ; // the link to `f` will still resolve correctly
119
+ ```
120
+
137
121
When re-exporting an item, rustdoc allows adding additional documentation to it.
138
122
That additional documentation will be resolved in the scope of the re-export, not
139
123
the original, allowing you to link to items in the new crate. The new links
@@ -154,8 +138,6 @@ module it is defined in.
154
138
155
139
If links do not look 'sufficiently like' an intra-doc link, they will be ignored and no warning
156
140
will be given, even if the link fails to resolve. For example, any link containing ` / ` or ` [] `
157
- characters will be ignored. You can see the full criteria for 'sufficiently like' in [ the source
158
- code] .
141
+ characters will be ignored.
159
142
160
143
[ #72243 ] : https://github.com/rust-lang/rust/issues/72243
161
- [ the source code ] : https://github.com/rust-lang/rust/blob/34628e5b533d35840b61c5db0665cf7633ed3c5a/src/librustdoc/passes/collect_intra_doc_links.rs#L982
0 commit comments