From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 439BFC433E0 for ; Thu, 25 Mar 2021 10:39:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1927961A30 for ; Thu, 25 Mar 2021 10:39:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230345AbhCYKjK (ORCPT ); Thu, 25 Mar 2021 06:39:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:53544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230163AbhCYKic (ORCPT ); Thu, 25 Mar 2021 06:38:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D7A50619FE; Thu, 25 Mar 2021 10:38:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616668712; bh=XdWrZeI0OJ0qNfVpkg0AQG7GblnuxxssfsvEd5dtxGo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r8JCc4UN6XrxF1KDnxhuZzWRfFmh28bw54uWoNVGBVodNE/Ml8d2FlAMIgLK6cUwR 5YDiA6jC5xPRfmXHd6XQMdaxN7SQuELCS1fUR2WSQyAWkthMlGW8OSpyRDsoyg6/+g YHS1mXuR1YR+1l4uKYAkCBmz4zljMhNRd7n5flrzNmH7sg6ksp903JtiP1nbq+GEUR djUKdRCQZCDMdaMALq1lZa5MzXJdpv+tcmXLPcwoPUQ+WkelvE3t7QhKk5KQOI+VaB G2JCFq1Tw+xSBQq9wVK6kmKldHpxWh9FwFZBKRnhqZ/Gr8AsY/w6eRsUc84VOwjH9i 0Y9lpAklLKI1g== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lPNNl-001Ava-A5; Thu, 25 Mar 2021 11:38:29 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet , Andrew Morton Cc: Mauro Carvalho Chehab , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH v2 5/7] scripts: get_abi.pl: parse description line per line Date: Thu, 25 Mar 2021 11:38:26 +0100 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Mauro Carvalho Chehab Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: Mauro Carvalho Chehab --- scripts/get_abi.pl | 47 ++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/scripts/get_abi.pl b/scripts/get_abi.pl index eb1a23103afa..e5d1da492c1e 100755 --- a/scripts/get_abi.pl +++ b/scripts/get_abi.pl @@ -381,34 +381,41 @@ 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; - foreach my $f (@matches) { - my $xref = $f; - my $path = $f; - $path =~ s,.*/(.*/.*),$1,;; - $path =~ s,[/\-],_,g;; - $xref .= " "; - $desc =~ s,\bDocumentation/ABI/$f\b,:ref:`$xref`,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 .= " "; + $d =~ s,\bDocumentation/ABI/$f\b,:ref:`$xref`,g; + } - # Seek for cross reference symbols like /sys/... - @matches = $desc =~ m/$xref_match/g; + # Seek for cross reference symbols like /sys/... + @matches = $d =~ m/$xref_match/g; - foreach my $s (@matches) { - next if (!($s =~ m,/,)); - if (defined($data{$s}) && defined($data{$s}->{label})) { - my $xref = $s; + foreach my $s (@matches) { + next if (!($s =~ m,/,)); + if (defined($data{$s}) && defined($data{$s}->{label})) { + my $xref = $s; - $xref =~ s/$symbols/\\$1/g; - $xref = ":ref:`$xref <" . $data{$s}->{label} . ">`"; + $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+//; -- 2.30.2