Skip to content
Latchkey

cargo doc --no-deps: Build Docs in CI

cargo doc --no-deps generates HTML documentation for the workspace crates without also documenting every dependency.

Documenting dependencies is slow and rarely what you publish. --no-deps keeps the build fast, and RUSTDOCFLAGS lets you fail on broken intra-doc links.

What it does

cargo doc runs rustdoc to produce HTML under target/doc. --no-deps documents only the local packages, skipping dependencies. Setting RUSTDOCFLAGS="-D warnings" turns rustdoc lints (like broken intra-doc links) into hard errors.

Common usage

Terminal
cargo doc --no-deps --all-features --locked
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps
cargo doc --no-deps --document-private-items

Flags

FlagWhat it does
--no-depsDo not build documentation for dependencies
--all-featuresDocument with all features enabled
--document-private-itemsInclude private items in the docs
--openOpen the docs in a browser (local only, not CI)
RUSTDOCFLAGS=-D warningsEnv var: fail on rustdoc warnings

In CI

Use RUSTDOCFLAGS="-D warnings" to catch broken doc links before they ship. Cache ~/.cargo and target/ so doc builds reuse compiled dependency metadata. Do not use --open in CI; there is no browser.

Common errors in CI

"error: unresolved link to Foo" with -D warnings means an intra-doc link points at something that does not exist or is not imported in scope. "error: [...] cannot be resolved" is the same class. Without the deny flag these are warnings and the docs still build, so the gate only triggers when RUSTDOCFLAGS is set.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →