From nobody Sun Feb 8 12:19:18 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 1538224BBF2; Mon, 24 Feb 2025 09:09:04 +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=1740388144; cv=none; b=CluUICEX8eHDBInpch8bX9q3ucwkHM3khECXbHW/XEJ3BY15jiz8BzkggHfG29fFkz8DdAvoKjW8zeC6aZTwmmzr/gsrZB0pyXDGR5XNxfsAcTZ2WplsOkg52ByVYpdgV1X4KlOJ3zWCdtM+X/GDJBmA/eC6Um6x2Klx7wfSlwo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740388144; c=relaxed/simple; bh=07FCqO/8Qxm5lSe7sCG8lMGcmip/PZdZVuFoGS9C284=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mvJKuDIgbXOzfpxQM6ksAw2pbxeTUsNR6LGKoxtT+U53HgACEjGcjgE9Kto9ejzpEhT+mNRFTkuuxZGNHzHCStA/+07eDJLUvcKIMnPuhPQNt2q7bOB4sYx3ICBzLn6Sw4LVW/Qv/N4ltecqLNpi96kAXje8pZqGwEd8Sov1Q7Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Eq5ynI/H; 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="Eq5ynI/H" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F4D1C2BCC7; Mon, 24 Feb 2025 09:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740388143; bh=07FCqO/8Qxm5lSe7sCG8lMGcmip/PZdZVuFoGS9C284=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eq5ynI/HGk1dxhEr8zv3/xWVea4TpFu3HvJ5N1q08cZ4pRMVAia2IRwrxqaoseNEN RgklGXBnC0iFL8v7MjW7uqUWFyAaCMqd9a504xOt05hWMaigjMdpG5MAqg1PoQWoqQ U/A10Ya/o2Xsxo15hcS9L+/Hinuja2HnpZ1GMAQhMtPN73g0dBVVLRv9Ig6DXwZEXl JgpmlWla4pApo+/tx7je9UG9EUp6swW3aDbNImrgZArtAyLjcgGcn5S/6c9ratmo5O WPqMHczHKHLMdrS6DMaUiBASTCf3i585Hqqer0J5hqlVr+2Ayzfj36vYUq5YoWAoI2 u2b5pGoKryaZw== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1tmUST-00000003p5j-35Dy; Mon, 24 Feb 2025 10:09:01 +0100 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , "Mauro Carvalho Chehab" , linux-kernel@vger.kernel.org Subject: [PATCH v2 35/39] scripts/kernel-doc.py: some coding style cleanups Date: Mon, 24 Feb 2025 10:08:41 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 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-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Remove some warnings generated by pylint. Among them, cleanup TODO messages, removing the ones that were already handled, as now all TODOs that are required to be fully compatible with kernel-doc were already addressed. So, the existing TODOs are pointing possible future cleanups and improvements. Signed-off-by: Mauro Carvalho Chehab --- scripts/kernel-doc.py | 10 +++++----- scripts/lib/kdoc/kdoc_files.py | 1 - scripts/lib/kdoc/kdoc_output.py | 1 + scripts/lib/kdoc/kdoc_parser.py | 30 +++++++----------------------- scripts/lib/kdoc/kdoc_re.py | 3 ++- 5 files changed, 15 insertions(+), 30 deletions(-) diff --git a/scripts/kernel-doc.py b/scripts/kernel-doc.py index 7683fb4ffc59..5e1e1839438c 100755 --- a/scripts/kernel-doc.py +++ b/scripts/kernel-doc.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# pylint: disable=3DC0103, +# pylint: disable=3DC0103,R0915 # Copyright(c) 2025: Mauro Carvalho Chehab . # SPDX-License-Identifier: GPL-2.0 =20 @@ -167,7 +167,7 @@ def main(): =20 # Those are valid for all 3 types of filter parser.add_argument("-n", "-nosymbol", "--nosymbol", action=3D'append', - help=3DNOSYMBOL_DESC) + help=3DNOSYMBOL_DESC) =20 parser.add_argument("-D", "-no-doc-sections", "--no-doc-sections", action=3D'store_true', help=3D"Don't outputt DOC s= ections") @@ -211,9 +211,9 @@ def main(): kfiles.parse(args.files, export_file=3Dargs.export_file) =20 for t in kfiles.msg(enable_lineno=3Dargs.enable_lineno, export=3Dargs.= export, - internal=3Dargs.internal, symbol=3Dargs.symbol, - nosymbol=3Dargs.nosymbol, - no_doc_sections=3Dargs.no_doc_sections): + internal=3Dargs.internal, symbol=3Dargs.symbol, + nosymbol=3Dargs.nosymbol, + no_doc_sections=3Dargs.no_doc_sections): msg =3D t[1] if msg: print(msg) diff --git a/scripts/lib/kdoc/kdoc_files.py b/scripts/lib/kdoc/kdoc_files.py index e130e5e32806..fc14bd6f9863 100755 --- a/scripts/lib/kdoc/kdoc_files.py +++ b/scripts/lib/kdoc/kdoc_files.py @@ -11,7 +11,6 @@ import argparse import logging import os import re -import sys =20 from kdoc_parser import KernelDoc from kdoc_output import OutputFormat diff --git a/scripts/lib/kdoc/kdoc_output.py b/scripts/lib/kdoc/kdoc_output= .py index d0cb7f511f87..487068753b53 100755 --- a/scripts/lib/kdoc/kdoc_output.py +++ b/scripts/lib/kdoc/kdoc_output.py @@ -234,6 +234,7 @@ class OutputFormat: def out_struct(self, fname, name, args): """Outputs a struct""" =20 + class RestFormat(OutputFormat): """Consts and functions used by ReST output""" =20 diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser= .py index 6cebc32e18f2..cf4bf7cedcbc 100755 --- a/scripts/lib/kdoc/kdoc_parser.py +++ b/scripts/lib/kdoc/kdoc_parser.py @@ -130,7 +130,7 @@ class KernelDoc: # Place all potential outputs into an array self.entries =3D [] =20 - # TODO: rename to emit_message + # TODO: rename to emit_message after removal of kernel-doc.pl def emit_warning(self, ln, msg, warning=3DTrue): """Emit a message""" =20 @@ -157,19 +157,6 @@ class KernelDoc: name =3D self.entry.section contents =3D self.entry.contents =20 - # TODO: we can prevent dumping empty sections here with: - # - # if self.entry.contents.strip("\n"): - # if start_new: - # self.entry.section =3D self.section_default - # self.entry.contents =3D "" - # - # return - # - # But, as we want to be producing the same output of the - # venerable kernel-doc Perl tool, let's just output everything, - # at least for now - if type_param.match(name): name =3D type_param.group(1) =20 @@ -205,7 +192,7 @@ class KernelDoc: self.entry.section =3D self.section_default self.entry.contents =3D "" =20 - # TODO: rename it to store_declaration + # TODO: rename it to store_declaration after removal of kernel-doc.pl def output_declaration(self, dtype, name, **args): """ Stores the entry into an entry array. @@ -225,13 +212,13 @@ class KernelDoc: args["type"] =3D dtype args["warnings"] =3D self.entry.warnings =20 - # TODO: use colletions.OrderedDict + # TODO: use colletions.OrderedDict to remove sectionlist =20 sections =3D args.get('sections', {}) sectionlist =3D args.get('sectionlist', []) =20 # Drop empty sections - # TODO: improve it to emit warnings + # TODO: improve empty sections logic to emit warnings for section in ["Description", "Return"]: if section in sectionlist: if not sections[section].rstrip(): @@ -635,7 +622,9 @@ class KernelDoc: =20 # Replace macros # - # TODO: it is better to also move those to the NestedMatch log= ic, + # TODO: use NestedMatch for FOO($1, $2, ...) matches + # + # it is better to also move those to the NestedMatch logic, # to ensure that parenthesis will be properly matched. =20 (Re(r'__ETHTOOL_DECLARE_LINK_MODE_MASK\s*\(([^\)]+)\)', re.S),= r'DECLARE_BITMAP(\1, __ETHTOOL_LINK_MODE_MASK_NBITS)'), @@ -902,7 +891,6 @@ class KernelDoc: self.dump_struct(ln, prototype) return =20 - # TODO: handle other types self.output_declaration(self.entry.decl_type, prototype, entry=3Dself.entry) =20 @@ -1670,10 +1658,6 @@ class KernelDoc: self.st_inline_name[self.inline_= doc_state], line) =20 - # TODO: not all states allow EXPORT_SYMBOL*, so this - # can be optimized later on to speedup parsing - self.process_export(self.config.function_table, line) - # Hand this line to the appropriate state handler if self.state =3D=3D self.STATE_NORMAL: self.process_normal(ln, line) diff --git a/scripts/lib/kdoc/kdoc_re.py b/scripts/lib/kdoc/kdoc_re.py index 45ddba8090e5..de362ec38db7 100755 --- a/scripts/lib/kdoc/kdoc_re.py +++ b/scripts/lib/kdoc/kdoc_re.py @@ -131,7 +131,8 @@ class NestedMatch: will ignore the search string. """ =20 - # TODO: + # TODO: make NestedMatch handle multiple match groups + # # Right now, regular expressions to match it are defined only up to # the start delimiter, e.g.: # --=20 2.48.1