Skip to content

feat: add features parameter to cache_crate for mutually exclusive features#57

Open
bpodwinski wants to merge 9 commits into
snowmead:mainfrom
bpodwinski:feat/cache-crate-specific-features
Open

feat: add features parameter to cache_crate for mutually exclusive features#57
bpodwinski wants to merge 9 commits into
snowmead:mainfrom
bpodwinski:feat/cache-crate-specific-features

Conversation

@bpodwinski

Copy link
Copy Markdown

Summary

  • Adds an optional features parameter to cache_crate allowing users to
    specify exact Cargo features instead of --all-features
  • Introduces FeatureStrategy::Specific(Vec<String>) variant in rustdoc.rs
    with fallback order: Specific → DefaultFeatures → NoDefaultFeatures
  • Fixes caching failures for crates with mutually exclusive features (e.g.
    leptos-use with axum vs actix)
  • Syncs README.md and install.sh with current tool list (cache_crate
    unified tool, cache_operations)

Test plan

  • Unit tests added for FeatureStrategy::Specific — args and description
  • cargo fmt and cargo clippy pass
  • Manual test: cache a crate with mutually exclusive features

cache_crate({crate_name: "leptos-use", source_type: "cratesio",
version: "0.15.8", features: ["axum"]})

  • Verify fallback still works when features is omitted

@snowmead snowmead left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change!

I noticed there are a few places not covered in some of the crate caching paths for accepting a feature set. Please make sure all of them can accept features. That way some tools don't download all the features by default.

Comment thread rust-docs-mcp/src/rustdoc.rs Outdated
Comment thread rust-docs-mcp/src/rustdoc.rs
Comment thread rust-docs-mcp/src/rustdoc.rs Outdated
Comment thread rust-docs-mcp/src/rustdoc.rs
Comment thread rust-docs-mcp/tests/integration_tests.rs
…y impl

Avoids unnecessary String allocations on static variants per @snowmead
review on PR snowmead#57. Display writes directly into the formatter, so static
variants do zero alloc and Specific streams its features without a join +
format! intermediate String.
Remove build_feature_strategies per @snowmead review on PR snowmead#57. The
helper was called once and duplicated fallback variants.
Cover:
- test_cache_with_specific_features — local fixture with axum/actix features,
  verifies that features=["axum"] produces docs with axum symbols and
  excludes actix symbols.
- test_cache_workspace_member_with_features — same assertion on a workspace
  member, validates the features propagation fix.
- test_cache_leptos_use_with_axum_feature — end-to-end reproduction of
  the motivating scenario against crates.io (~80s).
- test_cache_respects_feature_change — #[ignore]'d, expected to fail.
  Documents a pre-existing cache-key bug (features not part of cache
  identity): re-caching with a different feature set returns stale docs.
  Will pass once the cache key is feature-aware (separate follow-up).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants