Skip to content

Convert rust,ignore doc examples to compile-checked forms (no_run) #146

@lxsaah

Description

@lxsaah

Problem

The workspace has ~108 doc examples marked rust,ignore/ignore that are never compiled by cargo test --doc, versus only ~29 that are compile-checked (rust, rust,no_run, no_run). After two API-moving refactor rounds (#131/#135, then the 036 series #141#144), uncompiled examples are guaranteed rot magnets — and a spot-check during the post-036 debt scan confirmed it:

  • aimdb-core/src/builder.rs — the AimDb example chained .register_record(...) (returns &mut Self) into .build() (takes self by value); it could not compile as written.
  • aimdb-core/src/remote/mod.rs — example used .build()? against the async build() -> (AimDb, AimDbRunner) signature.
  • aimdb-core/src/connector.rs — module example was built on RecordConfig::builder(), an API that never existed.

Those three were fixed in PR #145, but only because they happened to be spot-checked. The remaining ~105 have no protection.

Per-crate counts (scan of 2026-06-12, stack-tip branch)

crate ignored examples
aimdb-core 54
aimdb-sync 12
aimdb-websocket-connector 11
aimdb-mqtt-connector 7
aimdb-knx-connector 6
aimdb-embassy-adapter 5
aimdb-data-contracts 4
aimdb-uds-connector, aimdb-derive 2 each
wasm-adapter, tokio-adapter, serial-connector, persistence, persistence-sqlite 1 each

Proposed approach

For each example, in order of preference:

  1. no_run — compiles in doc tests but doesn't execute. Right default for examples needing a runtime, broker, socket, or hardware. Add hidden setup lines (# use …;, # async fn demo() -> … {, # }) to make fragments compile.
  2. Plain ```rust — where the example can actually run (pure types, parsing, config builders).
  3. Keep ignore only where compiling is genuinely impossible (e.g. Embassy/no_std-only API illustrated from a std doc build, codegen output sketches) — and leave a one-line comment in the doc saying why.

Notes:

  • aimdb-core examples that reference aimdb_tokio_adapter can't compile from core (dependency direction). Options: illustrate with the test-support runtime/mocks core already uses internally, or keep those specific ones ignore with rationale. Decide once, apply consistently.
  • Embassy-adapter examples likely fall under the legitimate-ignore carve-out (host doc builds can't compile thumb-only API), same for aimdb-derive macro-expansion sketches.
  • Mechanical and parallelizable per crate; good opportunistic work to fold into whatever next touches each crate, with aimdb-core (54, half the total) worth a dedicated pass.

Acceptance

  • Every remaining ignore fence has a reason it can't be no_run.
  • cargo test --doc (std combos via make test) compiles all converted examples; CI keeps them honest from then on.

Origin: post-036 technical-debt scan (2026-06-12); follow-up to PR #145, which fixed only the spot-checked stale examples. Related: design docs 034 §3 (doc-rot findings), 036.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions