Skip to content

Commit 7b7d42d

Browse files
committed
Merge pull request #408 from azawawi/master
Add 5to6-perlfunc functions to search index
2 parents 997e03d + a406f32 commit 7b7d42d

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ html/language/
99
html/syntax/
1010
html/images/type-graph*
1111
html/js/search.js
12+
.precomp

htmlify.p6

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use experimental :pack;
3535
my $type-graph;
3636
my %routines-by-type;
3737
my %*POD2HTML-CALLBACKS;
38+
my %p5to6-functions;
3839

3940
# TODO: Generate menulist automatically
4041
my @menu =
@@ -227,6 +228,11 @@ sub process-pod-source(:$kind, :$pod, :$filename, :$pod-is-complete) {
227228

228229
find-definitions :$pod, :$origin, :url("/$kind/$filename");
229230
find-references :$pod, :$origin, :url("/$kind/$filename");
231+
232+
# Special handling for 5to6-perlfunc
233+
if $filename eq '5to6-perlfunc' {
234+
find-p5to6-functions( :$pod, :$origin, :url("/$kind/$filename"))
235+
}
230236
}
231237

232238
# XXX: Generalize
@@ -320,6 +326,18 @@ sub find-references(:$pod!, :$url, :$origin) {
320326
}
321327
}
322328

329+
sub find-p5to6-functions(:$pod!, :$url, :$origin) {
330+
if $pod ~~ Pod::Item {
331+
my $func-name = ~$pod.contents[0].contents;
332+
%p5to6-functions{$func-name} = 1;
333+
}
334+
elsif $pod.?contents {
335+
for $pod.contents -> $sub-pod {
336+
find-p5to6-functions(:pod($sub-pod), :$url, :$origin) if $sub-pod ~~ Pod::Block;
337+
}
338+
}
339+
}
340+
323341
sub register-reference(:$pod!, :$origin, :$url) {
324342
if $pod.meta {
325343
for @( $pod.meta ) -> $meta {
@@ -602,15 +620,19 @@ sub write-search-file () {
602620
sub escape(Str $s) {
603621
$s.trans([</ \\ ">] => [<\\/ \\\\ \\">]);
604622
}
605-
my $items = $*DR.get-kinds.map(-> $kind {
623+
my @items = $*DR.get-kinds.map(-> $kind {
606624
$*DR.lookup($kind, :by<kind>).categorize({escape .name})\
607625
.pairs.sort({.key}).map: -> (:key($name), :value(@docs)) {
608626
qq[[\{ category: "{
609627
( @docs > 1 ?? $kind !! @docs.[0].subkinds[0] ).wordcase
610628
}", value: "$name", url: "{@docs.[0].url}" \}]] #"
611629
}
612-
}).flat.join(",\n");
613-
spurt("html/js/search.js", $template.subst("ITEMS", $items));
630+
}).flat;
631+
@items.append( %p5to6-functions.keys.map( {
632+
my $url = "/language/5to6-perlfunc.html#" ~ uri_escape($_);
633+
sprintf( q[[{ category: "5to6-perlfunc", value: "%s", url: "%s" }]], $_, $url);
634+
}) );
635+
spurt("html/js/search.js", $template.subst("ITEMS", @items.join(",\n") ));
614636
}
615637

616638
sub write-disambiguation-files () {

0 commit comments

Comments
 (0)