Cargo doc
cargo doc is a Cargo command that generates documentation for Rust packages and their dependencies.
Idiomatic Rust
cargo doc is Cargo's command for generating documentation for a Rust package and its dependencies.
- How it is used
- Supports API review and user onboarding by generating browsable documentation for a Rust crate.
- How deep it goes
- Generates HTML and explains documentation comments, but stops short of documenting advanced configuration.
- Examples
- Uses a linkedlist crate, LinkedList API pages, crate-level examples, and target/doc output.
- What you can do after
- Operate Cargo to generate documentation, inspect public APIs, and regenerate pages during editing.
Learn Rust in a Month of Lunches
cargo doc is the Cargo command-line tool that generates documentation for Rust packages and their dependencies, with --open optionally opening the generated documentation.
- How it is used
- Generates local, browsable documentation for Rust code, including APIs from external crates.
- How deep it goes
- Explains generation, browser opening, API listings, comments, and dependency selection without covering documentation internals.
- Examples
- Uses DoesNothing, PrintThing, a printing method, automatic traits, blanket implementations, and /// comments.
- What you can do after
- Apply it via Cargo to generate and inspect documentation for a Rust project or its dependencies.
Read how Learn Rust in a Month of Lunches explains cargo doc →
Also covered in
- Rust in Action: Systems programming concepts and techniques
- Rust Web Development
- Code Like a Pro in Rust
- Refactoring to Rust
What to know first
- crateA crate is a unit of Rust code compiled as a library or executable, comprising source code and its module hierarchy and distributable through package metadata.
- HTMLHTML is the standard markup language for structuring content and elements in documents on the web.
- documentationDocumentation is recorded explanatory, instructional, or reference material that describes a system, process, or subject and how it is used, understood, or maintained.
- MarkdownMarkdown is a lightweight markup language that uses readable plain-text syntax to represent structured and formatted documents.
Related concepts
- documentationproduces · Documentation is recorded explanatory, instructional, or reference material that describes a system, process, or subject and how it is used, understood, or maintained.
- rustdocuses · rustdoc is Rust’s documentation generator, producing reference documentation from source code and documentation comments.
- Cargohas part · Cargo is Rust’s package manager and build tool for managing projects and dependencies and for building, testing, and running Rust code.
- HTMLproduces · HTML is the standard markup language for structuring content and elements in documents on the web.
- browseruses · A web browser is software that retrieves, interprets, and renders web resources, executes supported web content, and enables interaction with web applications.
Questions about cargo doc
What is cargo doc?
cargo doc is a Cargo command that generates documentation for Rust packages and their dependencies.
Which Manning books explain cargo doc?
Idiomatic Rust and Learn Rust in a Month of Lunches.
What should I know before learning cargo doc?
Manning books that teach cargo doc usually introduce crate, HTML, documentation and Markdown first.
What are the parts of cargo doc?
Cargo doc includes Cargo.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

