docs(lib): assembly example compiles as no_run, not ignore; convention 16
- the crate-root assembly example was a ```ignore block, which rustdoc renders with the untested badge docs.rs surfaces on the crate page (the tooltip 'This example is not tested'); ```no_run blocks are compile-checked by doctests and get no badge - the example body is gated with hidden cfg lines (#[cfg(feature = "local")] around a hidden block): empty under default features, compile-checked under --all-features; the doctest now passes in both cargo test configurations instead of being skipped - AGENTS.md convention 16 records the rule: doc examples are tested or no_run, never ignore; feature-gated bodies via hidden cfg lines Verification: cargo test (doctest src/lib.rs line 39 now compile-... ok in default and --all-features); cargo doc --no-deps (no untested badge in the rendered HTML); clippy --all-targets --all-features -D warnings; fmt --check; wasm check; fuzz/shared corpus replay (9).
This commit is contained in:
1 parent
a701247ca6
commit
faa1c9ba10
2 files changed
+17
-1
No files matched your search
@@ -244,6 +244,19 @@ implementation agents.
|
||||
though en dashes inside numeric ranges keep their normal meaning.
|
||||
Hyphens in compound words (`wasm-clean`, `tty-wire`) are untouched.
|
||||
|
||||
16. **Doc examples must be compile-checked, never `ignore`.** rustdoc
|
||||
marks ` ```ignore ` blocks with an untested badge that docs.rs
|
||||
surfaces on the crate page (an ⓘ icon with the tooltip "This
|
||||
example is not tested"); `no_run` blocks get no badge, because
|
||||
doctests still compile them. So: prefer a fully tested doctest;
|
||||
otherwise `no_run`. For an example whose body needs a feature, gate
|
||||
the body with hidden cfg lines instead of ignoring the block:
|
||||
`# #[cfg(feature = "local")]` then `# {` and `# }`, so the example
|
||||
compiles (as an empty body) under default features and
|
||||
compile-checks under `--all-features`. Verify with `cargo test`
|
||||
(the doctest run) in both feature configurations; the crate-root
|
||||
assembly example in `src/lib.rs` is the reference pattern.
|
||||
|
||||
## Verification Commands
|
||||
|
||||
Run these before committing. All must pass.
|
||||
|
||||
+4
-1
@@ -36,7 +36,9 @@
|
||||
//!
|
||||
//! # Assembly pattern
|
||||
//!
|
||||
//! ```ignore
|
||||
//! ```no_run
|
||||
//! # #[cfg(feature = "local")]
|
||||
//! # {
|
||||
//! let mut backends = std::collections::HashMap::new();
|
||||
//! backends.insert(
|
||||
//! "local".into(),
|
||||
@@ -44,6 +46,7 @@
|
||||
//! as std::sync::Arc<dyn alktty::TtyBackend>,
|
||||
//! );
|
||||
//! let tty_adapter = alktty::TtyAdapter::new(backends);
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
//! # Crate-root surface
|
||||
|
||||
Reference in new issue
Block a user