Skip to content

docs: make published crate-root docs read for crates.io/docs.rs users #2442

Closed

Description

@thiras

Problem

Every crate except decdn-e2e ships to crates.io (release.yml → publish-crates.sh). That means docs.rs renders each crate's lib.rs //! docs and crates.io renders its README.md. decdn-client reads well to an outside user after #2436: it has a "Choose an entry point" table, runnable examples/, and doctests. The other crate roots are written for workspace contributors instead. They cite issue numbers, link repo-relative paths, use changelog voice, and give no map of the crate's API.

Findings

Survey of crates/*/src/lib.rs and Cargo.toml on main:

Crate //! lines Issues
protocol 4 Has no module map. Does not name the three ALPNs or point at the client/dht/framing/message/coverage/region/identity modules. It is the second crate in the public-API snapshot and a dependency of the client SDK, so SDK users land here.
incentive 25 One dense paragraph. Has no module map for voucher, capability, lane, buyer_pool, or the sol! bindings. Its main types are only reachable by reading the whole paragraph.
node 7 Cargo.toml description says "CLI entry point and runtime wiring". The crate is the daemon. Links appendix-local-admin-http.md as a bare filename.
reputation 9 "persistence deferred per §14a.3": ADR 008 has no §14a.3. This is a dangling reference.
bao-range 22 Changelog voice ("historically had to pull the whole blob"). The Cargo.toml description is a full paragraph that cites #578.
config-types 14 Compat-shim framing ("so existing decdn_cache::* paths in decdn-node keep resolving"). Cites adr/appendix-binaries.md as a repo-relative path.
cache 16 Cites adr/appendix-poc-production-seams.md as a repo-relative path. Has a broken mid-sentence line wrap ("one\n//! such backend — the").
common, cli 13 / 10 Acceptable. Both still cite issue numbers (#578).
e2e 23 publish = false. Fine as written. Out of scope except for the issue-number description.

Cross-cutting:

  1. Issue numbers in published docs. For example #578, #823, #831, #915, #406, and #1028. On docs.rs these are unlinked noise. They also record history, which goes against the present-tense-canon rule in CLAUDE.md.
  2. Repo-relative links. adr/… and crates/… paths do not resolve on docs.rs or crates.io. Use absolute https://github.com/decdn/decdn/blob/main/adr/… URLs, matching the workspace citation style.
  3. README and lib.rs drift independently. No crate uses #![doc = include_str!("../README.md")], and nothing checks that the two say the same thing. Pick one: include the README, or keep the README to the shared boilerplate plus one paragraph that matches the //! summary.
  4. No [package.metadata.docs.rs]. docs.rs builds default features only. So decdn-incentive's redb feature, which provides RedbBuyerPoolStore and which the CLI enables, is missing from the rendered docs, and no item shows a doc(cfg) badge. Decide per crate which features docs.rs builds. Test-only features (test-util, test-support, public-api-test) should stay out.
  5. No doctests or examples outside client/incentive. At minimum, protocol (encode/decode a message) and incentive (sign/verify a voucher) should each have one compiled example on the crate root.

Proposed scope

  • Rewrite the crate-root //! for protocol, incentive, node, reputation, bao-range, config-types, and cache. Each one gets a one-sentence purpose, a short module or entry-point map (modelled on decdn-client's table), and absolute ADR links. Remove issue numbers and history voice.
  • Fix the Cargo.toml description for node and bao-range, and drop issue numbers from every description.
  • Fix the dangling ADR 008 §14a.3 reference.
  • Decide on README/lib.rs single-sourcing and apply it to every published crate.
  • Add [package.metadata.docs.rs] where a user-facing feature exists (incentive/redb at minimum), and enable doc_cfg badges under cfg(docsrs).
  • Add one doctest to protocol and incentive crate roots.

Out of scope: item-level docs (missing_docs is already a gate) and decdn-client, which #2436 already covers.

Acceptance

  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items passes.
  • cargo publish --workspace --dry-run passes.
  • grep -nE '#[0-9]{3,}|historically|used to' crates/*/src/lib.rs finds nothing in published crates.
  • No //! crate-root link in a published crate is repo-relative.
  • Public-API snapshots regenerate cleanly if the root re-exports change.

Activity

  1. added
    kind:docs
    rust
    kind:chore
    on Oct 12, 2026
  2. self-assigned this
    on Oct 12, 2026
  3. assigned and unassigned on Oct 12, 2026
  4. moved this from Backlog to In progress in deCDNon Oct 12, 2026
  5. added a commit that references this issue on Oct 12, 2026
    d898a53
  6. moved this from In progress to Done in deCDNon Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:chorekind:docsrust

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions