Skip to content

Commit

Permalink
Add 5to6-perlfunc functions to index under a hidden category. This fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
azawawi committed Mar 4, 2016
1 parent 997e03d commit 475a78a
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions htmlify.p6
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use experimental :pack;
my $type-graph;
my %routines-by-type;
my %*POD2HTML-CALLBACKS;
my %p5to6-functions;

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

find-definitions :$pod, :$origin, :url("/$kind/$filename");
find-references :$pod, :$origin, :url("/$kind/$filename");

# Special handling for 5to6-perlfunc
if $filename eq '5to6-perlfunc' {
find-p5to6-functions( :$pod, :$origin, :url("/$kind/$filename"))
}
}

# XXX: Generalize
Expand Down Expand Up @@ -320,6 +326,18 @@ sub find-references(:$pod!, :$url, :$origin) {
}
}

sub find-p5to6-functions(:$pod!, :$url, :$origin) {
if $pod ~~ Pod::Item {
my $func-name = ~$pod.contents[0].contents;
%p5to6-functions{$func-name} = 1;
}
elsif $pod.?contents {
for $pod.contents -> $sub-pod {
find-p5to6-functions(:pod($sub-pod), :$url, :$origin) if $sub-pod ~~ Pod::Block;
}
}
}

sub register-reference(:$pod!, :$origin, :$url) {
if $pod.meta {
for @( $pod.meta ) -> $meta {
Expand Down Expand Up @@ -602,15 +620,19 @@ sub write-search-file () {
sub escape(Str $s) {
$s.trans([</ \\ ">] => [<\\/ \\\\ \\">]);
}
my $items = $*DR.get-kinds.map(-> $kind {
my @items = $*DR.get-kinds.map(-> $kind {
$*DR.lookup($kind, :by<kind>).categorize({escape .name})\
.pairs.sort({.key}).map: -> (:key($name), :value(@docs)) {
qq[[\{ category: "{
( @docs > 1 ?? $kind !! @docs.[0].subkinds[0] ).wordcase
}", value: "$name", url: "{@docs.[0].url}" \}]] #"
}
}).flat.join(",\n");
spurt("html/js/search.js", $template.subst("ITEMS", $items));
}).flat;
@items.append( %p5to6-functions.keys.map( {
my $url = "/language/5to6-perlfunc.html#" ~ uri_escape($_);
sprintf( q[[{ category: "5to6-perlfunc", value: "%s", url: "%s" }]], $_, $url);
}) );
spurt("html/js/search.js", $template.subst("ITEMS", @items.join(",\n") ));
}

sub write-disambiguation-files () {
Expand Down

0 comments on commit 475a78a

Please sign in to comment.