Skip to content

docs(crates): promote item prose stranded below its own rustdoc block - #7613

Merged
oferchen merged 3 commits into
masterfrom
docs/promote-stranded-item-prose
Sep 2, 2026
Merged

oferchen merged 3 commits into
masterfrom
docs/promote-stranded-item-prose

Conversation

@oferchen

@oferchen oferchen commented Sep 1, 2026

Copy link
Copy Markdown
Owner

What

An item already carries a /// block, and prose about that same item sits between the block and the item as //:

/// Which `--info=FLAG` names an info level, and indexes into `info_levels[]`.
// upstream: rsync.h INFO_BACKUP..INFO_SYMSAFE, options.c:228 info_verbosity[]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum InfoFlag {

rustdoc stops at the first non-doc line, so that citation is invisible in the generated docs while reading, in source, as though it were part of the doc block. crates/bandwidth/src/limiter/core/limiter.rs even ends its doc block with a bare /// before the stranded // upstream: io.c:sleep_for_bwlimit().

This promotes those runs to ///. Pure in-place // -> ///; nothing moves, no text changes after the marker.

Scope, measured not estimated

A census of all 224,455 comment lines in crates/ classified them, then split the "// run directly above an item" population by shape:

shape count action
item has rustdoc, run carries an upstream citation 183 promoted
item has rustdoc, run is plain prose 6 promoted
item has no rustdoc, run carries a citation 505 untouched
item has no rustdoc, run is plain prose 279 untouched

The bottom two rows are deliberately left alone: there the // is a legitimate non-doc implementation note, and promoting it would newly document the item. That is a per-site judgement call, not a mechanical move.

Restricting the top two rows to the published surface (rustdoc emits nothing for test/bench targets or #[cfg(test)] items, so promoting there is churn with no reader) gives the 164 lines across 50 files in this diff. git diff --shortstat is 164 insertions(+), 164 deletions(-) — confirming the pure in-place rewrite with no line movement.

The check that matters here

154 of the 164 lines carry an upstream citation, so the binding question is whether the citation gate still sees them.

tools/ci/citation_drift_audit.py --ratchet -> ratchet OK, no crate above its baseline. The gate filters on the word upstream plus a \b([a-z_0-9]+)\.c:(\d+) regex and is syntax-agnostic about the comment marker, so // -> /// preserves every one of the 23,500+ citations. That is measured, not assumed.

Other verification

  • cargo fmt --all -- --check — clean
  • cargo check --workspace --all-features — clean
  • cargo doc --workspace --no-deps — every diagnostic location is in a file absent from this diff (core/src/lib.rs, rsync_io/src/lib.rs, core/.../module_list/types.rs, transfer/src/pipeline/receiver.rs), so all are inherited by construction
  • cargo clippy --workspace --all-targets --all-features — zero doc lints; doc_markdown does not fire on the promoted options.c:89-style citations, which was the real risk of turning these into rustdoc

Not in scope

Three defect classes I expected to find measured as ~zero, each refuted by sampling before acting:

  • commented-out code (300 raw hits) — all wrapped prose continuation lines beginning for/if/while/match. Zero real.
  • stale TODO/FIXME markers (8) — all XSTATE_TODO xattr protocol state, the upstream-mirrored enum variant.
  • stale symbol references in docs (9,966 raw hits) — Win32 API names (ReadFile, WriteFile), CAP_SYS_NICE, criterion benchmark cell names, std types (FileExt).

The tree is already in good shape on documentation: 22 of 25 crates carry both #![deny(missing_docs)] and #![deny(rustdoc::broken_intra_doc_links)], and there are 146k rustdoc lines against 52k plain comment lines. The three crates lacking the doc lints (matching, test-support, windows-gnu-eh) are a real completeness gap but a separate change.

A census of all 224,455 comment lines in `crates/` found exactly one
coherent, mechanically-fixable defect class: an item already carries a
`///` block, and prose about that same item sits BETWEEN the block and
the item as `//`. rustdoc stops at the first non-doc line, so that prose
is invisible in the generated documentation while reading, in source, as
though it were part of the doc.

Measured population: 189 sites (183 carrying an upstream citation, 6
plain prose). Scoped to the published surface - test and bench targets
and `#[cfg(test)]` items are excluded, since rustdoc emits nothing for
them - the change is 164 lines across 50 files.

The fix is a pure in-place `//` -> `///` rewrite. Nothing moves and no
text changes after the marker, so every upstream citation keeps its file,
line and quoted anchor byte-for-byte.

Deliberately NOT touched: 505 citation runs and 279 prose runs sitting
above items that have NO rustdoc at all. There the `//` is a legitimate
implementation note, and promoting it would newly document the item -
a per-site judgement call, not a mechanical move.

Verification:
- `cargo fmt --all -- --check` clean
- `cargo check --workspace --all-features` clean
- `cargo doc --workspace --no-deps` reports no diagnostic in any changed
  file; every diagnostic location is in a file absent from this diff
- `cargo clippy --workspace --all-targets --all-features` reports zero
  doc lints; `doc_markdown` does not fire on the promoted citations
- `tools/ci/citation_drift_audit.py --ratchet` -> `ratchet OK`, no crate
  above its baseline, which is the load-bearing check here: the gate
  filters on the word `upstream` plus a `file.c:line` regex and is
  syntax-agnostic, so the promotion preserves all 23,500+ citations
…ve it

`fmt + clippy` failed with

    error: doc list item without indentation
      --> crates/core/src/version/report/renderer.rs:616:5
    note: `-D clippy::doc-lazy-continuation` implied by `-D warnings`

The promoted `upstream:` line landed directly beneath the bullet list
that enumerates the JSON key mappings, so rustdoc reads it as a lazy
continuation of the final `"optional secluded-args"` item.

Clippy offers two remedies - indent the line into that item, or separate
it into its own paragraph. The blank line is the correct one: the line is
the function's upstream citation, not a property of the last bullet, and
the citation-drift tooling scans for these lines on their own. Indenting
would bury a whole-function citation inside one list entry.

Verified with `cargo clippy -p core --all-targets --no-deps`: clean with
the blank line, and removing it reproduces the diagnostic at
renderer.rs:616 verbatim. A scan of all 50 files this branch touches
found exactly one site with this shape, so no sibling occurrence is
hiding behind clippy's first-error stop.
@oferchen
oferchen merged commit aa69351 into master Sep 2, 2026
74 checks passed
@oferchen
oferchen deleted the docs/promote-stranded-item-prose branch September 2, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant