Linux command
cargo-doc 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Build documentation
cargo doc
Build and open in browser
cargo doc --open
Build without dependencies
cargo doc --no-deps
Include private items
cargo doc --document-private-items
Build for all workspace members
cargo doc --workspace
Build with release profile
cargo doc --release
Build with all features
cargo doc --all-features
说明
cargo doc builds documentation for the local package and all dependencies using rustdoc. Output placed in target/doc/ in HTML format.
参数
- --open
- Open documentation in browser after building
- --no-deps
- Don't build documentation for dependencies
- --document-private-items
- Include non-public items (default for binaries)
- -r, --release
- Build with release profile
- --workspace
- Document all workspace members
- --exclude _spec_
- Exclude packages (with --workspace)
- -p, --package _spec_
- Document specific packages
- --lib
- Document library only
- --bins
- Document all binaries
- --target _triple_
- Document for target architecture
- -j, --jobs _n_
- Parallel jobs (default: CPU count)
- --features _features_
- Enable specified features
- --all-features
- Enable all features
- --no-default-features
- Disable default features
FAQ
What is the cargo-doc command used for?
cargo doc builds documentation for the local package and all dependencies using rustdoc. Output placed in target/doc/ in HTML format.
How do I run a basic cargo-doc example?
Run `cargo doc` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --open do in cargo-doc?
Open documentation in browser after building