Skip to content

feature request: option to link std in "cargo doc" to local docs #6543

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

Closed
QuietMisdreavus opened this issue Jan 11, 2019 · 2 comments
Closed
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@QuietMisdreavus
Copy link
Member

Describe the problem you are trying to solve

A persistent report i've seen crop up from time to time is that whenever someone's cargo doc links to a type from std, it links to the nightly docs, instead of stable, or to some locally-downloaded docs provided by rustup. This has been a problem caused by the design of rustdoc and std's own code asking it to link downstream crates to the nightly docs in the first place. This causes a problem if people want to work totally offline, since they need to have the std docs open separately (rustup doc --std) from their crate's docs (cargo doc --open).

Describe the solution you'd like

A (currently unstable) CLI flag added recently to rustdoc will be able to solve this issue. The --extern-html-root-url flag allows users to override the base URL used by rustdoc to link to a crate. This flag was added for docs.rs, and has been in use for a few months now without issue. If Cargo would like to use this flag for this feature, i can push for its stabilization based on docs.rs's successful testing of it.

The flag can be used like "--extern-html-root-url std=file:///path/to/doc-root", where the path leads to the folder above the std folder where the std docs are.

The idea i have in mind is to add some kind of option to Cargo, either in the form of a .cargo/config field or a CLI flag, which will make Cargo pass the --extern-html-root-url flag to rustdoc and make it link to offline docs for std and friends.

The biggest remaining problem here may be with how to grab the folder path in the first place. Since the docs are installed by rustup, i don't know if the request should actually be given to them, or if we can coordinate to get that information from rustup to Cargo, so Cargo can give that information to rustdoc.

@QuietMisdreavus QuietMisdreavus added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jan 11, 2019
@ehuss
Copy link
Contributor

ehuss commented Jan 11, 2019

I think this may be a duplicate of #6279? I listed a few questions there that probably should be answered by a proposed design. There's an example workaround command there that works if rustup is used, though it would definitely be nice to support it directly!

@QuietMisdreavus
Copy link
Member Author

Ah, this is a duplicate! I forgot about that other issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

2 participants