Skip to content

Use README as crate-level rustdoc#5

Merged
coderdan merged 1 commit intomainfrom
readme-as-docs
May 2, 2026
Merged

Use README as crate-level rustdoc#5
coderdan merged 1 commit intomainfrom
readme-as-docs

Conversation

@coderdan
Copy link
Copy Markdown
Collaborator

@coderdan coderdan commented May 1, 2026

Summary

Replaces the inline //! doc block in `src/lib.rs` with a single
`#![doc = include_str!("../README.md")]` so the docs.rs landing page
and the GitHub README stay in sync without manual duplication.

The two relative LICENSE links in the README become absolute GitHub URLs
so they still resolve when rendered from docs.rs (relative links would
404 against the crate root URL there).

Why

The previous `//!` block was a strict subset of the README — every
section there is also in the README, plus the README has more (drop-in
compat status, benchmarks, error-type migration). Single source of truth
is easier to keep current.

Test plan

  • `cargo test --doc` — the README's `let data = b"hello, world!"` example runs as the crate doctest (1 passes)
  • `cargo doc --no-deps` with `RUSTDOCFLAGS=-D warnings` — clean
  • `cargo test --locked` — 47 tests pass
  • `cargo clippy --all-targets --locked -- -D warnings` — clean
  • `cargo fmt --all -- --check` — clean
  • CI matrix green

Replaces the `//!` doc block in lib.rs with a single
`#![doc = include_str!("../README.md")]` so the crate root on
docs.rs and the GitHub README stay in sync without duplication.

The two relative `LICENSE-APACHE` / `LICENSE-MIT` links in the
README are switched to absolute GitHub URLs so they still resolve
when rendered from docs.rs (relative links would 404 from the
crate root URL there).

The doctest in the README — the `let data = b"hello, world!"...`
example — runs as the crate's doctest, replacing the identical
one that was inline in lib.rs. Verified locally:
  - cargo test --doc       (1 doctest passes)
  - cargo doc --no-deps with RUSTDOCFLAGS=-D warnings  (clean)
  - cargo test --locked    (28 unit + 18 parity tests pass)
  - cargo clippy --all-targets --locked -- -D warnings (clean)
  - cargo fmt --all -- --check                         (clean)
@coderdan coderdan merged commit e4af17b into main May 2, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant