feature request: option to link std in "cargo doc" to local docs #6543
Labels
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
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 fromstd
, it links to the nightly docs, instead of stable, or to some locally-downloaded docs provided byrustup
. This has been a problem caused by the design of rustdoc andstd
'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 thestd
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 forstd
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.
The text was updated successfully, but these errors were encountered: