docs: convert doc examples to tested doctests#504
Merged
Conversation
Most code examples in the embedded docs (custom_builtins.md, threat-model.md, python.md, logging.md) used `rust,ignore` fencing, which meant rustdoc marked them as "not tested". Convert complete examples to testable doctests using hidden `# ` boilerplate lines. Fix MountableFs::new() call in threat-model.md to match actual API. 14 examples now compile-tested by `cargo test --doc --all-features`. Examples using external crates (sqlx, reqwest, tracing-subscriber) or feature-gated APIs in non-gated modules remain `rust,ignore`. Update spec 008-documentation with fencing rules and doctest guidance. https://claude.ai/code/session_01ALmXdnbcnFsF9EY3Aw8MLT
Three doc tests using .network() failed without http_client feature since BashBuilder::network() is behind #[cfg(feature = "http_client")]. Change fencing to rust,ignore for these examples in non-feature-gated modules (crate docs, compatibility.md, network mod docs). https://claude.ai/code/session_01ALmXdnbcnFsF9EY3Aw8MLT
CI resolves to newer versions than what's in our Cargo.lock: - getrandom 0.4.2 (safe-to-run) - r-efi 6.0.0 (safe-to-deploy) - tokio 1.50.0 (safe-to-deploy) https://claude.ai/code/session_01ALmXdnbcnFsF9EY3Aw8MLT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rust,ignoreto compiled/tested doctests acrosscustom_builtins.md,threat-model.md,python.md, andlogging.md.network()(behindhttp_clientfeature) in non-feature-gated modules now correctly userust,ignoreMountableFs::new()call inthreat-model.mdto match actual API signaturespecs/008-documentation.mdTest plan
cargo test --doc(no features) — 76 passed, 0 failedcargo test --doc --all-features— 84 passed, 0 failedcargo doc --no-depsbuilds without errorsjust check(fmt + clippy + test) passes