The crate root names files a docs.rs reader cannot open
- Lingua principale
- Rust
- Stelle
- 9
- Fork
- 1
- Merge medio
- 11h 46m
- PR unite (30g)
- 62
Descrizione
## What
`src/lib.rs`'s crate-level docs name `examples/dashboard.rs` and
`examples/dashboard_composed.rs` as one application written both ways. On
docs.rs those are inert code spans: the source browser carries only files
reachable from the crate root, so nothing there opens them.
The same holds for every `docs/...` path named in rustdoc across `src/` —
`docs/testing.md` in `src/panic.rs:163` and `src/test_support/*`,
`docs/rfcs/0009-clock-di.md` in `src/subscription/time.rs:32`. Those are in
internal or test-support items; the crate root is the first user-facing page to
do it.
## Why it is worth deciding
The crate root is the page a reader arriving from crates.io starts on, and
since #378 it states that there are two ways to write a program. The reference
for the second one is reachable — the [`reducer`] module link — but the worked
example that shows it, and `docs/composition.md`, which says when the rewrite is
worth it, are not.
`docs/composition.md` is additionally not in the published crate at all:
`Cargo.toml`'s `include` ships `src/**/*`, `examples/**/*`, `tests/**/*`,
`benches/**/*`, `README.md`, `CHANGELOG.md`, `LICENSE`, `Cargo.toml` and one
migration guide. So a reader holding the `.crate` has the examples but not the
guide, and a reader on docs.rs has neither.
## Options, none of them obviously right
- **Absolute URLs into the repository.** Works from docs.rs, and no rustdoc
feature is needed. Against: no rustdoc in this crate does it today, and a URL
pins a host and a branch — the shape `docs/releasing.md` and #350 already
treat as a maintenance cost.
- **`#![doc = include_str!("../README.md")]`,** or a section of it. The README
is packaged and already links both the guide and the examples one paragraph
from the same claim. Against: it duplicates the crate root's own material, and
the README's fenced blocks are compiled by nothing today — pulling it into
rustdoc would make every one of them a doctest.
- **Ship `docs/composition.md` in `include` and pull it in like the migration
guide.** `src/lib.rs` already does exactly this for
`docs/migrations/0.10-to-0.11.md` under `cfg(doctest)`. Against: that entry
exists to *compile* the guide's snippets, not to publish it, and the include
comment records a deliberate file-by-file policy.
- **Accept it** and say so, on the ground that docs.rs's sidebar carries a
repository link and the crate root is a reference page rather than a guide.
The choice is about what the crate root is for, which is a judgment rather than
something the observation settles.
## Provenance
Raised in review of #378. That PR closed the half it could: the examples it
names are packaged, so the reference resolves for a reader holding the crate,
and it deliberately does not name `docs/composition.md`, which is not. What it
cannot close from `src/lib.rs` alone is the docs.rs reader's route.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.