Generates a graph of the dependency hierarchy of a set of clojure files. This uses the clojure.tools.namespace library for namespace parsing and Rhizome for graph generation using Graphviz.
This tool was originally inspired by lein-ns-dep-graph, but has many additional options for graph generation.
There are a few different ways to use clj-hiera. First, you'll need Graphviz installed in order to generate the images. Check your local package manager:
# Debian/Ubuntu:
sudo apt-get install graphviz
# OS X with Homebrew:
brew install graphviz
If you're using tools.deps
, you can use this by adding an alias to your
deps.edn
file:
:hiera
{:deps {io.github.greglook/clj-hiera {:git/tag "2.0.0", :git/sha "b14e514"}}
:exec-fn hiera.main/graph
:exec-args {,,,}}
To generate namespace graphs:
clj -X:hiera [opts]
Alternately, you can use this as a standalone Clojure tool:
clj -Ttools install-latest :lib io.github.greglook/clj-hiera :as hiera
Then, to invoke the tool in any Clojure project:
clj -Thiera graph [opts]
For Leiningen, you can use this via the lein-hiera
plugin. Add the following
to your project.clj
file or user-level profile:
[lein-hiera "2.0.0"]
Then you can run:
lein hiera [opts]
The available options, and their default values are:
name | default | description |
---|---|---|
:sources |
#{"src"} |
Set of directories containing source files to analyze. |
:output |
"target/hiera" |
Directory to write files to. |
:layout |
:vertical |
Whether to lay out the graph vertically or horizontally. |
:cluster-depth |
0 |
Number of namespace segments to cluster nodes by. |
:external |
false |
Show external namespaces as nodes in the graph. |
:ignore |
#{} |
A set of namespace prefixes or patterns to exclude from the graph. |
When using Leiningen, graph generation options may be provided under the
:hiera
key in the project map. You can also provide/override the
configuration options by specifying them on the command line with keyword
arguments:
lein hiera :cluster-depth 3 :layout :horizontal
This image shows the dependency hierarchy from a moderately complex project. The
namespaces are clustered by two levels, and it shows a dependency on the external
puget
library.
This is free and unencumbered software released into the public domain. See the UNLICENSE file for more information.