rustdoc man page

rustdoc — generate documentation from Rust source code


rustdoc [Options] INPUT


This tool generates API reference documentation by extracting comments from source code written in the Rust language, available at <>. It accepts several input formats and provides several output formats for the generated documentation.


-r, --input-format FORMAT

html or json (default: inferred)

-w, --output-format FORMAT

html or json (default: html)

-o, --output OUTPUT

where to place the output (default: doc/ for html, doc.json for json)

--passes LIST

space‐separated list of passes to run (default: '')


don't run the default passes

--plugins LIST

space-separated list of plugins to run (default: '')

--plugin-path DIR

directory to load plugins from (default: /tmp/rustdoc_ng/plugins)

--target TRIPLE

target triple to document

--crate-name NAME

specify the name of this crate

-L, --library-path DIR

directory to add to crate search path

--cfg SPEC

pass a --cfg to rustc

--extern VAL

pass an --extern to rustc


run code examples as tests

--test-args ARGS

pass arguments to the test runner

--html-in-header FILE

file to add to <head>

--html-before-content FILE

file to add in <body>, before content

--html-after-content FILE

file to add in <body>, after content

--markdown-css FILE

CSS files to include via <link> in a rendered Markdown file

--markdown-playground-url URL

URL to send code snippets to


don't include table of contents

-h, --help

Print help

-V, --version

Print rustdoc's version

Output Formats

The rustdoc tool can generate output in either an HTML or JSON format.

If using an HTML format, then the specified output destination will be the root directory of an HTML structure for all the documentation. Pages will be placed into this directory, and source files will also possibly be rendered into it as well.

If using a JSON format, then the specified output destination will have the rustdoc output serialized as JSON into it. This output format exists to pre‐compile documentation for crates, and for usage in non‐rustdoc tools. The JSON output is the following hash:

       "schema": VERSION,
       "crate": ...,
       "plugins": ...,

The schema version indicates what the structure of crate/plugins will look like. Within a schema version the structure will remain the same. The crate field will contain all relevant documentation for the source being documented, and the plugins field will contain the output of the plugins run over the crate.


To generate documentation for the source in the current directory:
   $ rustdoc

List all available passes that rustdoc has, along with default passes:
   $ rustdoc --passes list

To precompile the documentation for a crate, and then use it to render html at a later date:
   $ rustdoc -w json
   $ rustdoc doc.json

The generated HTML can be viewed with any standard web browser.

See Also



See <> for issues.


See AUTHORS.txt in the Rust source distribution.

Referenced By

cargo(1), rustc(1).

September 2016 rustdoc 1.13.0 User Commands