-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Description
For example, consider this documentation on i32::unchecked_add:
https://doc.rust-lang.org/1.82.0/std/primitive.i32.html#method.unchecked_add
rust/library/core/src/num/int_macros.rs
Lines 493 to 494 in f6e511e
| /// Calling `x.unchecked_add(y)` is semantically equivalent to calling | |
| /// `x.`[`checked_add`]`(y).`[`unwrap_unchecked`]`()`. |
Rustdoc currently produces the following HTML. (I have inserted newlines for readability. These are not present in rustdoc's output.)
<code>x.</code>
<a href="primitive.i32.html#method.checked_add"><code>checked_add</code></a>
<code>(y).</code>
<a href="option/enum.Option.html#method.unwrap_unchecked"><code>unwrap_unchecked</code></a>
<code>()</code>Because there are 5 individual code blocks, there is weird padding between their otherwise-monospaced text, and inappropriately placed rounded corners.
It would be better to produce, from exactly the above Markdown source code, the following HTML structure instead.
<code>
x.
<a href="primitive.i32.html#method.checked_add">checked_add</a>
(y).
<a href="option/enum.Option.html#method.unwrap_unchecked">unwrap_unchecked</a>
()
</code>
It is sometimes possible to achieve this output today by manually writing <code> and <a>:
/// <code>x.<a href="...">checked_add</a>(y).<a href="...">unwrap_unchecked</a>()</code>
But the reason I say "sometimes" and the reason I have tagged
A-intra-doc-links
[`Option::unwrap_unchecked`]) and not for HTML links (<a href="Option::unwrap_unchecked"></a>). Whether or not that changes in the future as a separate issue, I still think the suggestion in this issue will remain valuable because writing inline code and links in Markdown syntax is always going to be more convenient than falling back to HTML syntax.