Skip to content

Commit 2dd1ed2

Browse files
committed
Update intra_rustdoc_links
- Mention this is valid Markdown - Add more alternatives
1 parent 0483d34 commit 2dd1ed2

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

text/0000-intra-rustdoc-links.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ it should also be possible to write a Rust path
8080
and somewhere else in the document: `[iter]: std::iter::Iterator`
8181
3. `<std::iter::Iterator>`
8282

83+
All additions are already valid Markdown,
84+
as defined by the orginal [Markdown syntax definition][md]
85+
as well as the [CommonMark] project.
86+
Especially, Rust paths are valid CommonMark [link destinations],
87+
even with the suffixes described [below][path-ambiguities].
88+
89+
[md]: https://daringfireball.net/projects/markdown/syntax
90+
[CommonMark]: http://commonmark.org
91+
[link destinations]: http://spec.commonmark.org/0.27/#link-destination
92+
8393
## How it will be rendered
8494

8595
The following:
@@ -146,6 +156,7 @@ mod amet {
146156
```
147157

148158
## Path ambiguities
159+
[path-ambiguities]: #path-ambiguities
149160

150161
Rust allows items to have the same name. A short evaluation revealed that
151162

@@ -173,7 +184,9 @@ This was originally proposed by
173184
going into more details:
174185

175186
> `<syntax::ptr::P>` — First search for type-like items. If not found, search for value-like items
187+
>
176188
> `<syntax::ptr::P()>` — Only search for functions.
189+
>
177190
> `<std::stringify!>` — Only search for macros.
178191
179192
## Linking to methods
@@ -271,9 +284,29 @@ Maybe present an example use case of a module whose documentation links to sever
271284
# Alternatives
272285
[alternatives]: #alternatives
273286

274-
## Syntax alternatives
287+
- Use reference-style links and automatically generate the references.
288+
For example, the Markdown snippet
289+
290+
```md
291+
This is of type [`String`].
292+
```
293+
294+
expects a link reference definition like
275295

276-
Introduce special syntax for this:
296+
```md
297+
[`String`]: https://doc.rust-lang.org/nightly/std/string/struct.String.html
298+
```
299+
300+
to follow (or precede) it.
301+
This link reference definition can be automatially generated by Rustdoc
302+
with the (relative) URL to the page of the item.
303+
This was suggested in [the CommonMark forum]
304+
as well as
305+
by [GuillaumeGomez](https://github.com/GuillaumeGomez).
306+
307+
We consider this equivalent to the `<String>` syntax this RFC proposes.
308+
309+
[cm-forum]: https://talk.commonmark.org/t/what-should-the-rust-community-do-for-linkage/2141
277310

278311
- [javadoc] and [jsdoc]
279312
use `{@link java.awt.Panel}`
@@ -282,6 +315,10 @@ Introduce special syntax for this:
282315
[javadoc]: http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html
283316
[jsdoc]: http://usejsdoc.org/tags-inline-link.html
284317

318+
- [@kennytm](https://github.com/kennytm)
319+
listed other syntax alternatives
320+
[here](https://github.com/rust-lang/rfcs/pull/1946#issuecomment-284718018).
321+
285322

286323
# Unresolved questions
287324
[unresolved]: #unresolved-questions

0 commit comments

Comments
 (0)