sverweij / dependency-cruiser

Validate and visualize dependencies. Your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.
https://npmjs.com/dependency-cruiser
MIT License
5.15k stars 249 forks source link

Question: Can I access the classes/methods/functions in modules? #937

Closed Midnighter closed 3 months ago

Midnighter commented 3 months ago

Summary

I would like to do two things:

  1. Create a PlantUML output plugin (probably a class diagram, maybe a component diagram).
  2. In that diagram, I would like to list not only modules and their dependencies, but also individual classes with their methods and functions within those modules.

After skimming the result schema, I have the impression that this is not possible, but perhaps it is possible to reach for these entities at a deeper level since they surely must be in the AST?

Context

I'm creating a plan for re-organizing a code base. My idea was to create a picture of the current project state in PlantUML because that would rather quickly allow me to manually add how I would organize the code in the target state.

I realize that this may be out of scope, but I appreciate any pointers. Thank you 🙂

github-actions[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Midnighter commented 3 months ago

Stale without reaction from maintainers is not very nice to be honest.

sverweij commented 3 months ago

Hi @Midnighter sorry about that! Stalebot doesn't know when I'm taking time off to focus on my private well being - like having a holiday or taking care of family members. Maybe one day I'll teach it that.

As to your question: dependency-cruiser focuses on inter-module dependencies as the one thing to do well. Diving into details inside modules is possible (and interesting!), but will also take a lot of time to set up and maintain. If this would have been my full time, reliably paid job I might have dug into it (and created a separate program for it).

As an alternative: the makers of webstorm do build things like this for a living, though, and it might be their offering does what you need: https://www.jetbrains.com/help/webstorm/module-dependency-diagram.html

Related:

Midnighter commented 3 months ago

Hi Sander,

Thank you for the thoughtful response. I definitely support your taking time off, we do too little of that in this always on world.

Thanks for the pointer to webstorm, looks very interesting. And I completely understand that this is out of scope for dependency-cruiser. I will still use it for its intended purpose 😌.