I’m happy to announce the availability of dune-deps, a command-line tool that scans a dune project and gathers the dependencies into a graph. The output is in the dot format, supported by the dot command from graphviz.
It shows the dependencies between the following:
libraries defined by the project,
executables defined by the project,
direct dependencies on external libraries.
Dependencies are extracted by parsing dune files. As an example, here’s what we obtain for the sources of opam, which has over 50K lines of code:
Since the original announcement, I received some good feedback from users working on large projects. Thank you!
The latest version released today is 1.2.0. It is already available on opam-repository (thank you @kit-ty-kate). The changes since the original release, besides bug fixes, include:
Ability to select or ignore dune files and folders to scan. For example, dune-deps foo bar -x bar/test uses all the dune files found in folders foo and bar but will ignore bar/test. This is useful for ignoring uninteresting parts of the project and for ignoring parse errors (see bug #4).
Executable name disambiguation. For example, private executables of the same name like foo/main and bar/baz/main are now rendered as main<foo> and main<baz> respectively instead of just main.
Optional exclusion of all executables or all external libraries with --no-exe and --no-ext.
Ability to show only the dependencies and/or the reverse dependencies of selected libraries. See below.
Whole-project graphs for large projects tend to be unreadable. To deal with that, I added support for an “hourglass view” () option for showing only the dependencies and reverse dependencies of a component of interest.
The following is obtained with -h opam-client on the opam project:
Please let us know if this works for your favorite projects! The source code of dune-deps makes it somewhat easier now to experiment with new strategies for eliminating nodes. See the Filter and Filterable modules.
Check out dune-deps --help for detailed documentation on the options.
So, I made a generic yaml workflow that people can stick into their git/github project. This will automatically maintain the dependency graph .deps/deps.png which can be included in a readme.