8
8
use URI::Escape;
9
9
use lib ' lib' ;
10
10
use Perl6::TypeGraph;
11
+ use Perl6::TypeGraph::Viz;
11
12
12
13
sub url-munge ($ _ ) {
13
14
return $ _ if m {^ <[ a..z ] >+ '://' };
18
19
19
20
my $ * DEBUG = False ;
20
21
22
+ my $ tg ;
21
23
my % names ;
22
24
my % types ;
23
25
my % routines ;
63
65
64
66
sub MAIN ($ out_dir = ' html' , Bool : $ debug ) {
65
67
$ * DEBUG = $ debug ;
66
- for (' ' , <type language routine >) {
68
+ for (' ' , <type language routine svg >) {
67
69
mkdir " $ out_dir /$ _" unless " $ out_dir /$ _" . IO ~~ : e;
68
70
}
69
71
@@ -73,7 +75,7 @@ ($out_dir = 'html', Bool :$debug)
73
75
say ' ... done' ;
74
76
75
77
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' );
77
79
{
78
80
my % h = $ tg . sorted. kv . flat . reverse ;
79
81
@ source .= sort : { % h {. key } // -1 };
@@ -155,6 +157,8 @@ ($out_dir = 'html', Bool :$debug)
155
157
}
156
158
spurt " $ out_dir /$ what /$ podname .html" , pod2html($ pod , : url(& url-munge ), : $ footer );
157
159
}
160
+
161
+ write-type-graph-images(: $ out_dir );
158
162
write-search-file(: $ out_dir );
159
163
write-index-file(: $ out_dir );
160
164
say " Writing per-routine files..." ;
@@ -228,6 +232,14 @@ ($out_dir = 'html', Bool :$debug)
228
232
);
229
233
}
230
234
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
+
231
243
sub write-search-file (: $ out_dir ! ) {
232
244
say " Writing $ out_dir /search.html" ;
233
245
my $ template = slurp (" search_template.html" );
0 commit comments