Skip to content

Commit

Permalink
Fix search indexer
Browse files Browse the repository at this point in the history
Fixes #1894 D#1894
Fixes #1959 D#1959
Fixes #1936 D#1936
Fixes #1922 D#1922
Fixes #1893 D#1893
Fixes #1809 D#1809
Fixes #1743 D#1743

Don't hide exceptions behind Promise.alloff and let them
explode instead. Don't assume all X<> contain text only
and instead render them into plain text when entering them
into documentable object (containing codes like C<> still
appear to render fine as <code> on the page, but using
plain text in documentables lets us avoid having <code>
tags appear in the search results and the search box.
  • Loading branch information
zoffixznet committed Apr 27, 2018
1 parent da36e4f commit d3db402
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
4 changes: 2 additions & 2 deletions assets/sass/style.scss
Expand Up @@ -78,7 +78,7 @@ table.pod-table tr:nth-child(odd) {
background-color: rgba(0, 0, 0, 0.031373);
}
table.pod-table tr:nth-child(even) {
background-color: none;
background-color: transparent;
}

td, th {
Expand All @@ -91,7 +91,7 @@ td, th {

.pretty-box {
border: 0.2em solid;
background-style: solid;
border-style: solid;
border-radius: 1em;
box-shadow: 0.5em 0.5em 1em #888888;
padding: 2em;
Expand Down
8 changes: 4 additions & 4 deletions doc/Language/operators.pod6
Expand Up @@ -133,7 +133,7 @@ performs I<in-place> (i.e., I<destructive> behaviour;
and an uppercase form (e.g., C<S///>) that provides a I<non-destructive>
behavior.
=head2 C<s///> in-place substitution
=head2 X«C<s///> in-place substitution»
my $str = 'old string';
$str ~~ s/o .+ d/new/;
Expand Down Expand Up @@ -175,7 +175,7 @@ Non-paired characters can simply replace the original slashes. Paired
characters, like braces, are used only on the match portion, with the
substitution given by assignment (of anything: a string, a routine call, etc.).
=head2 C<S///> non-destructive substitution
=head2 X«C<S///> non-destructive substitution»
say S/o .+ d/new/ with 'old string'; # OUTPUT: «new string␤»
S:g/« (.)/$0.uc()/.say for <foo bar ber>; # OUTPUT: «Foo␤Bar␤Ber␤»
Expand All @@ -191,7 +191,7 @@ warning. To execute the substitution on a variable that isn't the C<$_> this
operator uses, alias it to C<$_> with C<given>, C<with>, or any other way.
Alternatively, use the L«C<.subst> method|/routine/subst».
=head2 C<tr///> in-place transliteration
=head2 X«C<tr///> in-place transliteration»
my $str = 'old string';
$str ~~ tr/dol/wne/;
Expand All @@ -209,7 +209,7 @@ that measures the distance between original value and the resultant string.
$str ~~ tr:c:d/dol st//;
say $str; # OUTPUT: «ring␤»
=head2 C<TR///> non-destructive transliteration
=head2 X«C<TR///> non-destructive transliteration»
with 'old string' {
say TR/dol/wne/; # OUTPUT: «new string␤»
Expand Down
44 changes: 27 additions & 17 deletions htmlify.p6
Expand Up @@ -266,11 +266,11 @@ sub process-pod-dir($dir, :&sorted-by = &[cmp], :$sparse, :$parallel) {
}

if $num %% $parallel {
await Promise.allof: @pod-files;
await @pod-files;
@pod-files = ();
}

LAST await Promise.allof: @pod-files;
LAST await @pod-files;
}
}

Expand Down Expand Up @@ -450,12 +450,12 @@ sub register-reference(:$pod!, :$origin, :$url) {
for @( $pod.meta ) -> $meta {
my $name;
if $meta.elems > 1 {
my $last = $meta[*-1];
my $rest = $meta[0..*-2].join;
my $last = textify-guts $meta[*-1];
my $rest = $meta[0..*-2]».&textify-guts.join;
$name = "$last ($rest)";
}
else {
$name = $meta.Str;
$name = textify-guts $meta;
}
$*DR.add-new(
:$pod,
Expand All @@ -474,11 +474,19 @@ sub register-reference(:$pod!, :$origin, :$url) {
:$url,
:kind<reference>,
:subkinds['reference'],
:$name,
:name(textify-guts $name),
);
}
}

multi textify-guts (Any:U, ) { '' }
multi textify-guts (Str:D \v) { v }
multi textify-guts (List:D \v) { v».&textify-guts.Str }
multi textify-guts (Pod::Block \v) {
use Pod::To::Text;
pod2text v;
}

#| A one-pass-parser for pod headers that define something documentable.
sub find-definitions(:$pod, :$origin, :$min-level = -1, :$url) {
# Runs through the pod content, and looks for headings.
Expand Down Expand Up @@ -510,18 +518,20 @@ sub find-definitions(:$pod, :$origin, :$min-level = -1, :$url) {
when :(Pod::FormattingCode $) {
my $fc := .[0];
proceed unless $fc.type eq "X";
@definitions = $fc.meta[0].flat;
(@definitions = $fc.meta[0]:v.flat) ||= '';
# set default name if none provide so X<if|control> gets name 'if'
@definitions[1] = $fc.contents[0] if @definitions == 1;
@definitions[1] = textify-guts $fc.contents[0]
if @definitions == 1;
$unambiguous = True;
}
# XXX: Remove when extra "" have been purged
when :("", Pod::FormattingCode $, "") {
my $fc := .[1];
proceed unless $fc.type eq "X";
@definitions = $fc.meta[0].flat;
(@definitions = $fc.meta[0]:v.flat) ||= '';
# set default name if none provide so X<if|control> gets name 'if'
@definitions[1] = $fc.contents[0] if @definitions == 1;
@definitions[1] = textify-guts $fc.contents[0]
if @definitions == 1;
$unambiguous = True;
}
when :(Str $ where /^The \s \S+ \s \w+$/) {
Expand All @@ -538,15 +548,15 @@ sub find-definitions(:$pod, :$origin, :$min-level = -1, :$url) {
}
when :("The ", Pod::FormattingCode $, Str $ where /^\s (\w+)$/) {
# The C<Foo> infix
@definitions = .[2].words[0], .[1].contents[0];
@definitions = .[2].words[0], textify-guts .[1].contents[0];
}
when :(Str $ where /^(\w+) \s$/, Pod::FormattingCode $) {
# infix C<Foo>
@definitions = .[0].words[0], .[1].contents[0];
@definitions = .[0].words[0], textify-guts .[1].contents[0];
}
# XXX: Remove when extra "" have been purged
when :(Str $ where /^(\w+) \s$/, Pod::FormattingCode $, "") {
@definitions = .[0].words[0], .[1].contents[0];
@definitions = .[0].words[0], textify-guts .[1].contents[0];
}
default { next }
}
Expand Down Expand Up @@ -669,13 +679,13 @@ sub write-type-graph-images(:$force, :$parallel) {
my $viz = Perl6::TypeGraph::Viz.new-for-type($type);
@type-graph-images.push: $viz.to-file("html/images/type-graph-{$type}.svg", format => 'svg');
if @type-graph-images %% $parallel {
await Promise.allof: @type-graph-images;
await @type-graph-images;
@type-graph-images = ();
}

print '.';

LAST await Promise.allof: @type-graph-images;
LAST await @type-graph-images;
}
say '';

Expand All @@ -692,11 +702,11 @@ sub write-type-graph-images(:$force, :$parallel) {
:rank-dir('LR'));
@specialized-visualizations.push: $viz.to-file("html/images/type-graph-{$group}.svg", format => 'svg');
if @specialized-visualizations %% $parallel {
await Promise.allof: @specialized-visualizations;
await @specialized-visualizations;
@specialized-visualizations = ();
}

LAST await Promise.allof: @specialized-visualizations;
LAST await @specialized-visualizations;
}
}

Expand Down
2 changes: 1 addition & 1 deletion template/search_template.js
Expand Up @@ -169,7 +169,7 @@ $.extend( $.ui.autocomplete, {
current_search = term.toLowerCase();

var search_method = false;
if (term.startsWith(".")) {
if (term.match(/^\s*\.[a-zA-Z][a-zA-Z0-9_-]+\s*$/)) {
search_method = true;
term = term.substr(1);
}
Expand Down

0 comments on commit d3db402

Please sign in to comment.