Skip to content

Commit 2d69708

Browse files
committed
scripts/documentation-file-ref-check: get rid of false-positives
Now that the number of broken refs are smaller, improve the logic that gets rid of false-positives. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Acked-by: Jonathan Corbet <corbet@lwn.net>
1 parent e1f319f commit 2d69708

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

scripts/documentation-file-ref-check

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,31 @@ while (<IN>) {
3838
my $f = $1;
3939
my $ln = $2;
4040

41-
# Makefiles contain nasty expressions to parse docs
42-
next if ($f =~ m/Makefile/);
41+
# Makefiles and scripts contain nasty expressions to parse docs
42+
next if ($f =~ m/Makefile/ || $f =~ m/\.sh$/);
43+
4344
# Skip this script
4445
next if ($f eq $scriptname);
4546

46-
if ($ln =~ m,\b(\S*)(Documentation/[A-Za-z0-9\_\.\,\~/\*\[\]\?+-]*),) {
47+
if ($ln =~ m,\b(\S*)(Documentation/[A-Za-z0-9\_\.\,\~/\*\[\]\?+-]*)(.*),) {
4748
my $prefix = $1;
4849
my $ref = $2;
4950
my $base = $2;
51+
my $extra = $3;
52+
53+
# some file references are like:
54+
# /usr/src/linux/Documentation/DMA-{API,mapping}.txt
55+
# For now, ignore them
56+
next if ($extra =~ m/^{/);
57+
58+
# Remove footnotes at the end like:
59+
# Documentation/devicetree/dt-object-internal.txt[1]
60+
$ref =~ s/(txt|rst)\[\d+]$/$1/;
61+
62+
# Remove ending ']' without any '['
63+
$ref =~ s/\].*// if (!($ref =~ m/\[/));
5064

65+
# Remove puntuation marks at the end
5166
$ref =~ s/[\,\.]+$//;
5267

5368
my $fulref = "$prefix$ref";

0 commit comments

Comments
 (0)