Skip to content

cargo doc: seamless offline cross-linking to local std docs. #8104

@nathan-at-least

Description

@nathan-at-least

Describe the problem you are trying to solve

I often rely on rustup doc --std and cargo doc --open to open two offline tabs while doing development for a project. This way I have complete API docs for std and all dependencies.

However, these two renderings are separate, and the cargo doc renderings link to online copies of std documentation, rather than the local offline copy.

This makes offline development cumbersome, since all std links fail to open when I'm browsing dependency docs, and then I need to switch tabs and search for the same term.

Describe the solution you'd like

Allow cargo doc to take an --online / --offline parameter that knows the generated docs are intended for local offline consumption and which rely on rustup doc output and link to that. Under the hood, perhaps the std doc linking can take a URL prefix, and in one mode it uses a local path and another it uses https://doc.rust-lang.org/<channel>/std

A good implementation should do link-checking, especially for local links, so that a user who runs cargo doc --offline who has not generated the rustup doc documentation should see a clear use friendly error message explaining how to fix the problem. (I assume it may not be wise to automatically generate rustup docs for users with different development setups.)

Notes

The same problem and solution exist for core and any other crates managed by the rustup toolchain.

What if users don't install rustup the default way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions