Skip to content

Commit db1a7dd

Browse files
committed
Merge remote branch 'origin/generate-svg'
2 parents 5f4d151 + 584bf60 commit db1a7dd

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-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");

lib/AST.pod

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=begin pod
2+
3+
class AST { }
4+
5+
An C<AST> or I<Abstract Syntax Tree> is a partially processed representation
6+
of a program. ASTs are return values of the C<quasi> quoting construct,
7+
and are typically used withing macros to generate code that is inserted
8+
in the calling location of the macro.
9+
10+
There is no API defined for ASTs yet. Hopefully that will emerge as
11+
part of the work on macros.
12+
13+
=end pod

0 commit comments

Comments
 (0)