Generate Rust API documentation

Use the Cargo tool on Red Hat Enterprise Linux to generate HTML API documentation from comments in your source code that are marked for extraction. Documentation comments are extracted only for public functions, variables, and members.

Prerequisites

  • Rust Toolset is installed.

Build documentation for a Rust project

Use the Cargo tool to generate documentation from comments in your source code that are marked for extraction. Note that documentation comments are extracted only for public functions, variables, and members.

Before you begin

Procedure

  1. In your code, use three slashes /// at the beginning of a line to mark the line for extracting the comment for documentation.
  2. Build the documentation:
    $ cargo doc --no-deps

    The command stores the generated documentation in the target/doc/ directory.