← All notes

Documenting and publishing a Rust crate

Answer: The crate registry at crates.io distributes the source code of your packages. It primarily hosts code that is open source. Documentation comments use three slashes and support Markdown notation. Cargo doc builds HTML documentation. Cargo test --doc runs only documentation tests.

Comments, HTML docs, and crates.io

The registry at crates.io distributes the source code of your packages.

It primarily hosts code that is open source.

Documentation comments use three slashes instead of two.

They also support Markdown notation for formatting the text.

You can generate the HTML documentation from this documentation comment by running cargo doc.

cargo doc and documentation tests

Use cargo doc to build documentation in target/doc.

The --open flag will automatically open that documentation in your web browser.

Doc comments are denoted by ///, and support Markdown.

Use cargo test to run all tests, including documentation tests.

Pass cargo test --doc to only run documentation tests.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Rust Programming Language, Publishing a Crate to Crates.io; Rust By Example, Documentation. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/rust-by-example/master/LICENSE-MIT). Copyright the Rust Project Developers. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Rust Programming Language, Publishing a Crate to Crates.io; Rust By Example, Documentation. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers. MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/rust-by-example/master/LICENSE-MIT). Copyright the Rust Project Developers.

Cite this

Permanent ID: iil:note:1r8nwdt1

iinventedlight. 2026. "Documenting and publishing a Rust crate." iinventedlight Library, iil:note:1r8nwdt1, version of 2026-11-23. https://iinventedlight.com/library/notes/rust-publishing-crates/. License: CC-BY-4.0.

@misc{iil_note_1r8nwdt1,
  author = {{iinventedlight}},
  title = {{Documenting and publishing a Rust crate}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-23},
  url = {https://iinventedlight.com/library/notes/rust-publishing-crates/},
  note = {Permanent ID iil:note:1r8nwdt1. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/rust-publishing-crates.md.