I just added a module dependency graph generator by following a similar process to the library which I used for class hierarchies. I'd be willing to bet that Andrei wants to apply it to Phobos, and that is indeed a thing that can be done.

There's an example on GitHub, and the readme explains how to run it. The example outputs... this. (Try not to scream.)

https://i.imgur.com/Af4RKuc.png

So like you might expect for Phobos. Everything importing everything else, just about. I have a few comments on this.

The library just gives you the DOT file as output, not the image. Graphviz probably lets you pick different strategies for how a graph should be drawn. Drawing a graph is really complicated, so it's best to leave that to Graphviz. I believe you can specify drawing co-ordinates for vertices in a DOT file. In any case, how the graph is drawn in the end is a probably a user decision.

Like the previous class example, you can filter out modules from the output with a regular expression. You will probably have to do this to get sensible output, as you might not care which standard library modules you're depending on, or you might care, but not for a few modules in particular, etc.

The filters and the methods can be combined to only look at particular sets of modules at a time, so you can generate graphs for only a subset of Phobos, etc. This might help in making the imports look more like a binary tree.

Back on the class hierarchies. I hit a bit of a snag with that. I have been using ModuleInfo and ClassInfo to generate the diagrams, but ClassInfo is a runtime feature which has no knowledge of method or attribute names. So I might have to use compile time reflection all the way for that. So in short, I haven't thought of a good way to get method and attribute names into the output yet.

As an aside, ModuleInfo has been undocumented forever, as far as I can tell. Would it be possible to get some documentation for ModuleInfo up on the site? I've been figuring out how to use it just by reading object_.d. If it was documented, someone else would have probably written this stuff I'm writing by now already, because it's really simple code.

Reply via email to