cargo-modules icon indicating copy to clipboard operation
cargo-modules copied to clipboard

Option to generate graph for structure/enum

Open Stargateur opened this issue 5 years ago • 1 comments

I would like to be able to generate a graph for a structure. I have a heavy numbers of structure for a parsing crate that contains each other a lot, and I would like to generate a visual graph of it. I know this is not the purpose of this repo but I search I didn't find anything.

So I wonder, if anyone know something that do it, or if that could be an additional feature of this crate.

Example:

struct A {
    b: B,
    c: C,
}

struct B {
    c: C,
}

struct C {
    foo: i32,
}

struct D {
    a: A,
    b: B,
}

will produce:

digraph {
  A [shape=record, label="{ struct A | { <b> b| <c> c } }"];
  B [shape=record, label="{ struct B | { <c> c } }"];
  C [shape=record, label="{ struct C | { <foo> foo } }"];
  D [shape=record, label="{ struct D | { <a> a | <b> b } }"];

  A:b -> B;
  A:c -> C;
  B:c -> C;
  C:foo -> i32;
  D:a -> A;
  D:b -> B;
}

and so will produce:

graph

Stargateur avatar Jul 03 '20 21:07 Stargateur

That sounds interesting! Could be out of scope for this crate though.

kvark avatar Jul 04 '20 15:07 kvark