How to use

The main difference between module-graph and other tools based on ocamldep is that module-graph does not need to understand how your project is built: it just scans the directories looking for binary objects and computes the links between them.

In your project, just run:

$ module-graph
Generated 23 edges in "deps.dot" and "deps.pdf"
$ evince deps.pdf

By default, module-graph scans the current directory and its sub-directories, looking for .cmt/.cmti files. It only ignores the _opam/ sub-directory.

You can specify another set of directories to scan:

$ module-graph _build/default/src/parsers
Generated 6 edges in "deps.dot" and "deps.pdf"

You can change the format of the generated file with -T/--format FORMAT:

$ module-graph --format png
Generated 23 edges in "deps.dot" and "deps.png"
$ display deps.png

You can change the name of the generated file with -o/--output BASENAME:

$ module-graph -o alt-ergo-deps
Generated 23 edges in "alt-ergo-deps.dot" and "alt-ergo-deps.pdf"
$ evince alt-ergo-deps.pdf

In some cases, .cmt/.cmti files are not available, so you may want to use .cmi files with --cmi:

$ module-graph --cmi
Generated 21 edges in "deps.dot" and "deps.pdf"
$ evince deps.pdf

By default, module-graph drops direct links between modules if these links are implied by transitive dependencies. You can keep them with -A/–all-links:

$ module-graph --all-links
Generated 32 edges in "deps.dot" and "deps.pdf"
$ evince deps.pdf

If modules are packed/wrapped within a module (default behavior for dune), you may use the -R/--remove-pack MODNAME to filter modules (keeping only the ones within the pack) and remove the corresponding prefix:

$ module-graph --remove-pack AltErgoLib
Generated 19 edges in "deps.dot" and "deps.pdf"
$ evince deps.pdf

You can display the filenames in the grap instead of the module names using the --filenames option:

$ module-graph --filenames
Generated 23 edges in "deps.dot" and "deps.pdf"
$ evince deps.pdf

You can filter out modules using a regexp with -X/--ignore-module REGEXP where regexp is in the glob format:

$ module-graph -X 'AltErgoLib__*'
Generated 3 edges in "deps.dot" and "deps.pdf"
$ evince deps.pdf

Examples

  • Raw Dependencies for module-graph:

module-graph-deps

  • All Dependencies for module-graph (--all-links):

module-graph-deps-all

  • Raw Dependencies for alt-ergo:

alt-ergo-deps

  • Dependencies restricted to AltErgoLib for alt-ergo (--remove-pack AltErgoLib):

alt-ergo-deps-pack