Skip to content

Commit 06c2000

Browse files
author
Geoffrey Broadwell
committed
Generate type graph visualizations as SVG files (and .gitignore the new html/svg/ directory)
1 parent 11bb98c commit 06c2000

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ html/*.html
55
html/routine/
66
html/type/
77
html/language/
8+
html/svg/

htmlify.pl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use URI::Escape;
99
use lib 'lib';
1010
use Perl6::TypeGraph;
11+
use Perl6::TypeGraph::Viz;
1112

1213
sub url-munge($_) {
1314
return $_ if m{^ <[a..z]>+ '://'};
@@ -18,6 +19,7 @@
1819

1920
my $*DEBUG = False;
2021

22+
my $tg;
2123
my %names;
2224
my %types;
2325
my %routines;
@@ -63,7 +65,7 @@
6365

6466
sub MAIN($out_dir = 'html', Bool :$debug) {
6567
$*DEBUG = $debug;
66-
for ('', <type language routine>) {
68+
for ('', <type language routine svg>) {
6769
mkdir "$out_dir/$_" unless "$out_dir/$_".IO ~~ :e;
6870
}
6971

@@ -73,7 +75,7 @@ ($out_dir = 'html', Bool :$debug)
7375
say '... done';
7476

7577
say "Reading type graph ...";
76-
my $tg = Perl6::TypeGraph.new-from-file('type-graph.txt');
78+
$tg = Perl6::TypeGraph.new-from-file('type-graph.txt');
7779
{
7880
my %h = $tg.sorted.kv.flat.reverse;
7981
@source.=sort: { %h{.key} // -1 };
@@ -155,6 +157,8 @@ ($out_dir = 'html', Bool :$debug)
155157
}
156158
spurt "$out_dir/$what/$podname.html", pod2html($pod, :url(&url-munge), :$footer);
157159
}
160+
161+
write-type-graph-images(:$out_dir);
158162
write-search-file(:$out_dir);
159163
write-index-file(:$out_dir);
160164
say "Writing per-routine files...";
@@ -228,6 +232,14 @@ ($out_dir = 'html', Bool :$debug)
228232
);
229233
}
230234

235+
sub write-type-graph-images(:$out_dir!) {
236+
say "Writing type graph images to $out_dir/svg/";
237+
for $tg.sorted -> $type {
238+
my $viz = Perl6::TypeGraph::Viz.new-for-type($type);
239+
$viz.to-svg-file("$out_dir/svg/type-graph-{$type}.svg");
240+
}
241+
}
242+
231243
sub write-search-file(:$out_dir!) {
232244
say "Writing $out_dir/search.html";
233245
my $template = slurp("search_template.html");

0 commit comments

Comments
 (0)