ShigekiKarita/d-graphviz


Graphviz utility for D

License: BSL-1.0

Language: D


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

Project Statistics

Sourcerank 4
Repository Size 249 KB
Stars 9
Forks 4
Watchers 3
Open issues 0
Dependencies 0
Contributors 2
Tags 3
Created
Last updated
Last pushed

Top Contributors See all

Shigeki Karita Dennis

Packages Referencing this Repo

d-graphviz
Graphviz utility for D
Latest release 0.0.3 - Updated - 9 stars

Recent Tags See all

v0.0.3 September 27, 2019
v0.0.2 September 26, 2019
v0.0.1 February 11, 2018

Something wrong with this page? Make a suggestion

Last synced: 2019-09-28 01:03:03 UTC

Login to resync this repository