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 7DEEFC55179 for ; Wed, 28 Oct 2020 22:23:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A803206F4 for ; Wed, 28 Oct 2020 22:23:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603923795; bh=RbVYiyu/rnWFPmPj9R4bvXieqOVYpclyWM2vnETsDtk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1yWWSJWd/zJLCXjPwSCBv8hAU//GfFP/w6vjjAFlrJYAjhM927XMwGKA1Fi81KyqR Yr281l6geOjPPFT5f6Q1mH+MgJVz/cgPpZHP9O9pw966Ciu10Ghh3d4ZuzNrTGc++z 3ZDALfUGV6413IQCAsgCYfDWi/VFX6RnjLKCwN3g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732395AbgJ1WU4 (ORCPT ); Wed, 28 Oct 2020 18:20:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:60522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731696AbgJ1WRl (ORCPT ); Wed, 28 Oct 2020 18:17:41 -0400 Received: from mail.kernel.org (ip5f5ad5b2.dynamic.kabel-deutschland.de [95.90.213.178]) (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 B23DB2476E; Wed, 28 Oct 2020 14:23:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603895014; bh=RbVYiyu/rnWFPmPj9R4bvXieqOVYpclyWM2vnETsDtk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kTNF5Pqjd1M4SY1bzV51A86oc9KUrFY736pMM1/DVy3MTp/dGcJf0MYBTmbhqw7zS a+jCuxZJgdr4Qb7aPUFKeGMWoA1w2EssdpleQJ2EdNYC58dwDKja4JKyT3kdRAhWrQ RTnicPpRM+JELSNJml6ExltnvUR0o8oL43wEo6HM= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1kXmMO-003hlP-OH; Wed, 28 Oct 2020 15:23:32 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Greg Kroah-Hartman Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH 15/33] docs: kernel_abi.py: use --enable-lineno for get_abi.pl Date: Wed, 28 Oct 2020 15:23:13 +0100 Message-Id: <7ae62dc8a05ece0b1c04a57dde0ad25d62d13742.1603893146.git.mchehab+huawei@kernel.org> 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 From: Mauro Carvalho Chehab 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 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