Commit c27c2e34 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Jonathan Corbet

scripts: get_abi.pl: parse description line per line

Change the description parsing logic in rst mode in order
to parse it line per line.

The end result is the same, but doing line per line allows
to add some code to escape literal blocks when seeking for
cross-references.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/d33cfa2e59ecf8f28d4ed7de7402468cf2168921.1616668017.git.mchehab+huawei@kernel.orgSigned-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 87ec9ea1
......@@ -381,20 +381,23 @@ sub output_rest {
# Enrich text by creating cross-references
$desc =~ s,Documentation/(?!devicetree)(\S+)\.rst,:doc:`/$1`,g;
my $new_desc = "";
open(my $fh, "+<", \$desc);
while (my $d = <$fh>) {
$d =~ s,Documentation/(?!devicetree)(\S+)\.rst,:doc:`/$1`,g;
my @matches = $desc =~ m,Documentation/ABI/([\w\/\-]+),g;
my @matches = $d =~ m,Documentation/ABI/([\w\/\-]+),g;
foreach my $f (@matches) {
my $xref = $f;
my $path = $f;
$path =~ s,.*/(.*/.*),$1,;;
$path =~ s,[/\-],_,g;;
$xref .= " <abi_file_" . $path . ">";
$desc =~ s,\bDocumentation/ABI/$f\b,:ref:`$xref`,g;
$d =~ s,\bDocumentation/ABI/$f\b,:ref:`$xref`,g;
}
# Seek for cross reference symbols like /sys/...
@matches = $desc =~ m/$xref_match/g;
@matches = $d =~ m/$xref_match/g;
foreach my $s (@matches) {
next if (!($s =~ m,/,));
......@@ -404,11 +407,15 @@ sub output_rest {
$xref =~ s/$symbols/\\$1/g;
$xref = ":ref:`$xref <" . $data{$s}->{label} . ">`";
$desc =~ s,$start$s$bondary,$1$xref$2,g;
$d =~ s,$start$s$bondary,$1$xref$2,g;
}
}
$new_desc .= $d;
}
close $fh;
print "$desc\n\n";
print "$new_desc\n\n";
} else {
$desc =~ s/^\s+//;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment