Commit 290d5388 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Jonathan Corbet

scripts: documentation-file-ref-check: improve :doc: handling

There are some issues at the script with regards to :doc:
tags:

- It doesn't escape files under Documentation/sphinx,
  leading to false positives;
- It doesn't handle root URLs, like :doc:`/x86/boot`;
- It doesn't output the file with a bad reference.

Address those things, in order to remove false positives
from the list of problems.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 43e96ef8
...@@ -51,7 +51,9 @@ open IN, "git grep ':doc:\`' Documentation/|" ...@@ -51,7 +51,9 @@ open IN, "git grep ':doc:\`' Documentation/|"
or die "Failed to run git grep"; or die "Failed to run git grep";
while (<IN>) { while (<IN>) {
next if (!m,^([^:]+):.*\:doc\:\`([^\`]+)\`,); next if (!m,^([^:]+):.*\:doc\:\`([^\`]+)\`,);
next if (m,sphinx/,);
my $file = $1;
my $d = $1; my $d = $1;
my $doc_ref = $2; my $doc_ref = $2;
...@@ -60,7 +62,12 @@ while (<IN>) { ...@@ -60,7 +62,12 @@ while (<IN>) {
$d =~ s,(.*/).*,$1,; $d =~ s,(.*/).*,$1,;
$f =~ s,.*\<([^\>]+)\>,$1,; $f =~ s,.*\<([^\>]+)\>,$1,;
$f ="$d$f.rst"; if ($f =~ m,^/,) {
$f = "$f.rst";
$f =~ s,^/,Documentation/,;
} else {
$f = "$d$f.rst";
}
next if (grep -e, glob("$f")); next if (grep -e, glob("$f"));
...@@ -69,7 +76,7 @@ while (<IN>) { ...@@ -69,7 +76,7 @@ while (<IN>) {
} }
$doc_fix++; $doc_fix++;
print STDERR "$f: :doc:`$doc_ref`\n"; print STDERR "$file: :doc:`$doc_ref`\n";
} }
close IN; close IN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment