Skip to content

Documentation: inline code with links split into multiple blocks #83997

Description

@tspiteri

EDIT(camelid): ⚠️ Please do not open a PR for this! It is still under discussion.


Right now in the standard library documentation, when a piece of inline code has part of it linked, the code is split into multiple <code> blocks, which renders poorly. For example the Arc thread safety section contains

image

Here, between Arc< and RefCell, and between <T> and >, there is extra spacing. This is because the doc comment contains

/// `Arc<`[`RefCell<T>`]`>`

which is rendered using three <code> blocks as

<code>Arc&lt;</code><a href="../../std/cell/struct.RefCell.html"><code>RefCell&lt;T&gt;</code></a><code>&gt;</code>

I think better would be

/// <code>Arc&lt;[RefCell&lt;T&gt;][RefCell]&gt;</code>

which presumably is rendered in one block as

<code>Arc&lt;<a href="../../std/cell/struct.RefCell.html">RefCell&lt;T&gt;</a>&gt;</code>

(I'm not sure if the link to RefCell gets a title attribute as well).

The downside is that now the doc comment markdown is a bit hairy with explicit <code>, &lt; and &gt; spread throughout.

Is this substitution considered an improvement? If so I can grep through the code, make some substitutions, and open a PR.

An alternative solution would be to change rustdoc itself to combine consecutive code blocks, some of which could be wrapped inside <a>/</a>, into a single block, though I do not have the know-how to open such a PR. I don't even know if there is some downside to this that I am missing, where <code> blocks are meant to be separate, maybe for some markdown compliance or something.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-libs-api[DEPRECATED; DO NOT USE]

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions