C.W.K.
Stream
Lesson 06 of 06 · published

Docs, docs.rs & Publishing

~10 min · tooling, docs, crates-io, semver

Level 0Rust Curious
0 XP0/80 lessons0/19 achievements
0/100 XP to next level100 XP to go0% complete

The final piece of the toolchain is the ecosystem itself — how you find, document, and publish crates. cargo doc, docs.rs, and crates.io close the loop.

cargo doc: docs from code

cargo doc --open generates HTML documentation from your /// comments and type signatures, and opens it in a browser. Every Rust crate's docs are generated this way, so they all look and navigate identically. Your doc comments — the same ones whose examples are doctested — become a polished reference site for free.

docs.rs: the universal docs host

Every crate published to crates.io gets its documentation auto-built and hosted at docs.rs. When you depend on a crate, docs.rs/<crate> is your reference — generated from that exact version's source. It's why exploring an unfamiliar Rust crate is fast: the docs are always there, always current, always in the same format.

docs.rs is your first stop for any crate. Before guessing at a crate's API or web-searching, open docs.rs/<crate-name>. It's generated from the source, versioned, and complete — far more reliable than a blog post or an AI's memory of an old version. Reading docs.rs is a core Rust skill.

Publishing and semver

cargo publish pushes a crate to crates.io for the world to use. With that power comes the semver contract: a MINOR or PATCH bump must stay backward-compatible; breaking changes require a MAJOR bump. The whole ecosystem's reliability rests on crate authors honoring this — and Cargo's version resolution assuming they do. You've now seen the full loop: write, test, document, publish.

Code

Generate docs locally; read any crate's on docs.rs·bash
# Generate and open your crate's docs locally
cargo doc --open

# Any dependency's docs are auto-hosted, e.g.:
#   https://docs.rs/serde     https://docs.rs/tokio

# Publish your own crate to crates.io (semver applies):
#   cargo publish    # MAJOR.MINOR.PATCH — breaking changes bump MAJOR

External links

Exercise

Run cargo doc --open on a project with documented functions and browse the generated site. Then open docs.rs/serde (or any crate you've used) and find a specific method's signature and example. Why is reading docs.rs more reliable than asking an AI or reading a years-old blog post about the crate?
Hint
docs.rs is generated from the exact source of a specific version — it can't be out of date or hallucinated. A blog post or an AI's training data may describe an old API that changed. For Rust crates, the generated docs are ground truth.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.