Skip to content

Commit d116737

Browse files
committed
Type graphs: eliminate prose, add links to SVG (daxim++)
Closes #283
1 parent c60a60c commit d116737

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

htmlify.p6

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,14 @@ multi write-type-source($doc) {
288288
}
289289

290290
if $type {
291-
my $tg-preamble = qq[<h1>Type graph</h1>\n<p>Below you should see a
292-
clickable image showing the type relations for $podname that links
293-
to the documentation pages for the related types. If not, try the
294-
<a href="/images/type-graph-{href_escape $podname}.png">PNG
295-
version</a> instead.</p>];
291+
my $graph-contents = slurp 'template/type-graph.html';
292+
$graph-contents .= subst('ESCAPEDPODNAME', uri_escape($podname), :g);
293+
$graph-contents .= subst('PODNAME', $podname);
294+
$graph-contents .= subst('INLINESVG', svg-for-file("html/images/type-graph-$podname.svg"));
295+
296296
$pod.contents.append: Pod::Raw.new(
297297
target => 'html',
298-
contents => $tg-preamble ~ svg-for-file("html/images/type-graph-$podname.svg"),
299-
298+
contents => $graph-contents,
300299
);
301300

302301
my @mro = $type.mro;

template/type-graph.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<h1>Type graph</h1>
2+
<figure>
3+
<figcaption>Type relations for <code>PODNAME</code></figcaption>
4+
INLINESVG
5+
<p class="fallback">
6+
Stand-alone image:
7+
<a rel="alternate" href="/images/type-graph-ESCAPEDPODNAME.svg" type="image/svg+xml">vector</a>,
8+
<a rel="alternate" href="/images/type-graph-ESCAPEDPODNAME.png" type="image/png">raster</a>
9+
</p>
10+
</figure>

0 commit comments

Comments
 (0)