d-graphviz 0.0.3

Graphviz utility for D


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

d-graphviz

Build Status codecov Dub version

Graphviz utility for D

dot

created by

import std.stdio;
import std.format;

import dgraphviz;

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

void main()
{
    auto g = new 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;
import dgraphviz;

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.3 2019-Sep-27
0.0.2 2019-Sep-26
0.0.1 2018-Feb-11
~master 2019-Sep-27
Show all 4 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 1 downloads this month

  • 395 downloads total

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