Skip to content

Intra-doc links should be styled according to the kind of their target #78256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dfoxfranke opened this issue Oct 22, 2020 · 6 comments
Open
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@dfoxfranke
Copy link

dfoxfranke commented Oct 22, 2020

Rustdoc generally has fairly consistent ways of styling documentation items. For example, in the default Light theme, structs are magenta, traits are lavender, functions and methods are gold, etc., and are always set in a sans-serif or monospace font. However, this convention does not seem to get applied to intra-documentation links.

Right now, if I write

/// [Result]

the link will be blue and set in serifs; if I write

/// [`Result`]

it'll be blue and set in monospace.

It would be more attractive and consistent for [Result] to be set in magenta sans-serif, and [`Result`] to be set in magenta monospace.

@camelid camelid added A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-feature-request Category: A feature request, i.e: not implemented / a PR. A-rustdoc-ui Area: Rustdoc UI (generated HTML) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Oct 22, 2020
@camelid
Copy link
Member

camelid commented Oct 22, 2020

IIUC intra-doc links are implemented as just constructing a link based on the path to the item, with no styling applied. In other words, they're equivalent to the old-style [Foo](../foo/struct.Foo.html) links. Thus I'm marking this as a feature request.

@dfoxfranke
Copy link
Author

Yes, come to think of it, that raises a question: what to do with old-style links? I can think of a few possibilities and they all seem reasonable:

  1. Nothing. You need to use a new-style intra-doc link if you want the styling.
  2. Have rustdoc notice when something is an old-style doc link and apply formatting as if it had been written in new style.
  3. Don't do anything with them in rustdoc, but add a cargo fix pass to rewrite old-style links.

@camelid
Copy link
Member

camelid commented Oct 23, 2020

I think we would like go with (1); the other two seem like they would take a lot of work for not much benefit.

@jyn514
Copy link
Member

jyn514 commented Oct 23, 2020

FWIW there is an issue open for 3, and that would be my preference: #75805

@detly
Copy link

detly commented Jul 26, 2021

If you are going to detect the target of a link, why require the backticks for monospacing at all, when the target is an item?

@jyn514
Copy link
Member

jyn514 commented Jul 26, 2021

@detly the backticks would not be required. Backticks mean the item should be highlighted as code, so rustdoc uses a monospace font for them already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants