Rust
Docs Commands
Generate beautiful documentation from your Rust code with cargo doc. Rust's documentation system turns code comments into browsable HTML with cross-references and examples.
4 commands
Pro Tips
Use 'cargo doc --open' to build docs and open them in your browser. Add '--no-deps' to skip dependency docs.
Write examples in doc comments with '```' blocks — they compile and run as tests with 'cargo test'.
Use '//!' for module-level docs at the top of lib.rs and '///' for item-level documentation.
Common Mistakes
Doc examples that use 'unwrap()' set a bad example. Use proper error handling in documentation code.
Private items are hidden from docs by default. Use 'cargo doc --document-private-items' for internal documentation.