Skip to content

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

Open
bpodwinski wants to merge 5 commits intosnowmead:mainfrom
bpodwinski:feat/cache-crate-specific-features
Open

feat: add features parameter to cache_crate for mutually exclusive features#57
bpodwinski wants to merge 5 commits intosnowmead: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

Copy link
Copy Markdown
Owner

@snowmead snowmead left a comment

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.


/// Get a description of this strategy for logging
fn description(&self) -> &str {
fn description(&self) -> String {
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.

I don't see why this needs to return a String instead of &str

Comment on lines 389 to 398
/// Run cargo rustdoc with JSON output for a crate or specific package
///
/// # Parameters
/// - `source_path`: The root directory containing Cargo.toml
/// - `package`: Optional package name for workspace members
/// - `target_dir`: Optional custom target directory to avoid conflicts when building
/// multiple workspace members concurrently. When building multiple workspace members
/// in parallel, each must use a unique target directory to prevent cargo from
/// conflicting with itself. See [`DocGenerator::generate_workspace_member_docs`](crate::cache::docgen::DocGenerator::generate_workspace_member_docs)
/// for the implementation pattern.
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.

All these docs should be above run_cargo_rustdoc_json

Comment on lines +399 to +414
fn build_feature_strategies(features: Option<Vec<String>>) -> Vec<FeatureStrategy> {
if let Some(feats) = features {
vec![
FeatureStrategy::Specific(feats),
FeatureStrategy::DefaultFeatures,
FeatureStrategy::NoDefaultFeatures,
]
} else {
vec![
FeatureStrategy::AllFeatures,
FeatureStrategy::DefaultFeatures,
FeatureStrategy::NoDefaultFeatures,
]
}
}

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.

I would remove this bloat

Comment on lines -426 to -431
// Try different feature strategies in order
let strategies = [
FeatureStrategy::AllFeatures,
FeatureStrategy::DefaultFeatures,
FeatureStrategy::NoDefaultFeatures,
];
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.

we could just add an if features is specified, add it to the array, simpler to reason about

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.

this would require removing all the tests below

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.

We should add actual integration tests for to make sure specifying features works

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