d-graphviz 0.0.1

Graphviz utility for D


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

d-graphviz

Graphviz utility for D

dot

created by

import std.stdio;
import std.format;

static import dot;

struct A {
    auto toString() {
        return "A\n\"struct\"";
    }
}

void main()
{
    auto g = new dot.Directed;
    A a;
    with (g) {
        node(a, ["shape": "box", "color": "#ff0000"]);
        edge(a, true);
        edge(a, 1, ["style": "dashed", "label": "a-to-1"]);
        edge(true, "foo");
    }
    g.save("simple.dot");
}

and $ dot simple.dot -Tpng -O

practical example

library dependency graph

import std.path;
import std.process;

void main() {
    // set phobos root
    auto dc = environment.get("DC");
    assert(dc != "", "use DUB or set $DC enviroment variable");
    auto which = executeShell("which " ~ dc);
    assert(which.status == 0);
    version(DigitalMars) {
        auto root = which.output.dirName ~ "/../../src/phobos/";
    }
    version(LDC) {
        auto root = which.output.dirName ~ "/../import/";
    }

    // plot std.range dependency graph
    auto g = libraryDependency(root, "std/range", true);
    g.save("range.dot");
}

result $ dot range.dot -Tpng -O

range

TODO

  • use set ops to remove duplicated nodes and edges
  • do string sanity check
  • support subgraph
Authors:
  • Shigeki Karita
Dependencies:
none
Versions:
0.0.1 2018-Feb-11
~master 2018-Feb-11
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 15 downloads total

Score:
0.6
Short URL:
d-graphviz.dub.pm