Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add '--uses' ie: cargo modules structure --no-fns --no-traits --no-types --uses #265

Open
cameronelliott opened this issue Feb 21, 2024 · 2 comments

Comments

@cameronelliott
Copy link

While --uses might not seems as logical under the structure sub-command as the dependencies, I think it could be useful for some people.

On the project I am working on, dependencies even with --focus-on produces graphs that are far too busy to be usable. (I have tried many of the --layout options)

So, I think being able to see the uses in the structure view would be quiet useful.

Thank you for making cargo-modules, it is really great!

@regexident
Copy link
Owner

Ho Cameron,

do you have a sort of sketch of how you would envision such uses to be visualized via the structure sub-command?

@duckki
Copy link

duckki commented Mar 29, 2024

This is something I want as well. My use case is when I start to read an existing codebase and want to identify the "leaves" of dependency forest. "owns" relationship is already reflected by the directory structure of the code.

But, I don't think such an output can be a tree form like structure command. One way to achieve something like this is by topologically sorting the "use"-dependency graph. That'd be just a list.

A more elaborate presentation would be a layered graph. The leaf nodes are on the top layer. Then, nodes that are directly dependent on them are on the next layer. And so forth. Towards the bottom, modules are increasingly more dependent on other modules. That will be similar to the "tech tree" presentation on video games. We may need to deal with cycles by breaking cycles favoring certain edges or by treating cycles as groups (aka Tarjan's strongly-connected component).

tech tree

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

No branches or pull requests

3 participants