Skip to content

Commit fbe5844

Browse files
committed
Only report exact case matches.
Be sneaky and work even on case-insensitive file systems.
1 parent f1b9f67 commit fbe5844

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

xt/rakudoc-types.rakutest

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,23 @@ sub render-node($node) {
4040
$result;
4141
}
4242

43+
# given a slashy type, see if that file exists on disk
44+
# To work on case-insensitive file systems, we grep the dir listing
45+
# rather than check a preconstructed path.
46+
47+
sub file-exists($type) {
48+
my @parts = $type.split('/');
49+
50+
my $path = "doc/Type".IO;
51+
while @parts {
52+
my $part = @parts.shift;
53+
$part ~= '.rakudoc' unless @parts.elems;
54+
return False unless $path.dir.grep(*.basename eq $part);
55+
$path = $path.child($part);
56+
}
57+
return True;
58+
}
59+
4360
sub is-valid-type($node, $parent, $file) {
4461
# only care about I<>, C<>, L<>, etc.
4562
return unless $node ~~ Pod::FormattingCode;
@@ -49,7 +66,8 @@ sub is-valid-type($node, $parent, $file) {
4966
my $type = $node.contents.join('');
5067
my $type-slash = $type.subst('::', '/', :g);
5168
my $type-colon = $type.subst('/', '::', :g);
52-
return unless "doc/Type/$type-slash.rakudoc".IO.f;
69+
70+
return unless file-exists($type-slash);
5371

5472
if $file eq "doc/Type/$type-slash.rakudoc" {
5573
# We are on the same page as this type. Don't link it, only C<> it.

0 commit comments

Comments
 (0)