OSDN Git Service

scripts: get_abi: ignore code blocks for cross-references
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 25 Mar 2021 10:38:27 +0000 (11:38 +0100)
committerJonathan Corbet <corbet@lwn.net>
Wed, 31 Mar 2021 19:53:16 +0000 (13:53 -0600)
The script should not generate cross-references inside
literal blocks.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/a590f994f8a5742db333bde69e88241a080e4fe0.1616668017.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
scripts/get_abi.pl

index e5d1da4..d7aa820 100755 (executable)
@@ -382,8 +382,27 @@ sub output_rest {
                                # Enrich text by creating cross-references
 
                                my $new_desc = "";
+                               my $init_indent = -1;
+                               my $literal_indent = -1;
+
                                open(my $fh, "+<", \$desc);
                                while (my $d = <$fh>) {
+                                       my $indent = $d =~ m/^(\s+)/;
+                                       my $spaces = length($indent);
+                                       $init_indent = $indent if ($init_indent < 0);
+                                       if ($literal_indent >= 0) {
+                                               if ($spaces > $literal_indent) {
+                                                       $new_desc .= $d;
+                                                       next;
+                                               } else {
+                                                       $literal_indent = -1;
+                                               }
+                                       } else {
+                                               if ($d =~ /()::$/ && !($d =~ /^\s*\.\./)) {
+                                                       $literal_indent = $spaces;
+                                               }
+                                       }
+
                                        $d =~ s,Documentation/(?!devicetree)(\S+)\.rst,:doc:`/$1`,g;
 
                                        my @matches = $d =~ m,Documentation/ABI/([\w\/\-]+),g;