Skip to content

Support rustdoc root-url feature #6279

Closed
@ehuss

Description

@ehuss

Rustdoc has an unstable flag --extern-html-root-url which allows you to redirect external links to a different site. It might be useful if cargo exposed native support for this feature somehow so that it could automatically fill in all the flags. This could allow libstd links to go to your local copy of libstd downloaded by rustup instead of doc.rust-lang.org for better offline support. Or redirect dependency links to another site like docs.rs instead of building all dependency docs.

Currently you can use it like this:

RUSTDOCFLAGS="--extern-html-root-url \
    std=file://$(rustc --print sysroot)/share/doc/rust/html \
    -Z unstable-options" cargo doc

And you can add other sysroot crates like proc_macro.

Some design work needs to be done to figure out exactly how this works. Some things to consider:

  • What if the user doesn't use rustup?
  • What if the docs weren't downloaded by rustup?
  • What if rustup's directory layout changes?
  • How might this interact in a possible future where cargo manages sysroot or otherwise has more knowledge of it? How would cargo know which crates exist in the sysroot?
  • How can the user enter specific mappings, such as to docs.rs or other sites? Would there be interaction with --no-deps?

I'm imagine there are many other questions to be resolved.

See #8104 for a detailed use case example.

cc @QuietMisdreavus

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`Command-docS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions