Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scripts/documentation-file-ref-check: detect broken :doc:`foo`

As we keep migrating documents to ReST, we're starting to see
more of such tags.

Right now, all such tags are pointing to a documentation file,
but regressions may be introduced.

So, add a check for such kind of issues as well.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
894ee5ff fe3e4b9c

+29
+29
scripts/documentation-file-ref-check
··· 30 30 31 31 my %broken_ref; 32 32 33 + my $doc_fix = 0; 34 + 35 + open IN, "git grep ':doc:\`' Documentation/|" 36 + or die "Failed to run git grep"; 37 + while (<IN>) { 38 + next if (!m,^([^:]+):.*\:doc\:\`([^\`]+)\`,); 39 + 40 + my $d = $1; 41 + my $doc_ref = $2; 42 + 43 + my $f = $doc_ref; 44 + 45 + $d =~ s,(.*/).*,$1,; 46 + $f =~ s,.*\<([^\>]+)\>,$1,; 47 + 48 + $f ="$d$f.rst"; 49 + 50 + next if (grep -e, glob("$f")); 51 + 52 + if ($fix && !$doc_fix) { 53 + print STDERR "\nWARNING: Currently, can't fix broken :doc:`` fields\n"; 54 + } 55 + $doc_fix++; 56 + 57 + print STDERR "$f: :doc:`$doc_ref`\n"; 58 + } 59 + close IN; 60 + 33 61 open IN, "git grep 'Documentation/'|" 34 62 or die "Failed to run git grep"; 35 63 while (<IN>) { ··· 131 103 } 132 104 } 133 105 } 106 + close IN; 134 107 135 108 exit 0 if (!$fix); 136 109