Skip to content

Commit 0945572

Browse files
committed
remove %types. Switch search to the type registry instead
1 parent 43ee365 commit 0945572

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

htmlify.pl

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
my $*DEBUG = False;
2222

2323
my $tg;
24-
my %types;
2524
my %methods-by-type;
2625
my $footer = footer-html;
2726

@@ -93,7 +92,6 @@ (Bool :$debug, Bool :$typegraph = False)
9392
my $file = .value;
9493
my $what = $podname ~~ /^<[A..Z]> | '::'/ ?? 'type' !! 'language';
9594
say "$file.path() => $what/$podname";
96-
%types{$what}{$podname} = "/$what/$podname";
9795
my $pod = eval slurp($file.path) ~ "\n\$=pod";
9896
$pod.=[0];
9997
if $what eq 'language' {
@@ -197,7 +195,6 @@ (Bool :$debug, Bool :$typegraph = False)
197195
say "$podname.$name" if $*DEBUG;
198196
next if $name ~~ /\s/;
199197
%methods-by-type{$podname}.push: $chunk;
200-
%types<routine>{$name} = "/routine/" ~ uri_escape( $name );
201198
$dr.add-new(
202199
:kind<routine>,
203200
# TODO: determine subkind, ie method/sub
@@ -215,7 +212,7 @@ (Bool :$debug, Bool :$typegraph = False)
215212
write-disambiguation-files($dr);
216213
write-operator-files($dr);
217214
write-type-graph-images(:force($typegraph));
218-
write-search-file();
215+
write-search-file($dr);
219216
write-index-file($dr);
220217
say "Writing per-routine files";
221218
for $dr.lookup('routine', :by<kind>).list -> $d {
@@ -360,19 +357,20 @@ (Bool :$debug, Bool :$typegraph = False)
360357
';
361358
}
362359

363-
sub write-search-file() {
360+
sub write-search-file($dr) {
364361
say "Writing html/search.html";
365362
my $template = slurp("search_template.html");
366363
my @items;
367364
my sub fix-url ($raw) { $raw.substr(1) ~ '.html' };
368-
@items.push: %types<language>.pairs.sort.map({
369-
"\{ label: \"Language: {.key}\", value: \"{.key}\", url: \"{ fix-url(.value) }\" \}"
365+
@items.push: $dr.lookup('language', :by<kind>).sort(*.name).map({
366+
"\{ label: \"Language: {.name}\", value: \"{.name}\", url: \"{ fix-url(.url) }\" \}"
370367
});
371-
@items.push: %types<type>.sort.map({
372-
"\{ label: \"Type: {.key}\", value: \"{.key}\", url: \"{ fix-url(.value) }\" \}"
368+
@items.push: $dr.lookup('type', :by<kind>).sort(*.name).map({
369+
"\{ label: \"Type: {.name}\", value: \"{.name}\", url: \"{ fix-url(.url) }\" \}"
373370
});
374-
@items.push: %types<routine>.sort.map({
375-
"\{ label: \"Routine: {.key}\", value: \"{.key}\", url: \"{ fix-url(.value) }\" \}"
371+
my %seen;
372+
@items.push: $dr.lookup('routine', :by<kind>).grep({!%seen{.name}++}).sort(*.name).map({
373+
"\{ label: \"Routine: {.name}\", value: \"{.name}\", url: \"{ fix-url(.url) }\" \}"
376374
});
377375

378376
my $items = @items.join(",\n");

0 commit comments

Comments
 (0)