From 55e5414f2f8e31a8abbd95c43c24b69e83560a20 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 30 Oct 2020 08:40:29 +0100 Subject: [PATCH] scripts: get_abi.pl: auto-generate cross references There are several cross-references that can be automatically generated: - References to .rst files inside Documentation/ - References to other ABI files; - References to ABI symbols at /sys/*. Add a logic to automatically parse them and convert into cross references. Acked-by: Jonathan Corbet Signed-off-by: Mauro Carvalho Chehab Link: https://lore.kernel.org/r/abe756d4f94fb6ffcc3dd3902a766c7c3990ea89.1604042072.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman --- scripts/get_abi.pl | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/scripts/get_abi.pl b/scripts/get_abi.pl index 12a23f9a2f86..ff4f9f82ecad 100755 --- a/scripts/get_abi.pl +++ b/scripts/get_abi.pl @@ -3,6 +3,7 @@ use strict; use warnings; +use utf8; use Pod::Usage; use Getopt::Long; use File::Find; @@ -272,6 +273,9 @@ sub create_labels { # Outputs the book on ReST format # +# \b doesn't work well with paths. So, we need to define something else +my $bondary = qr { (?"; + $desc =~ s,\bDocumentation/ABI/$f\b,:ref:`$xref`,g; + } + + @matches = $desc =~ m,$bondary(/sys/[^\s\.\,\;\:\*\s\`\'\(\)]+)$bondary,; + + foreach my $s (@matches) { + if (defined($data{$s}) && defined($data{$s}->{label})) { + my $xref = $s; + + $xref =~ s/([\x00-\x1f\x21-\x2f\x3a-\x40\x7b-\xff])/\\$1/g; + $xref = ":ref:`$xref <" . $data{$s}->{label} . ">`"; + + $desc =~ s,$bondary$s$bondary,$xref,g; + } + } + print "$desc\n\n"; } else { $desc =~ s/^\s+//;