Linux command
cargo-rustdoc 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Build docs with rustdoc options
cargo rustdoc -- [rustdoc_flags]
Document with private items
cargo rustdoc -- --document-private-items
Output JSON format (nightly)
cargo rustdoc -Z unstable-options --output-format json
Document specific binary
cargo rustdoc --bin [name] -- [flags]
Build docs for all features
cargo rustdoc --all-features
说明
cargo rustdoc builds documentation for the current package and passes extra options directly to the rustdoc tool. Arguments after `--` are forwarded only to the final rustdoc invocation for the specified target, not to dependencies. This command is similar to `cargo doc` but provides fine-grained control over rustdoc flags. Common uses include documenting private items, generating JSON output for tooling (on nightly), and passing custom HTML or CSS settings. Only one target can be documented at a time when extra arguments are provided.
参数
- --open
- Open docs in browser after building
- --lib
- Document library only
- --bin _name_
- Document specified binary
- --bins
- Document all binaries
- --example _name_
- Document specified example
- --examples
- Document all examples
- -p, --package _spec_
- Package to document
- --target _triple_
- Document for target platform
- -j, --jobs _n_
- Parallel jobs
- --features _features_
- Enable features
- --all-features
- Enable all features
- --no-default-features
- Disable default features
FAQ
What is the cargo-rustdoc command used for?
cargo rustdoc builds documentation for the current package and passes extra options directly to the rustdoc tool. Arguments after `--` are forwarded only to the final rustdoc invocation for the specified target, not to dependencies. This command is similar to `cargo doc` but provides fine-grained control over rustdoc flags. Common uses include documenting private items, generating JSON output for tooling (on nightly), and passing custom HTML or CSS settings. Only one target can be documented at a time when extra arguments are provided.
How do I run a basic cargo-rustdoc example?
Run `cargo rustdoc -- [rustdoc_flags]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --open do in cargo-rustdoc?
Open docs in browser after building