From nobody Mon Apr 6 20:18:38 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C84F3A5E99; Wed, 18 Mar 2026 09:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773825081; cv=none; b=rRjNjqsmv9l95auVkj15HEEv68wCQi5CfGdPvYu+hVDKTAeyT82TQlzrqT/HkajrPt78hrjpBXlVKxT0CSYnMPXYc81aCVgd5hU9lr/svU0Bu6Y7hDtnLJrvdehdlH0l4mUwgB4yGZJ6891fQQJiytXywa73JwIpWUoQ5WDDjBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773825081; c=relaxed/simple; bh=BLxIAC+0ecDESspKr2mOmfyOm7KPoCXOrsFtpwI+cOw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NPl4ehV+IHnILCTkeWRLDDXuNWqPYy7lM4O9miTTKuU22EN5YfZcN61UIk5ezJyNjMSAj4kuK6AwYc3AQKlW04m/6yD3DfMRfPXdc6q5f/dZP/Rvt88Xphp4A03YR2eo+ngxg60GCObbrWPbn3fwBRwPPnrSyKJLb2CY/bDn088= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QeOX7hT8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QeOX7hT8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A41DC2BCB2; Wed, 18 Mar 2026 09:11:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773825080; bh=BLxIAC+0ecDESspKr2mOmfyOm7KPoCXOrsFtpwI+cOw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QeOX7hT8BfEHwFwAO+XNFVsZIGt+g0XWKMVx86dJQOQhIGGF3YRGOwL2rJ0Rn5xO2 p5JKfQlS2cPJWWxq6+rmkxLVrM52F4aRhEQX3zAAIT+yYoCYU1OHFLXqdZF5X3oSJp +SahHaeCo4IJ63VqJlm/2bG7HGEc1JgtAgYXJsFcPzS4ba7iGDxCGNF2bRKb8WdJRn L7Mc1y9EdqoLtBPkkGciB5J8nlEXpaHMVcZD/6MKLz9CTK/jA5enJpgUbqBub0WqXe jJJfSuspFmScwk1qGaUqPb50jDnYNSSIoQxSqCgT7ySc3TI5e3NOrMENIGoSTkhKzU fmh59tF7lYFhw== Received: from mchehab by mail.kernel.org with local (Exim 4.99.1) (envelope-from ) id 1w2mvu-00000002fpW-2JDS; Wed, 18 Mar 2026 10:11:18 +0100 From: Mauro Carvalho Chehab To: Jonathan Corbet , Linux Doc Mailing List Cc: Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Randy Dunlap Subject: [PATCH 04/14] docs: kdoc_files: use a class to group config parameters Date: Wed, 18 Mar 2026 10:11:04 +0100 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Instead of abusing argparse.Namespace, define a class to store configuration parameters and logger. Signed-off-by: Mauro Carvalho Chehab --- tools/lib/python/kdoc/kdoc_files.py | 45 ++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/tools/lib/python/kdoc/kdoc_files.py b/tools/lib/python/kdoc/kd= oc_files.py index 8c2059623949..1c5cb9e5f0e8 100644 --- a/tools/lib/python/kdoc/kdoc_files.py +++ b/tools/lib/python/kdoc/kdoc_files.py @@ -9,7 +9,6 @@ Classes for navigating through the files that kernel-doc ne= eds to handle to generate documentation. """ =20 -import argparse import logging import os import re @@ -87,6 +86,28 @@ class GlobSourceFiles: file_not_found_cb(fname) =20 =20 +class KdocConfig(): + """ + Stores all configuration attributes that kdoc_parser and kdoc_output + needs. + """ + def __init__(self, verbose=3DFalse, werror=3DFalse, wreturn=3DFalse, + wshort_desc=3DFalse, wcontents_before_sections=3DFalse, + logger=3DNone): + + self.verbose =3D verbose + self.werror =3D werror + self.wreturn =3D wreturn + self.wshort_desc =3D wshort_desc + self.wcontents_before_sections =3D wcontents_before_sections + + if logger: + self.log =3D logger + else: + self.log =3D logging.getLogger(__file__) + + self.warning =3D self.log.warning + class KernelFiles(): """ Parse kernel-doc tags on multiple kernel source files. @@ -224,29 +245,25 @@ class KernelFiles(): if kdoc_werror: werror =3D kdoc_werror =20 + if not logger: + logger =3D logging.getLogger("kernel-doc") + else: + logger =3D logger + # Some variables are global to the parser logic as a whole as they= are # used to send control configuration to KernelDoc class. As such, # those variables are read-only inside the KernelDoc. - self.config =3D argparse.Namespace + self.config =3D KdocConfig(verbose, werror, wreturn, wshort_desc, + wcontents_before_sections, logger) =20 - self.config.verbose =3D verbose - self.config.werror =3D werror - self.config.wreturn =3D wreturn - self.config.wshort_desc =3D wshort_desc - self.config.wcontents_before_sections =3D wcontents_before_sections + # Override log warning, as we want to count errors + self.config.warning =3D self.warning =20 if xforms: self.xforms =3D xforms else: self.xforms =3D CTransforms() =20 - if not logger: - self.config.log =3D logging.getLogger("kernel-doc") - else: - self.config.log =3D logger - - self.config.warning =3D self.warning - self.config.src_tree =3D os.environ.get("SRCTREE", None) =20 # Initialize variables that are internal to KernelFiles --=20 2.53.0