Skip to content

documentation building is sensitive to the order docs are generated #8487

Open
@ehuss

Description

@ehuss

If documentation for packages is built independently, then any cross-links between packages may not work. It depends on the order of commands, where it is necessary to build from the leaves up.

This is because rustdoc looks in the local directory to decide if it should create a relative link or not. If a dependency hasn't been built yet, then there is nothing for it to find, so it doesn't generate a link.

Usually this is fine for a normal cargo doc command, since it builds from the leaves on up (caveat below). However, if running cargo rustdoc or cargo doc -p foo --no-deps, then the user must know about this subtle interaction to build things in the correct order.

This came up with rust's build scripts here which gets it slightly wrong.

I'm not sure if there is anything that should be done here. One option is to have cargo doc -p foo -p bar be smart and determine the correct order (or create the directories ahead of time). This wouldn't help for rustbuild which uses cargo rustdoc which can only do one package at a time (although it could be changed to cargo doc --no-deps …).

Another option is to just document rustdoc's linking behavior.

Another possible problem is that the dependencies between rustdoc invocations is not explicitly tracked within cargo. This means that if crate A depends on crate B, A and B will be documented concurrently. If A happens to start before B, then A's links to B will be broken. This can be illustrated in the doc builder for rustc here. Removing that create_dir_all causes many links to break. I'm having a hard time creating a small reproduction, though (and I may not fully understand this scenario, since rustc's crate graph is very complex).

cc rust-lang/rust#74352

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugCommand-docS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions