Skip to content

rustdoc: Display crate:: as the name of the crate in intra-doc links #84731

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
camelid opened this issue Apr 30, 2021 · 5 comments
Open

rustdoc: Display crate:: as the name of the crate in intra-doc links #84731

camelid opened this issue Apr 30, 2021 · 5 comments
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@camelid
Copy link
Member

camelid commented Apr 30, 2021

This would solve the issue described in #84716 (comment) and wouldn't require using extern crate.

A link like [`crate::collections::HashMap`] in std would be rendered as std::collections::HashMap, and would continue to link to HashMap's docs.

I don't think there are any use cases where a library author would want crate:: to show up in their docs.

cc #84721
cc @jyn514 @joshtriplett

@camelid camelid added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name labels Apr 30, 2021
@jyn514 jyn514 changed the title rustdoc: Replace crate:: with the name of the crate in intra-doc links rustdoc: Display crate:: as the name of the crate in intra-doc links Apr 30, 2021
@jyn514
Copy link
Member

jyn514 commented Apr 30, 2021

I think this might be helpful, but it doesn't replace those issues. For this to be useful you have to know ahead of time that

  1. the name of the crate won't work
  2. crate:: will automatically be replaced

And I think 1. is the stumbling block. Given how easy the workaround is, I don't think we should special case this.

@camelid
Copy link
Member Author

camelid commented Apr 30, 2021

Is extern crate self as std; the workaround you're referencing?

@jyn514
Copy link
Member

jyn514 commented Apr 30, 2021

Yes.

@camelid
Copy link
Member Author

camelid commented Apr 30, 2021

I think the issue with that is then people are going to have to add extern crate everywhere. If in order to not have verbose intra-doc links, you have to use this workaround, then what's the purpose of having crate::?

@joshtriplett
Copy link
Member

I think this is an improvement, in that rendering crate::xyz as the_actual_crate_name::xyz is what people will generally want.

However, the issue motivating this was making reference to the_actual_crate_name::xyz in documentation, and expecting that to work, and being surprised when it generated an error even though the same reference in a doctest worked.

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 C-enhancement Category: An issue proposing an enhancement or a PR with one. 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

3 participants