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=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 267C3C63777 for ; Fri, 30 Oct 2020 07:43:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BAAFB2220B for ; Fri, 30 Oct 2020 07:43:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604043813; bh=9/c5OmFlR/hmRku2FTUlNg+8TtpQZ2resIqT66CTs3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=sNhD8MJqKYC9o8i0RLq8Bvipf/gJ1HjasGZ/ERDfrIJGZHqcunOtMW5cM2acaYZE6 Gs+H/gfXB4D+1/VwJm6RMJGHNxqoMNsl1R3OTr/T0Vg7XdXhAqxUhHSMPiXzW3+3jN MsQOARuUFKEAhq5X2EjGXNI3IQk+InS7xtf+8eNU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726197AbgJ3Hnc (ORCPT ); Fri, 30 Oct 2020 03:43:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:51860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbgJ3HlE (ORCPT ); Fri, 30 Oct 2020 03:41:04 -0400 Received: from mail.kernel.org (ip5f5ad5bb.dynamic.kabel-deutschland.de [95.90.213.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A30F622248; Fri, 30 Oct 2020 07:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604043662; bh=9/c5OmFlR/hmRku2FTUlNg+8TtpQZ2resIqT66CTs3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zs6kTxFKDCQd9iFqeWFUy1Sk2qPPL0SnhU4x7bwyeu7gdaYZQ3A1SXpGmb4lKY0yX dIGZ9KKrVGf4VR3jyzYJblymnemRwVD584F9oD0/kCzV4TJcWGFgC/8cu7Z3A8aZ7d +grVaYCDseX8CFveEOxXc+vISzddYTKgRUbXK7NM= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1kYP1w-004Ofq-NU; Fri, 30 Oct 2020 08:41:00 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , linux-kernel@vger.kernel.org Subject: [PATCH v2 15/39] docs: kernel_abi.py: use --enable-lineno for get_abi.pl Date: Fri, 30 Oct 2020 08:40:34 +0100 Message-Id: X-Mailer: git-send-email 2.26.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 Just like kernel-doc extension, we need to be able to identify what part of an imported document has issues, as reporting them as: get_abi.pl rest --dir $srctree/Documentation/ABI/obsolete --rst-source:1689: ERROR: Unexpected indentation. Makes a lot harder for someone to fix. It should be noticed that it the line which will be reported is the line where the "What:" definition is, and not the line with actually has an error. Signed-off-by: Mauro Carvalho Chehab --- Documentation/sphinx/kernel_abi.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kernel_abi.py index 8601a3b75a28..096dec482e96 100644 --- a/Documentation/sphinx/kernel_abi.py +++ b/Documentation/sphinx/kernel_abi.py @@ -36,6 +36,7 @@ import codecs import os import subprocess import sys +import re from os import path @@ -93,7 +94,7 @@ class KernelCmd(Directive): env = doc.settings.env cwd = path.dirname(doc.current_source) - cmd = "get_abi.pl rest --dir " + cmd = "get_abi.pl rest --enable-lineno --dir " cmd += self.arguments[0] srctree = path.abspath(os.environ["srctree"]) @@ -137,7 +138,7 @@ class KernelCmd(Directive): % (self.name, ErrorString(exc))) return out - def nestedParse(self, lines, fname): + def nestedParse(self, lines, f): content = ViewList() node = nodes.section() @@ -147,8 +148,17 @@ class KernelCmd(Directive): code_block += "\n " + l lines = code_block + "\n\n" - for c, l in enumerate(lines.split("\n")): - content.append(l, fname, c) + line_regex = re.compile("^#define LINENO (\S+)\#([0-9]+)$") + ln = 0 + + for line in lines.split("\n"): + match = line_regex.search(line) + if match: + f = match.group(1) + # sphinx counts lines from 0 + ln = int(match.group(2)) - 1 + else: + content.append(line, f, ln) buf = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter -- 2.26.2