Skip to content

Commit 82966bc

Browse files
committed
Render Enums differently in type graphs
This should resolve #72. The ticket says to “render enum types differently from classes”, but does not specify how exactly. This commit makes enums green. I am sure that there are better (and prettier) ways to do it, but the graph generation code is already unnecessarily convoluted, so perhaps we need a rewrite that will take care of all these tiny issues?
1 parent 689cc94 commit 82966bc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/Perl6/TypeGraph/Viz.pm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Perl6::TypeGraph::Viz {
77
has $.url-base = '/type/';
88
has $.rank-dir = 'BT';
99
has $.role-color = '#6666FF';
10+
has $.enum-color = '#33BB33';
1011
has $.class-color = '#000000';
1112
has $.node-soft-limit = 20;
1213
has $.node-hard-limit = 50;
@@ -64,7 +65,11 @@ class Perl6::TypeGraph::Viz {
6465

6566
@dot.append: "\n // Types\n";
6667
for @.types -> $type {
67-
my $color = $type.packagetype eq 'role' ?? $.role-color !! $.class-color;
68+
my $color = do given $type.packagetype {
69+
when role { $.role-color }
70+
when enum { $.enum-color }
71+
default { $.class-color }
72+
}
6873
@dot.append: " \"$type.name()\" [color=\"$color\", fontcolor=\"$color\", href=\"{$.url-base ~ $type.name }\", fontname=\"FreeSans\"];\n";
6974
}
7075

0 commit comments

Comments
 (0)