LinuxCommandLibrary

rustdoc

Generate documentation from Rust source code

TLDR

Generate documentation

$ rustdoc [lib.rs]
copy
Generate for crate
$ rustdoc --crate-name [mylib] [lib.rs]
copy
Output to directory
$ rustdoc -o [docs] [lib.rs]
copy
Document with tests
$ rustdoc --test [lib.rs]
copy
Set edition
$ rustdoc --edition [2021] [lib.rs]
copy

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.

SEE ALSO

cargo(1), rustc(1), doxygen(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community