Linux command
rustdoc 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Generate documentation
rustdoc [lib.rs]
Generate for crate
rustdoc --crate-name [mylib] [lib.rs]
Output to directory
rustdoc -o [docs] [lib.rs]
Document with tests
rustdoc --test [lib.rs]
Set edition
rustdoc --edition [2021] [lib.rs]
说明
rustdoc generates HTML documentation from Rust source code and doc comments. It extracts specially-formatted comments and produces navigable API documentation. The tool is typically invoked via `cargo doc` rather than directly, but can be used for custom documentation needs.
参数
- --crate-name _name_
- Crate name.
- -o _dir_, --out-dir _dir_
- Output directory.
- --test
- Run documentation tests.
- --edition _year_
- Rust edition.
- -L _path_
- Library search path.
- --extern _name=path_
- External crate.
- --document-private-items
- Include private items.
- --html-in-header _file_
- HTML to insert in header.
- --markdown-css _file_
- CSS for markdown.
FAQ
What is the rustdoc command used for?
rustdoc generates HTML documentation from Rust source code and doc comments. It extracts specially-formatted comments and produces navigable API documentation. The tool is typically invoked via `cargo doc` rather than directly, but can be used for custom documentation needs.
How do I run a basic rustdoc example?
Run `rustdoc [lib.rs]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --crate-name _name_ do in rustdoc?
Crate name.