Skip to content
This repository has been archived by the owner on Oct 25, 2020. It is now read-only.
/ elisp-depmap.el Public archive

Writes out a graphviz map based on project functions

License

Notifications You must be signed in to change notification settings

mtekman/elisp-depmap.el

Repository files navigation

elisp-depmap.el

This repo has migrated to GitLab

https://gitlab.com/mtekman/elisp-depmap.el

(The copy here is archived. Please see the above link for the latest developments)

A library to generate a dependency map for elisp projects.

Generates a GraphViz-compatible DOT file representation of all the top-level definitions in an elisp project, and represents the connections between them.

The idea is that your code should be structured in an untangled way (i.e. split into standalone libraries contained within specific files), and the graphviz diagram generated by this package should help you know whether you need to refactor your project.

Installation

(use-package elisp-depmap
  :bind (("C-c M-d" . elisp-depmap-graphviz-digraph)
         ("C-c M-g" . elisp-depmap-graphviz)
         ("C-c M-s" . elisp-depmap-makesummarytable))
  :config ((elisp-depmap-exec-file "~/graphviz2.dot")))

Usage

Within an elisp package directory, run either

  1. elisp-depmap-graphviz

    Generates an undirected graph. Useful if the project contains only one file. Each node is a function coloured by file, and shaped by variable or function type (e.g. setq, defvar, defcustom, defun, defsubst, defmacro). Each edge indicates that a function is linked to another. Border width indicates the size of the function.

  2. elisp-depmap-graphviz-digraph

    Generates a directed graph with clustered subgraphs (as in the above image). Useful if the project contains multiple files, where functions from the same file are contained under the same subgraph, and an arrow from a source node/function to a target node/function indicates that the source node was called by the target.

  3. elisp-depmap-makesummarytable

    Generates a summary table of functions, variables and files - including the number of lines of a function and number of references.

Customization

Variable (prefix: elisp-depmap)TypeDefaultGroupInfo
parse-hashtablesizeinteger50ParsingSize of hashtable storing variables/functions. Increase for large projects with many definitions.
parse-function-shapesalist(see defn.)ParsingAlist of variable and function types and Graphviz Shapes. Supports elisp types and common-lisp types. Easily extendable.
secondhelp-regexreferencesstring(see defn.)ParsingRegular expression to catch references to top-level definitions.
graph-subclustergroupsplist(see defn.)StylingClasses of sub-subgraph clusters. A plist of :keyword '([types]) pairs, where the sub-subgraph is given the name of the keyword, and clusters group all declared types.
graph-indentwidthinteger4StylingSize of each indentation in spaces inside the DOT file. Does not affect resultant image.
graph-stripprojectnamebooleantStylingStrip away the file name from the prefix of the function.
graph-filecolorsymbolsalist(see defn.)StylingA list of (color . "prefix") pairs, where each entry will be used to color a file, and replace the file prefix with “prefix” if graph-stripprojectname is enabled.
graph-decorateplist(see defn.)StylingKeywords can be :edge, :node, :graph, :subgraph and :subsubgraph. Values are alists specifying Graphviz Attributes.
graph-linemodinteger10StylingLine scaling modifier. Higher reduces the border width.
exec-filestring~/graphviz2.dotCommandLocation of DOT file, Org (summary table) file, and Graphviz file.
exec-outextstringpngCommandOutput Graphviz file type.
exec-commandargsstring(empty)CommandExtra command line arguments for running DOT.

About

Writes out a graphviz map based on project functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published