Generates a dependency hierarchy graph for Leiningen projects.
Clojure
Switch branches/tags
Latest commit f6fcf6f Feb 8, 2016 @greglook Bump to SNAPSHOT version.
Permalink
Failed to load latest commit information.
doc
src/leiningen
.gitignore
README.md
UNLICENSE
project.clj

README.md

lein-hiera

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 plugin is inspired by lein-ns-dep-graph, but has many additional options for graph generation.

Installation

Plugin releases are published on Clojars. To use the latest verison with Leiningen, add the following to your project definition or user profile plugins:

Clojars Project

You'll also need Graphviz installed, in order to generate the graph images. Check your local package manager:

# Debian/Ubuntu:
$ sudo apt-get install graphviz

# OS X:
$ brew install graphviz

Usage

A namespace graph can be generated by running:

$ lein hiera

This will generate a dependency graph in target/ns-hierarchy.png, showing the interdependency of the project's source namespaces. By default, all directories in the project's :source-paths are included. Additional directories to include may be given as command-line arguments:

$ lein hiera ../foo-lib/src ../bar-lib/src

Example

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.

Example dependency hierarchy

Options

Graph generation may be controlled with additional options under the :hiera key in the project map. The available options, and their default values are:

:hiera
{:path "target/ns-hierarchy.png"
 :vertical true
 :show-external false
 :cluster-depth 0
 :trim-ns-prefix true
 :ignore-ns #{}}
name description
:path Gives the location to output the graph image to.
:vertical Specifies whether to lay out the graph vertically or horizontally.
show-external When set, the graph will include nodes for namespaces which are not defined in the source files, marked by a dashed border.
:cluster-depth Sets the number of namespace segments to cluster nodes by. Clusters must contain at least one fewer segment than the nodes themselves.
:trim-ns-prefix When set, clustered namespaces will have the cluster prefix removed from the node labels.
:ignore-ns A set of namespace prefixes to exclude from the graph. For example, #{clojure} would exclude clojure.string, clojure.java.io, etc.

License

This is free and unencumbered software released into the public domain. See the UNLICENSE file for more information.