diff options
author | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2019-04-24 13:25:33 -0300 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2019-05-03 06:45:22 -0600 |
commit | 894ee5ff83335659da5fc4a4b1f41fa246f32d1a (patch) | |
tree | 22a0e9212e1be78029b4548fc665d463c0b33eef /scripts/documentation-file-ref-check | |
parent | fe3e4b9c6364d3aa69eb30f44d1a44bc90f99924 (diff) |
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>
Diffstat (limited to 'scripts/documentation-file-ref-check')
-rwxr-xr-x | scripts/documentation-file-ref-check | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/documentation-file-ref-check b/scripts/documentation-file-ref-check index bd7d9ab63941..63e9542656f1 100755 --- a/scripts/documentation-file-ref-check +++ b/scripts/documentation-file-ref-check @@ -30,6 +30,34 @@ print "Finding broken references. This may take a while... " if ($fix); my %broken_ref; +my $doc_fix = 0; + +open IN, "git grep ':doc:\`' Documentation/|" + or die "Failed to run git grep"; +while (<IN>) { + next if (!m,^([^:]+):.*\:doc\:\`([^\`]+)\`,); + + my $d = $1; + my $doc_ref = $2; + + my $f = $doc_ref; + + $d =~ s,(.*/).*,$1,; + $f =~ s,.*\<([^\>]+)\>,$1,; + + $f ="$d$f.rst"; + + next if (grep -e, glob("$f")); + + if ($fix && !$doc_fix) { + print STDERR "\nWARNING: Currently, can't fix broken :doc:`` fields\n"; + } + $doc_fix++; + + print STDERR "$f: :doc:`$doc_ref`\n"; +} +close IN; + open IN, "git grep 'Documentation/'|" or die "Failed to run git grep"; while (<IN>) { @@ -103,6 +131,7 @@ while (<IN>) { } } } +close IN; exit 0 if (!$fix); |