Skip to content
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

rustdoc: add a way to link relative to the root of the docs #63944

Open
vext01 opened this issue Aug 27, 2019 · 11 comments
Open

rustdoc: add a way to link relative to the root of the docs #63944

vext01 opened this issue Aug 27, 2019 · 11 comments
Labels
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

@vext01
Copy link
Contributor

vext01 commented Aug 27, 2019

In a recent documentation change, we were unable to create a link to a function in std and had to resort to linking to online documentation.

@eddyb described it best:

../std won't work in core::hint/std::hint and ../../std won't work in test

Thus the link checker can't be satisfied.

For more info, see:
#62891 (comment)

@eddyb
Copy link
Member

eddyb commented Aug 27, 2019

cc @QuietMisdreavus @GuillaumeGomez

Is there some other syntax that could be used to get the same effect, regardless of where it's used?

But also, could paths be interpreted relative to where the item being documented is defined, as supposed to where it's reexported from?

@mati865
Copy link
Contributor

mati865 commented Aug 27, 2019

Maybe something like here https://github.com/rust-lang/rust/pull/61926/files?

EDIT: Explained in #61926 (comment)

@RalfJung
Copy link
Member

RalfJung commented Aug 27, 2019 via email

@vext01
Copy link
Contributor Author

vext01 commented Aug 27, 2019

Having a variable that expands to the root seems most general.

Sounds good to me.

@GuillaumeGomez
Copy link
Member

For this kind of problems, we use intra-links. No need to put the full path, just the type.

@RalfJung
Copy link
Member

@GuillaumeGomez does that mean links like crate::vec::Vec are working properly these days?

Also see my question above: what if I want to link to the reference? There always is a reference "next to" the std docs, so I could use something like ../../reference/behavior-considered-undefined.html, but that relies on relative paths again.

@GuillaumeGomez
Copy link
Member

For the reference, please use a full url. No miraculous solution in there... :-/

@estebank estebank added 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. labels Aug 28, 2019
@RalfJung
Copy link
Member

RalfJung commented Nov 22, 2019

@GuillaumeGomez you didn't answer my question -- are links like crate::vec::Vec considered stable so that we can actually start using them in the docs? The last I heard is that this is experimental and should not be used.

This is just biting us again in #66379, where we want to link to the ptr module docs. And we want to link to a particular section of those docs. Is crate::ptr#safety a thing?

For the reference, please use a full url. No miraculous solution in there... :-/

There's an easy solution: provide a variable that expands to the root of the docs. Then for the reference we could do $DOCROOT/reference/behavior-considered-undefined.html.

@GuillaumeGomez
Copy link
Member

They are already used in the std docs so you can consider them "stable". Also the anchor PR has been merged.

@RalfJung
Copy link
Member

They are already used in the std docs so you can consider them "stable".

Great!

What remains of this issue is the case where one wants to link to the reference (or another "associated book") from a doc-comment that is included on several different folder depths. This is the one place that I am aware of where we are still forced to use absolute paths, and it could be fixed by having some way to tell rustdoc that a path is relative to the root of the docs.

@jyn514 jyn514 changed the title rustdoc: link checker cannot be satisfied rustdoc: add a way to link relative to the root of the docs Nov 12, 2020
@jyn514
Copy link
Member

jyn514 commented Nov 12, 2020

It sounds like this is #74481, but for things that aren't rust paths. Maybe we should close #74481 in favor of this issue?

@jyn514 jyn514 added C-feature-request Category: A feature request, i.e: not implemented / a PR. and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

7 participants