rustdoc
Generate documentation from Rust source code
TLDR
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]
SYNOPSIS
rustdoc [options] input
DESCRIPTION
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.
PARAMETERS
--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.
CAVEATS
Usually use cargo doc instead. Library paths needed for dependencies. Doc tests require proper setup. Private items hidden by default.
HISTORY
rustdoc has been part of Rust since early development. Documentation culture is strong in Rust, and rustdoc enables it with doc comments that compile to HTML and include tested code examples.
