Skip to content

Commit 804072a

Browse files
author
Geoffrey Broadwell
committed
Write specialized visualizations for Any, Exception, and the Metamodel
1 parent c837ee8 commit 804072a

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

htmlify.pl

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,58 @@ (Bool :$debug)
239239
$viz.to-file("html/images/type-graph-{$type}.svg", format => 'svg');
240240
$viz.to-file("html/images/type-graph-{$type}.png", format => 'png');
241241
}
242+
243+
say "Writing specialized visualizations to html/images/";
244+
my %by-group = $tg.sorted.classify(&viz-group);
245+
%by-group<Exception>.push: $tg.types< Exception Any Mu >;
246+
%by-group<Metamodel>.push: $tg.types< Any Mu >;
247+
248+
for %by-group.kv -> $group, @types {
249+
my $viz = Perl6::TypeGraph::Viz.new(:types(@types),
250+
:dot-hints(viz-hints($group)),
251+
:rank-dir('LR'));
252+
$viz.to-file("html/images/type-graph-{$group}.svg", format => 'svg');
253+
$viz.to-file("html/images/type-graph-{$group}.png", format => 'png');
254+
}
255+
}
256+
257+
sub viz-group ($type) {
258+
return 'Metamodel' if $type.name ~~ /^ 'Perl6::Metamodel' /;
259+
return 'Exception' if $type.name ~~ /^ 'X::' /;
260+
return 'Any';
261+
}
262+
263+
sub viz-hints ($group) {
264+
return '' unless $group eq 'Any';
265+
266+
return '
267+
subgraph "cluster: Mu children" {
268+
rank=same;
269+
style=invis;
270+
"Any";
271+
"Junction";
272+
}
273+
subgraph "cluster: Pod:: top level" {
274+
rank=same;
275+
style=invis;
276+
"Pod::Config";
277+
"Pod::Block";
278+
}
279+
subgraph "cluster: Date/time handling" {
280+
rank=same;
281+
style=invis;
282+
"Date";
283+
"DateTime";
284+
"DateTime-local-timezone";
285+
}
286+
subgraph "cluster: Collection roles" {
287+
rank=same;
288+
style=invis;
289+
"Positional";
290+
"Associative";
291+
"Baggy";
292+
}
293+
';
242294
}
243295

244296
sub write-search-file() {

0 commit comments

Comments
 (0)