Skip to content

build: link each crate's README from its manifest - #838

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:build/manifest-readme-key
Aug 12, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:build/manifest-readme-key

Conversation

@vyncint

@vyncint vyncint commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Every workspace crate has had a README since #818, and no manifest pointed at
one. This adds an explicit readme = "README.md" key to all twenty-six.

What the key changes: Cargo has auto-inferred a root README.md since 1.46,
so crates.io already picked these files up without it (and docs.rs front pages
render the crate docs from lib.rs, not the README, either way). What the
explicit key adds is robustness and self-documentation: if a named README is
renamed or deleted, cargo package fails loudly instead of silently
publishing a bare page, and tools reading crate metadata get a stated link
rather than an inference. Large workspaces (tokio, serde, clap) write the key
for the same reason.

Per-crate, not inherited — deliberately

[workspace.package] already carries edition, authors, license and
repository, and each crate inherits them with .workspace = true. readme
cannot follow that pattern: Cargo resolves a workspace-level readme
relative to the workspace root, so inheriting it would point all
twenty-six crates at the top-level README instead of their own. There is no
relative-to-member form, so the key belongs in each manifest — placed next to
description, the other per-crate metadata key.

Applied to all twenty-six, including the two publish = false crates. The key
is inert there, and a uniform rule is easier to keep than an exception list
that invites the question later.

Verification

  • cargo metadata --locked parses; every member reports a readme (as before
    via inference; now stated explicitly);
  • every readme path points at a file that exists (checked, 0 broken);
  • scripts/check-dependency-licenses.sh, which reads cargo metadata, is
    still green — the one guard this could plausibly have disturbed.

No code, no behaviour change.

(Maintainer edit: reworded the motivation and first verification bullet — the
original text described READMEs as unreachable without the key, but Cargo
auto-infers a root README.md since 1.46; the key's value is the fail-loud
cargo package check and explicitness, not new rendering.)

Every workspace crate has had a README since NVIDIA#818, and no manifest pointed
at one. `readme` is what puts that file on the crate's docs.rs and
crates.io front page; without it those pages carry the one-line
`description` and nothing else. Twenty-four of the twenty-six crates are
publishable, so the READMEs were written and then left unreachable from the
place a reader arrives.

Per-crate rather than inherited, deliberately. `[workspace.package]`
carries edition, authors, license and repository, and inheriting `readme`
from there would resolve every crate's path against the workspace root --
pointing all twenty-six at the top-level README instead of their own.
Cargo offers no relative-to-member form, so the key belongs in each
manifest, next to `description`, which is the other per-crate metadata key.

Applied to all twenty-six, including the two `publish = false` crates. The
key is inert there, and a uniform rule is easier to keep than an exception
list that invites the question later.

Verified: `cargo metadata --locked` parses and now reports a readme for
25/25 members it resolves, every path points at a file that exists, and the
license inventory guard -- which reads `cargo metadata` -- is still green.

Signed-off-by: Vyncint Ng <[email protected]>
@vyncint
vyncint requested a review from nihalpasham as a code owner August 12, 2026 10:17
@nihalpasham nihalpasham added build-related Build scripts, toolchain discovery, or compilation setup QoL-improvement Quality-of-life improvement; not a correctness fix labels Aug 12, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Gist: right change, wrong story. The explicit readme key is worth having: cargo package fails loudly if a named README goes missing instead of silently shipping a bare page, and it matches the tokio/serde/clap convention. But Cargo has auto-inferred a root README.md since 1.46, so the pages were never blank; I've reworded the PR description so the history records what actually changed. The per-crate placement over workspace inheritance is correctly reasoned (a workspace-level readme resolves against the workspace root).

Verified here:

  • all 26 target manifests exist on main with no prior readme key and no workspace.package.readme;
  • inference behavior confirmed on the pinned cargo (1.98-nightly): metadata reports README.md with no key present;
  • key placement uniform, next to description, including the two publish = false crates.

Landing once CI is green.

@nihalpasham
nihalpasham merged commit af642bf into NVIDIA:main Aug 12, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-related Build scripts, toolchain discovery, or compilation setup QoL-improvement Quality-of-life improvement; not a correctness fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants