Skip to content

Commit f4353ee

Browse files
committed
Generalize definition detection
Now allows more generalized forms. In the future, should also look for X<infix,foo> or some such in the header.
1 parent ed0ba4d commit f4353ee

File tree

3 files changed

+134
-111
lines changed

3 files changed

+134
-111
lines changed

htmlify.p6

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,31 @@ sub find-definitions (:$pod, :$origin, :$dr, :$min-level = -1) {
297297
# Is this new header a definition?
298298
# If so, begin processing it.
299299
# If not, skip to the next heading.
300-
$i = $i + 1 and next unless $c.contents[0].contents[0] ~~ Str
301-
and 2 == my @words = $c.contents[0].contents[0].words;
300+
my $header := $c.contents[0].contents;
301+
my @words;
302+
given $header {
303+
when :(Str $ where /^(\w+) \s (\S+)$/) {
304+
# Infix Foo
305+
@words = ~$0, ~$1;
306+
}
307+
when :(Str $ where /^The \s (\S+) \s (\w+)$/) {
308+
# The Foo Infix
309+
@words = ~$1, ~$0;
310+
}
311+
when :(Str $ where /^(\w+) \s$/, Pod::FormattingCode $, "") {
312+
# infix C<Foo>
313+
@words = ~$0, $header[1].contents[0];
314+
}
315+
when :("The ", Pod::FormattingCode $, Str $ where /^\s (\w+)$/) {
316+
# The C<Foo> infix
317+
@words = ~$0, $header[1].contents[0];
318+
}
319+
default { .perl.say; $i = $i + 1; next }
320+
}
302321

303322
my ($subkinds, $name) = @words;
304323
my %attr;
305-
given $subkinds {
324+
given $subkinds.lc {
306325
when / ^ [in | pre | post | circum | postcircum ] fix | listop / {
307326
%attr = :kind<routine>,
308327
:categories<operator>,
@@ -315,6 +334,10 @@ sub find-definitions (:$pod, :$origin, :$dr, :$min-level = -1) {
315334
%attr = :kind<type>,
316335
:categories($tg.types{$name}.?categories//''),
317336
}
337+
when 'variable'|'sigil'|'twigil'|'declarator' {
338+
%attr = :kind<syntax>,
339+
:categories($subkinds),
340+
}
318341
default {
319342
$i = $i + 1 and next
320343
}

0 commit comments

Comments
 (0)