Cargo doc --open doesn't show dependency documentation

Description:

I'm learning Rust by following the official book at The Rust Programming Language - The Rust Programming Language and ran into confusion with cargo doc --open.

Issue: When I run cargo doc --open, it successfully documents all dependencies (I can see "Documenting rand v0.8.5" in the output), but it only opens my crate's documentation page. There's no visible way to navigate to the randdocumentation or other dependencies from the opened page.

Expected: Based on examples in the Rust book and docs.rs, I expected to see links or a sidebar to browse dependency documentation, similar to how docs.rs interconnects all crate docs.

Current Workaround: I have to manually open target/doc/rand/index.html or edit the URL path directly.

Question: Is this intended behavior? Is there a better way to access dependency documentation locally that I'm missing as a beginner?

Environment:

  • OS: macOS
  • Command: cargo doc --open

unless you are using custom style sheets, on the index page of your own crate (or of any crate, for that matter), on the left sidebar, where you have groups like "all items", "sections", "crate items", at the bottom of which should be a group labeled "crates", you'll find all the dependency crates in the list.

if you don't see them in the sidebar, can you check the content of the target/doc/crates.js file? it should contain a list of all the crates documented by cargo doc.

1 Like