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: provide a way to override html_root_url #19603

Closed
SimonSapin opened this issue Dec 6, 2014 · 3 comments
Closed

rustdoc: provide a way to override html_root_url #19603

SimonSapin opened this issue Dec 6, 2014 · 3 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@SimonSapin
Copy link
Contributor

Rustdoc generates external links for standard library items. For example, Result at http://servo.github.io/rust-url/url/type.ParseResult.html links to http://doc.rust-lang.org/nightly/core/result/enum.Result.html

This URL seems to be determined from the #[doc(html_root_url = "…")] attribute in the crate that defines the item. There is apparently no way to override it.

Servo uses a Rust version that is often behind nightly, so I’d like http://doc.servo.org/ to link to docs for the Rust version that’s actually being used. Currently, this is achieved by copying Rust docs from the snapshot to the same location as where Servo docs are being generated. As a result, the crate index side bar lists both Servo and Rust crates, and is hard to read since there are so many of them.

I’d like instead to have docs for our Rust version at a different location, maybe http://doc.servo.org/rust-snapshot/ , and have standard library items link to that. The latter requires rustdoc accepting an override to html_root_url of external crates.

@tomjakubowski
Copy link
Contributor

A simple solution would be to recognize those attributes on extern crate view items.

@steveklabnik steveklabnik added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Dec 7, 2014
@SimonSapin
Copy link
Contributor Author

That would be hard to use with std (where the extern crate is usually implicit), and doesn't work for transitive dependencies (e.g. foo -> std -> core)

@steveklabnik steveklabnik added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Mar 24, 2015
@steveklabnik
Copy link
Member

Triage: I am not aware of any changes in this area.

@steveklabnik steveklabnik added T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. and removed T-tools labels May 18, 2017
bors added a commit that referenced this issue Aug 31, 2018
rustdoc: add flag to control the html_root_url of dependencies

The `--extern-html-root-url` flag in this PR allows one to override links to crates whose docs are not already available locally in the doc bundle. Docs.rs currently uses a version of this to make sure links to other crates go into that crate's docs.rs page. See the included test for intended use, but the idea is as follows:

Calling rustdoc with `--extern-html-root-url crate=https://some-url.com` will cause rustdoc to override links that point to that crate to instead be replaced with a link rooted at `https://some-url.com/`. (e.g. for docs.rs this would be `https://docs.rs/crate/0.1.0` or the like.) Cheekily, rustup could use these options to redirect links to std/core/etc to instead point to locally-downloaded docs, if it so desired.

Fixes #19603
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. 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