Skip to content

Commit 4a477cb

Browse files
committed
Get operators-as-routines to work
1 parent 8569817 commit 4a477cb

File tree

1 file changed

+13
-57
lines changed

1 file changed

+13
-57
lines changed

htmlify.p6

Lines changed: 13 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ sub MAIN(Bool :$debug, Bool :$typegraph = False) {
179179
$dr.compose;
180180

181181
write-disambiguation-files($dr);
182-
write-op-disambiguation-files($dr);
183182
write-type-graph-images(:force($typegraph));
184183
write-search-file($dr);
185184
write-index-files($dr);
@@ -198,6 +197,16 @@ sub MAIN(Bool :$debug, Bool :$typegraph = False) {
198197

199198
sub write-language-file(:$dr, :$what, :$pod, :$podname) {
200199
spurt "html/$what/$podname.html", p2h($pod, $what);
200+
my $name = $pod.content[0].name eq "TITLE"
201+
?? $pod.content[0].content[0].content[0]
202+
!! $podname;
203+
my $d = $dr.add-new(
204+
:kind<language>,
205+
:name($name),
206+
:url("/language/$podname"),
207+
:$pod,
208+
:pod-is-complete,
209+
);
201210
if $podname eq 'operators' {
202211
my @chunks = chunks-grep($pod.content,
203212
:from({ $_ ~~ Pod::Heading and .level == 2}),
@@ -213,20 +222,11 @@ sub write-language-file(:$dr, :$what, :$pod, :$podname) {
213222
:subkinds($what),
214223
:name($operator),
215224
:pod($chunk),
225+
:origin($d)
216226
:!pod-is-complete,
217227
);
218228
}
219229
}
220-
my $name = $pod.content[0].name eq "TITLE"
221-
?? $pod.content[0].content[0].content[0]
222-
!! $podname;
223-
$dr.add-new(
224-
:kind<language>,
225-
:name($name),
226-
:url("/language/$podname"),
227-
:$pod,
228-
:pod-is-complete,
229-
);
230230
}
231231

232232
sub write-type-file(:$dr, :$what, :$pod, :$podname) {
@@ -570,50 +570,6 @@ sub write-disambiguation-files($dr) {
570570
say '';
571571
}
572572

573-
sub write-op-disambiguation-files($dr) {
574-
say 'Writing operator disambiguation files ...';
575-
for $dr.lookup('operator', :by<kind>).classify(*.name).kv -> $name, @ops {
576-
next unless %operator_disambiguation_file_written{$name};
577-
my $pod = pod-with-title("Disambiguation for '$name'");
578-
if @ops == 1 {
579-
my $p = @ops[0];
580-
if $p.origin -> $o {
581-
$pod.content.push:
582-
pod-block(
583-
pod-link("'$name' is a $p.human-kind()", $p.url),
584-
' from ',
585-
pod-link($o.human-kind() ~ ' ' ~ $o.name, $o.url),
586-
);
587-
}
588-
else {
589-
$pod.content.push:
590-
pod-block(
591-
pod-link("'$name' is a $p.human-kind()", $p.url)
592-
);
593-
}
594-
}
595-
else {
596-
$pod.content.push:
597-
pod-block("'$name' can be anything of the following"),
598-
@ops.map({
599-
if .origin -> $o {
600-
pod-item(
601-
pod-link(.human-kind, .url),
602-
' from ',
603-
pod-link($o.human-kind() ~ ' ' ~ $o.name, $o.url),
604-
)
605-
}
606-
else {
607-
pod-item( pod-link(.human-kind, .url) )
608-
}
609-
});
610-
}
611-
my $html = p2h($pod, 'routine');
612-
spurt "html/$name.html", $html;
613-
}
614-
615-
}
616-
617573
sub write-index-files($dr) {
618574
# XXX: Main index file can't be generated properly until
619575
# it is turned into a Pod file. For now, it's just static.
@@ -654,7 +610,7 @@ sub write-index-files($dr) {
654610
.grep({$subkind .subkinds})\ # XXX
655611
.categorize(*.name).sort(*.key)>>.value\
656612
.map({
657-
[set(.map: {.subkinds // Nil}).list.join(', '), pod-link(.name, .url), .summary]
613+
[set(.map: {.subkinds // Nil}).list.join(', '), pod-link(.[0].name, .[0].url), .[0].summary]
658614
})
659615
)
660616
), $kind);
@@ -676,7 +632,7 @@ sub write-routine-file($dr, $name) {
676632
pod-block("Documentation for $subkind $name, assembled from the
677633
following types:"),
678634
@docs.map({
679-
pod-heading(.origin.name ~ '.' ~ .name), # TODO: better way to get link to origin
635+
pod-heading("{.name} in {.origin.name}"), # TODO: better way to get link to origin
680636
pod-block("From ", pod-link(.origin.name, .origin.url ~ '#' ~ (.subkinds ~~ /fix/ ?? .subkinds~'_' !! '') ~ .name)),
681637
.pod.list,
682638
})

0 commit comments

Comments
 (0)