History

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.

Mauro Carvalho Chehab committed 7 years ago

Commit 894ee5f1 parent fe3e4b91 file · +29 −0Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/documentation-file-ref-check+29−0
@@ -30,6 +30,34 @@ print "Finding broken references. This may take a while... " if ($fix); · 29 unmodified lines
3030
3131 my %broken_ref;
3232
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+
3361 open IN, "git grep 'Documentation/'|"
3462 or die "Failed to run git grep";
3563 while (<IN>) {
@@ -103,6 +131,7 @@ while (<IN>) { · 67 unmodified lines
103131 }
104132 }
105133 }
134+close IN;
106135
107136 exit 0 if (!$fix);
108137