Someone took the famous xkcd comic about dependency trees, hit it with some computer science and created a great toy. Would love someone with free time to extend the tool to run on hackage packages as well!
22 Likes
Does it create SVGs? I suspect some codebases might need it…
1 Like
It does create SVGs. That being said, dependencies in my projects are too messy for the renderer. They have non-planar crossing that the renderer doesn’t manage to eliminate. The graphs I tried all look pretty blocky too, which isn’t that insightful.
For the record, to generate a dependency graph with Stack I’ve come up with the following
$ stack dot --external > deps.dot # you can remove some packages with e.g. --prune "package1,package2"
$ dot -Tdot_json deps.dot > deps.json
$ cat deps.json | jq '(.objects | map({(._gvid|tostring): .name}) | add) as $objects | {nodes: .objects | map(select(.["name"] != "%1")) | map({id:.name}), edges: .edges | map({from: $objects[.tail|tostring], to: $objects[.head|tostring]})}' > deps-stacked.json
$ stacktower render deps-stacked.json -t tower --style handdrawn --merge -o deps.svg
This won’t have all the metadata that native parsers have, just the packages. But you can play with it that way
.
4 Likes