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.
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -381,34 +381,41 @@ sub output_rest { · 380 unmodified lines | |||
| 381 | 381 | ||
| 382 | # Enrich text by creating cross-references | 382 | # Enrich text by creating cross-references |
| 383 | 383 | ||
| 384 | $desc =~ s,Documentation/(?!devicetree)(\S+)\.rst,:doc:`/$1`,g; | 384 | my $new_desc = ""; |
| 385 | 385 | open(my $fh, "+<", \$desc); | |
| 386 | my @matches = $desc =~ m,Documentation/ABI/([\w\/\-]+),g; | 386 | while (my $d = <$fh>) { |
| 387 | foreach my $f (@matches) { | 387 | $d =~ s,Documentation/(?!devicetree)(\S+)\.rst,:doc:`/$1`,g; |
| 388 | my $xref = $f; | 388 | |
| 389 | my $path = $f; | 389 | my @matches = $d =~ m,Documentation/ABI/([\w\/\-]+),g; |
| 390 | $path =~ s,.*/(.*/.*),$1,;; | 390 | foreach my $f (@matches) { |
| 391 | $path =~ s,[/\-],_,g;; | 391 | my $xref = $f; |
| 392 | $xref .= " <abi_file_" . $path . ">"; | 392 | my $path = $f; |
| 393 | $desc =~ s,\bDocumentation/ABI/$f\b,:ref:`$xref`,g; | 393 | $path =~ s,.*/(.*/.*),$1,;; |
| 394 | } | 394 | $path =~ s,[/\-],_,g;; |
| 395 | $xref .= " <abi_file_" . $path . ">"; | ||
| 396 | $d =~ s,\bDocumentation/ABI/$f\b,:ref:`$xref`,g; | ||
| 397 | } | ||
| 395 | 398 | ||
| 396 | # Seek for cross reference symbols like /sys/... | 399 | # Seek for cross reference symbols like /sys/... |
| 397 | @matches = $desc =~ m/$xref_match/g; | 400 | @matches = $d =~ m/$xref_match/g; |
| 398 | 401 | ||
| 399 | foreach my $s (@matches) { | 402 | foreach my $s (@matches) { |
| 400 | next if (!($s =~ m,/,)); | 403 | next if (!($s =~ m,/,)); |
| 401 | if (defined($data{$s}) && defined($data{$s}->{label})) { | 404 | if (defined($data{$s}) && defined($data{$s}->{label})) { |
| 402 | my $xref = $s; | 405 | my $xref = $s; |
| 403 | 406 | ||
| 404 | $xref =~ s/$symbols/\\$1/g; | 407 | $xref =~ s/$symbols/\\$1/g; |
| 405 | $xref = ":ref:`$xref <" . $data{$s}->{label} . ">`"; | 408 | $xref = ":ref:`$xref <" . $data{$s}->{label} . ">`"; |
| 406 | 409 | ||
| 407 | $desc =~ s,$start$s$bondary,$1$xref$2,g; | 410 | $d =~ s,$start$s$bondary,$1$xref$2,g; |
| 411 | } | ||
| 408 | } | 412 | } |
| 413 | $new_desc .= $d; | ||
| 409 | } | 414 | } |
| 415 | close $fh; | ||
| 416 | |||
| 410 | 417 | ||
| 411 | print "$desc\n\n"; | 418 | print "$new_desc\n\n"; |
| 412 | } else { | 419 | } else { |
| 413 | $desc =~ s/^\s+//; | 420 | $desc =~ s/^\s+//; |
| 414 | 421 | ||