fix(doc): Fix docs.rs build failure for metrique crate#245
Merged
Conversation
The packaged docs-rs build was falling back to a workspace build on failure, masking errors where scraped examples reference dev-only crates. Remove the fallback when the packaged build fails (only fall back when cargo package itself fails). Also restore doc-scrape-examples flags that cargo package may strip, so the packaged build faithfully reproduces docs.rs behavior.
The example uses metrique_util::State (a dev-dep), which is unavailable during doc scraping on docs.rs. Set doc-scrape-examples = false.
5bfac62 to
38ee993
Compare
rcoh
approved these changes
Mar 17, 2026
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.
Fix docs.rs build failure for
metriquecrateSummary
The docs.rs build for metrique 0.1.21 fails because the
global-stateexample hasdoc-scrape-examples = trueand usesmetrique_util::State, butmetrique-utilwas only a dev-dependency. On docs.rs, dev-dependencies are stripped, so example scraping fails withunresolved import metrique_util.Two changes:
check-docsrs.sh: the script was not catching this class of failure. When the packaged docs-rs build failed, it silently fell back to a workspace build where dev-deps are available, masking the error. The fix removes the fallback when the packaged build itself fails (the fallback is preserved only whencargo packagefails, e.g. for unpublished crates). It also restoresdoc-scrape-examples = trueflags thatcargo packagemay strip from the packaged Cargo.toml, so the packaged build faithfully reproduces docs.rs behavior.metrique/Cargo.toml: addsmetrique-utilas an optional dependency behind a newutilfeature (which enablesmetrique-util/state). Theglobal-stateexample is gated onrequired-features = ["emf", "service-metrics", "util"]. Since docs.rs builds with--all-features, the feature is enabled and the example compiles during doc scraping.Testing
check-docsrs.sh metriquereproduces the exact docs.rs error before the Cargo.toml fix (E0432: unresolved importmetrique_util).check-docsrs.sh metriquepasses after the Cargo.toml fix.cargo check -p metrique --all-featurespasses.🔏 By submitting this pull request