From nobody Tue Feb 10 03:36:58 2026 Received: from ms.lwn.net (ms.lwn.net [45.79.88.28]) (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 5AF6F28A1C9; Fri, 6 Jun 2025 16:35:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.79.88.28 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749227706; cv=none; b=TQOET5g6TiyOobBslc78DOGTXWmeUiXWTnk59SX9yJxiy/NyoqWB703u2/xvnhcXlFtzMWA8OxUeRuPvRMpZHsDzuMT5dKe7PnzUbpj3QGmnhMvtT4aWEVt9Y2r6kVbvLxMmGF/fQFMKWoomR1fklyeBdtA+p0nYATMpl9k+oCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749227706; c=relaxed/simple; bh=DIPIVjIPVmXpZgI2rlAH7UBlHZake7OmEefjqrurvNk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ozdJ7QN34t0FvIjI2e/vbahWGA5G9J8CLHUbjFxVd7NOaEpgTWvEn0pIryuxVgoF18KHnvwzHwrvzofI+lWIlFkPD0kfb4Pbqcqqab+ZiD6sXp7kRgkAGOsjlxoOjadBu/119dHs5uKL+3Vcv1jct3GoZf1uct3PdAWKuDq4Q14= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lwn.net; spf=pass smtp.mailfrom=lwn.net; dkim=pass (2048-bit key) header.d=lwn.net header.i=@lwn.net header.b=S0cozf2K; arc=none smtp.client-ip=45.79.88.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lwn.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lwn.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lwn.net header.i=@lwn.net header.b="S0cozf2K" DKIM-Filter: OpenDKIM Filter v2.11.0 ms.lwn.net 36FF441F32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lwn.net; s=20201203; t=1749227699; bh=iNnVL4BxscFhHXFqnQBQA6YU9gzB5+B9LbFNv/P51Dc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S0cozf2K5fJE7OJVUPD8V+U9jjWzv4sA6yzrvSiFnWN08bMYHhQdw8TGRdCvtSSXX ZzjtC2ZLb4BjO8Y7tlC3DqOAtas1+0/zLcPeM0DZ3x9YOG6VZsCe9sIZyHTGcz60Id 1SDO/ttjcXKLPqhV8RmD1vnbjWGziDxHh7Puy+pVLRTEoRC84W/v1I0hcNJei+MQiV QWlHIS6b79GmoEIFtN8i/bIN/RcNy8u+0lVk6w2/4MHeMIsWKWOpr4HFwmc9QwAOaq Vo646R6A02/5ATri9/fia5F1cfz+zcCRgrqhndailliyj6NDCb9uVXRAvv5nj/NtqL sHfvegRtSlOjg== Received: from trenco.lwn.net (unknown [IPv6:2601:280:4600:2da9::1fe]) by ms.lwn.net (Postfix) with ESMTPA id 36FF441F32; Fri, 6 Jun 2025 16:34:59 +0000 (UTC) From: Jonathan Corbet To: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Jonathan Corbet Subject: [PATCH 8/9] docs: kdoc: move the declaration regexes out of process_name() Date: Fri, 6 Jun 2025 10:34:37 -0600 Message-ID: <20250606163438.229916-9-corbet@lwn.net> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250606163438.229916-1-corbet@lwn.net> References: <20250606163438.229916-1-corbet@lwn.net> 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 Content-Type: text/plain; charset="utf-8" Move two complex regexes up with the other patterns, decluttering this function and allowing the compilation to be done once rather than for every kerneldoc comment. Signed-off-by: Jonathan Corbet Reviewed-by: Mauro Carvalho Chehab --- scripts/lib/kdoc/kdoc_parser.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser= .py index 4e1ab28ff7cc..55f38240d4e5 100644 --- a/scripts/lib/kdoc/kdoc_parser.py +++ b/scripts/lib/kdoc/kdoc_parser.py @@ -47,7 +47,6 @@ doc_sect =3D doc_com + \ flags=3Dre.I, cache=3DFalse) =20 doc_content =3D doc_com_body + KernRe(r'(.*)', cache=3DFalse) -doc_block =3D doc_com + KernRe(r'DOC:\s*(.*)?', cache=3DFalse) doc_inline_start =3D KernRe(r'^\s*/\*\*\s*$', cache=3DFalse) doc_inline_sect =3D KernRe(r'\s*\*\s*(@\s*[\w][\w\.]*\s*):(.*)', cache=3DF= alse) doc_inline_end =3D KernRe(r'^\s*\*/\s*$', cache=3DFalse) @@ -60,6 +59,18 @@ export_symbol_ns =3D KernRe(r'^\s*EXPORT_SYMBOL_NS(_GPL)= ?\s*\(\s*(\w+)\s*,\s*"\S+" =20 type_param =3D KernRe(r"\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)", cache=3DFalse) =20 +# +# Tests for the beginning of a kerneldoc block in its various forms. +# +doc_block =3D doc_com + KernRe(r'DOC:\s*(.*)?', cache=3DFalse) +doc_begin_data =3D KernRe(r"^\s*\*?\s*(struct|union|enum|typedef)\b\s*(\w*= )", cache =3D False) +doc_begin_func =3D KernRe(str(doc_com) + # initial " * ' + r"(?:\w+\s*\*\s*)?" + # type (not captured) + r'(?:define\s+)?' + # possible "define" (not cap= tured) + r'(\w+)\s*(?:\(\w*\))?\s*' + # name and optional "= (...)" + r'(?:[-:].*)?$', # description (not captured) + cache =3D False) + # # A little helper to get rid of excess white space # @@ -1224,22 +1235,15 @@ class KernelDoc: if doc_decl.search(line): self.entry.identifier =3D doc_decl.group(1) =20 - decl_start =3D str(doc_com) # comment block asterisk - fn_type =3D r"(?:\w+\s*\*\s*)?" # type (for non-functions) - parenthesis =3D r"(?:\(\w*\))?" # optional parenthesis on fu= nction - decl_end =3D r"(?:[-:].*)" # end of the name part - # Test for data declaration - r =3D KernRe(r"^\s*\*?\s*(struct|union|enum|typedef)\b\s*(\w*)= ") - r2 =3D KernRe(fr"^{decl_start}{fn_type}(?:define\s+)?(\w+)\s*{= parenthesis}\s*{decl_end}?$") - if r.search(line): - self.entry.decl_type =3D r.group(1) - self.entry.identifier =3D r.group(2) + if doc_begin_data.search(line): + self.entry.decl_type =3D doc_begin_data.group(1) + self.entry.identifier =3D doc_begin_data.group(2) # # Look for a function description # - elif r2.search(line): - self.entry.identifier =3D r2.group(1) + elif doc_begin_func.search(line): + self.entry.identifier =3D doc_begin_func.group(1) self.entry.decl_type =3D "function" # # We struck out. --=20 2.49.0