rust-lang / rust-lang/rust

Rust doc `--extern-html-root-url` should support relative paths.

Open
#142,553 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug T-rustdoc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Hi!

I am using a bazel project and therefore am invoking rustdoc directly instead of through cargo rustdoc. Rustdoc has a --extern-html-root-url flag which allows you to specify external paths for crates.

Project setup:
I have a workspace of 2 crates:

  • a
  • b

a has public dependency of b and has functions which reference b's types in the public api.

If I invoke rustdoc by first building a's docs and then b the links for b in a's docs do not resolve, I am using the --extern-html-root-url flag to inform rustdoc to generate links for b relative to the output of a like this --extern-html-root-url b=/.

Ideally, if the path is relative rustdoc should make it relative to the output folder.

In a hierarchy where

  • /a is a's docs
  • /b is b's docs
  • / is an index (maybe generated via --enable-index-page

Then if I add the flag --extern-html-root-url b=/ it should map to / relative to the index page.

Currently this is ignored.

in crate bang
references crate type_defs

build order: [bang, type_defs]

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two-crate rustdoc build described in the issue, using --extern-html-root-url b=/ and checking the generated links. Trace rustdoc's handling of that flag and make relative paths resolve from the documentation output location; done means links from crate a to crate b resolve in the described hierarchy.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.