Rustdoc

Rustdoc is Rust's built-in documentation generator. It reads the /// and //! doc comments in your source and produces browsable HTML — the same tooling that generates the standard library docs and every crate on docs.rs.

Rules

  • rust_doc — Build HTML documentation for a rust_library, rust_binary, or rust_proc_macro target. Output is a directory tree suitable for hosting on a static site.
  • rust_doc_test — Compile and run the code samples embedded in a crate's doc comments as tests, matching Cargo's cargo test --doc behavior.

Toolchain

  • rustdoc_toolchain — Provide the rustdoc the rules above run. Registered for @rules_rust//rust/rustdoc:toolchain_type next to every rust_toolchain the rust module extension registers, so rustdoc always matches the compiler. Rules declare the type as rust_common.rustdoc_toolchain_type; the same page documents find_rustdoc, which falls back to the rust_doc of the rust_toolchain when no rustdoc_toolchain is registered.