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

Rustdocs directly link to doc.rust-lang.org, breaking offline docs #97918

Closed
aedoq opened this issue Jun 9, 2022 · 4 comments
Closed

Rustdocs directly link to doc.rust-lang.org, breaking offline docs #97918

aedoq opened this issue Jun 9, 2022 · 4 comments
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools

Comments

@aedoq
Copy link

aedoq commented Jun 9, 2022

The docs for the standard library often link to other rust documentation items, like the reference or "Rust by Example". However, most/many of these links link to the versions hosted at doc.rust-lang.org. This causes problems when browsing a version of the docs hosted somewhere else, for instance the offline version installed via rustup. In that case, the linked version is also hardcoded and might not even match the one of the offline docs.
Example (core::arch::asm)

Some pages will link to the docs on the same host, like the one for the keyword pub.

There are currently about 1044 matches for doc.rust-lang.org in .rustup/toolchains/stable-x86_64-unknown-linux-gnu/share/doc/rust/html:

$ grep -Frc "doc.rust-lang.org" . --exclude="print.html" | cut -d: -f2 | awk 'BEGIN{c=0} {c+=$0} END{print c}'
1044
@ehuss
Copy link
Contributor

ehuss commented Jun 9, 2022

I have considered adding a post-processing step in the docs building that makes the links relative, but that can be difficult. There may be some cases where it really wants to intentionally link to the live site. It would also need to be smart about the channel link (like https://doc.rust-lang.org/nightly/… vs https://doc.rust-lang.org/stable/… vs https://doc.rust-lang.org/1.60/… etc.). I'm not sure how to handle those. It could leave any channel-specific links alone, and convert everything else rooted at https://doc.rust-lang.org/. However, I think there was an issue where rustdoc would create links to https://doc.rust-lang.org/nightly/… quite frequently, I'm not sure if that has been mostly solved.

@GuillaumeGomez
Copy link
Member

If it's not "rustdoc generated resources", it makes sense to link to the website in my opinion as we cannot be sure that the resource actually exists locally. However, a lot of doc links use doc.rust-lang.org links whereas they should use either intra doc links or relative links. I'll send a PR for these cases.

@GuillaumeGomez GuillaumeGomez added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Jun 10, 2022
@GuillaumeGomez
Copy link
Member

I opened #97940. It seems like there is only one link in the public API that was not relative. There is another one in fmt private API so I don't think it's worth it to change it.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jun 10, 2022
…an-DPC

Use relative links instead of linking to doc.rust-lang.org when possible

Part of rust-lang#97918.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 10, 2022
…an-DPC

Use relative links instead of linking to doc.rust-lang.org when possible

Part of rust-lang#97918.
workingjubilee pushed a commit to tcdi/postgrestd that referenced this issue Sep 15, 2022
Use relative links instead of linking to doc.rust-lang.org when possible

Part of rust-lang/rust#97918.
@Dylan-DPC
Copy link
Member

Closing this issue as the above linked pr and the issue seems to be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools
Projects
None yet
Development

No branches or pull requests

4 participants