Giter VIP home page Giter VIP logo

graf's Introduction

Graf

Visualizes Elixir project codebase as a Hierarchichal Edge Bundling graph.

Utilizes Mike Bostock's example implemented in D3.

Quick start

git clone https://github.com/elixir-ecto/ecto.git /tmp/ecto

docker run --rm -v /tmp/ecto:/project \
    -e MAX_DEPS_DEPTH=1 \
    -e BUILTIN=false \
    -e SHORTEN_MODULE_NAMES=false \
    -e COLOR=lightsteelblue \
    studzien/graf:latest /project \
    > ecto.svg

After it finishes, ecto.svg should look similar to this:

Hierarchichal Edge Bundling graph for Ecto

Running

./priv/generate.sh is an entrypoint to the script. It takes Elixir projects directories as arguments and outputs a SVG with Hierarchichal Edge Bundling graph representing structure of these projects.

Generation has two phases:

  1. An Elixir script (priv/graf.exs) first generates JSON with relationships between modules from provided projects and for given options;
  2. A Node.js script (priv/heb/index.js) then generates a SVG from the JSON.

You can run this script locally, and not in the Docker container, but make sure you have Node available and run make setup first, that will install all JS dependencies.

Configuration

All configuration of the generation script is currently done via environmental variables.

The available variables are:

  • MAX_DEPS_DEPTH (default: 0) - how deep the generator should look into the dependencies when generating graph?
  • BUILTIN (default: false) - should built-in modules (like Enum or erlang) be considered when generating the graph?
  • SHORTEN_MODULE_NAMES (default: true) - should the module name on the graph be shortened to the last part? (i.e. Graph instead of Graf.Graph)
  • COLOR (default: #ccc) - the color of edges on the graph

Troubleshooting

Since the generator relies on running mix in your project to gather information like compile paths and checks whether it's an umbrella project, it might not work properly if there is some output in the mix run output, like logs.

A workaround for this is increasing log level or turning logging off for the time of graph generation.

If a graph can't be generated for your project or seems to be incorrect please create an issue describing the problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.