jplatte / cargo-depgraph

Creates graphviz dependency graphs for Rust projects that use Cargo
GNU General Public License v3.0
151 stars 8 forks source link

Keep transitive deps that would look optional after pruning #15

Open RagnarGrootKoerkamp opened 1 year ago

RagnarGrootKoerkamp commented 1 year ago

Locally I wrote some code to generate the image below. This deduplicates transitive dependencies, but keeps those that 'go around' optional deps. I.e., the solid line between pa-web and pa-vis is nice because without it (the current behavior) it would seems as though a large part of the tree is optional, while in fact it's not.

Would you accept a PR for it? And in that case, what should the flag be named? I'm not sure myself. And should this be default?

depgraph

jplatte commented 1 year ago

I think it makes sense for this to be the default behavior of --dedup-transitive-deps, not just for optional dependencies, but target-specific dependencies as well.

RagnarGrootKoerkamp commented 1 year ago

Yes I agree. Then the question becomes how to handle optional and target-specific dependencies when there is a path of optional/target-specific dependencies (as opposed to a path of required dependencies where the situation is simple).

I think optional deps should still be shown, but target-specific deps can be inferred through each other.

One issue with this could be when a long chain of packages has a similar feature flag to enable one specific dependency (say clap), and then we draw multiple optional lines to that package. On the other hand, drawing the dependency only for the bottom one isn't complete either.