From 040a3231df2e1691c8be9925c0e7dc935dd16f8d Mon Sep 17 00:00:00 2001 From: nomaterials Date: Thu, 4 Jun 2026 09:20:05 +0200 Subject: [PATCH] docs: fix execution_graph README Quick Start and compile both READMEs in CI The execution_graph README Quick Start dropped `?` on `add_node` and `set_input_value` (both return `Result`), so the `fn main()` example failed to compile with two E0308s. A reader's first copy-paste from the docs would not build, while the lib.rs doctest stayed correct because only it was exercised by CI. To stop this drift recurring, include each crate's README.md as a `#[cfg(doctest)]` item so the existing `cargo test --doc --workspace` step compiles the Quick Start. The item exists only under `cfg(doctest)`, so it never appears in rendered docs and is invisible to clippy and normal builds. execution_tape's README already compiled; its guard is purely protective. --- execution_graph/README.md | 4 ++-- execution_graph/src/lib.rs | 10 ++++++++++ execution_tape/src/lib.rs | 10 ++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/execution_graph/README.md b/execution_graph/README.md index 9847098..2edd2eb 100644 --- a/execution_graph/README.md +++ b/execution_graph/README.md @@ -52,8 +52,8 @@ fn main() -> Result<(), Box> { let program = Arc::new(builder.build_verified()?); let mut graph = ExecutionGraph::new(NoHost, Limits::default()); - let node = graph.add_node(program, entry, vec!["x".into()]); - graph.set_input_value(node, "x", Value::I64(41)); + let node = graph.add_node(program, entry, vec!["x".into()])?; + graph.set_input_value(node, "x", Value::I64(41))?; let summary = graph.run_all()?; assert_eq!(summary.executed_nodes, 1); diff --git a/execution_graph/src/lib.rs b/execution_graph/src/lib.rs index 5dd36c5..c613616 100644 --- a/execution_graph/src/lib.rs +++ b/execution_graph/src/lib.rs @@ -86,3 +86,13 @@ mod tape_access; pub use access::{Access, AccessLog, HostOpId, NodeId, ResourceKey}; pub use graph::{ExecutionGraph, GraphError, NodeOutputs}; pub use report::{NodeRunDetail, ReportDetailMask, RunDetailReport, RunSummary}; + +/// Compiles the `README.md` code blocks as doctests so the Quick Start cannot +/// drift out of sync with the API. +/// +/// This item exists only under `cfg(doctest)` (set while `cargo test --doc` +/// extracts doctests), so it is never built into the crate and never appears in +/// the rendered documentation. +#[cfg(doctest)] +#[doc = include_str!("../README.md")] +struct ReadmeDoctests; diff --git a/execution_tape/src/lib.rs b/execution_tape/src/lib.rs index 798ec91..559e93f 100644 --- a/execution_tape/src/lib.rs +++ b/execution_tape/src/lib.rs @@ -86,3 +86,13 @@ pub(crate) mod typed; pub mod value; pub mod verifier; pub mod vm; + +/// Compiles the `README.md` code blocks as doctests so the Quick Start cannot +/// drift out of sync with the API. +/// +/// This item exists only under `cfg(doctest)` (set while `cargo test --doc` +/// extracts doctests), so it is never built into the crate and never appears in +/// the rendered documentation. +#[cfg(doctest)] +#[doc = include_str!("../README.md")] +struct ReadmeDoctests;