mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scripts/documentation-file-ref-check: detect broken :doc:`foo`
@ 2019-04-24 16:25 Mauro Carvalho Chehab
  2019-05-03 12:41 ` Jonathan Corbet
  0 siblings, 1 reply; 2+ messages in thread
From: Mauro Carvalho Chehab @ 2019-04-24 16:25 UTC (permalink / raw)
  To: Linux Doc Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, linux-kernel,
	Jonathan Corbet

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>
---
 scripts/documentation-file-ref-check | 29 ++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/scripts/documentation-file-ref-check b/scripts/documentation-file-ref-check
index f47ef26754fa..01cf36e3840c 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);
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] scripts/documentation-file-ref-check: detect broken :doc:`foo`
  2019-04-24 16:25 [PATCH] scripts/documentation-file-ref-check: detect broken :doc:`foo` Mauro Carvalho Chehab
@ 2019-05-03 12:41 ` Jonathan Corbet
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Corbet @ 2019-05-03 12:41 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Doc Mailing List, Mauro Carvalho Chehab, linux-kernel

On Wed, 24 Apr 2019 13:25:33 -0300
Mauro Carvalho Chehab <mchehab+samsung@kernel.org> wrote:

> 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.

Applied, thanks.

jon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-03 12:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 16:25 [PATCH] scripts/documentation-file-ref-check: detect broken :doc:`foo` Mauro Carvalho Chehab
2019-05-03 12:41 ` Jonathan Corbet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®