mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Jonathan Corbet <corbet@lwn.net>,
	Linux Doc Mailing List <linux-doc@vger.kernel.org>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	intel-wired-lan@lists.osuosl.org,
	linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org,
	Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Randy Dunlap <rdunlap@infradead.org>
Subject: [PATCH v4 24/41] docs: kdoc_parser: use the new CFunction class
Date: Sat, 31 Jan 2026 15:24:58 +0100	[thread overview]
Message-ID: <06eaea98108e280144f088cbb3f35bf1d2fb5937.1769867953.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1769867953.git.mchehab+huawei@kernel.org>

The match logic for transforms becomes a lot clearer if we use
CFunction convenient alias class instead of NestedMatch.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
---
 tools/lib/python/kdoc/kdoc_parser.py | 38 ++++++++++++++--------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/kdoc_parser.py
index d2eb93f9d489..50d57c6799bb 100644
--- a/tools/lib/python/kdoc/kdoc_parser.py
+++ b/tools/lib/python/kdoc/kdoc_parser.py
@@ -13,7 +13,7 @@ import sys
 import re
 from pprint import pformat
 
-from kdoc.kdoc_re import NestedMatch, KernRe
+from kdoc.kdoc_re import CFunction, KernRe
 from kdoc.kdoc_item import KdocItem
 
 #
@@ -119,22 +119,22 @@ struct_xforms = [
     #
     # As it doesn't properly match the end parenthesis on some cases.
     #
-    # So, a better solution was crafted: there's now a NestedMatch
+    # So, a better solution was crafted: there's now a CFunction
     # class that ensures that delimiters after a search are properly
     # matched. So, the implementation to drop STRUCT_GROUP() will be
     # handled in separate.
     #
-    (NestedMatch(r'\bstruct_group\s*\('), r'\2'),
-    (NestedMatch(r'\bstruct_group_attr\s*\('), r'\3'),
-    (NestedMatch(r'\bstruct_group_tagged\s*\('), r'struct \1 { \3 } \2;'),
-    (NestedMatch(r'\b__struct_group\s*\('), r'\4'),
+    (CFunction('struct_group'), r'\2'),
+    (CFunction('struct_group_attr'), r'\3'),
+    (CFunction('struct_group_tagged'), r'struct \1 { \3 } \2;'),
+    (CFunction('__struct_group'), r'\4'),
 
     #
     # Replace macros
     #
-    # TODO: use NestedMatch for FOO($1, $2, ...) matches
+    # TODO: use CFunction on all FOO($1, $2, ...) matches
     #
-    # it is better to also move those to the NestedMatch logic,
+    # it is better to also move those to the CFunction logic,
     # to ensure that parentheses will be properly matched.
     #
     (KernRe(r'__ETHTOOL_DECLARE_LINK_MODE_MASK\s*\(([^\)]+)\)', re.S),
@@ -185,17 +185,17 @@ function_xforms = [
     (KernRe(r"DECL_BUCKET_PARAMS\s*\(\s*(\S+)\s*,\s*(\S+)\s*\)"), r"\1, \2"),
     (KernRe(r"__no_context_analysis\s*"), ""),
     (KernRe(r"__attribute_const__ +"), ""),
-    (NestedMatch(r"__cond_acquires\s*\("), ""),
-    (NestedMatch(r"__cond_releases\s*\("), ""),
-    (NestedMatch(r"__acquires\s*\("), ""),
-    (NestedMatch(r"__releases\s*\("), ""),
-    (NestedMatch(r"__must_hold\s*\("), ""),
-    (NestedMatch(r"__must_not_hold\s*\("), ""),
-    (NestedMatch(r"__must_hold_shared\s*\("), ""),
-    (NestedMatch(r"__cond_acquires_shared\s*\("), ""),
-    (NestedMatch(r"__acquires_shared\s*\("), ""),
-    (NestedMatch(r"__releases_shared\s*\("), ""),
-    (NestedMatch(r"__attribute__\s*\("), ""),
+    (CFunction("__cond_acquires"), ""),
+    (CFunction("__cond_releases"), ""),
+    (CFunction("__acquires"), ""),
+    (CFunction("__releases"), ""),
+    (CFunction("__must_hold"), ""),
+    (CFunction("__must_not_hold"), ""),
+    (CFunction("__must_hold_shared"), ""),
+    (CFunction("__cond_acquires_shared"), ""),
+    (CFunction("__acquires_shared"), ""),
+    (CFunction("__releases_shared"), ""),
+    (CFunction("__attribute__"), ""),
 ]
 
 #
-- 
2.52.0


  parent reply	other threads:[~2026-01-31 14:25 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-31 14:24 [PATCH v4 00/41] kernel-doc: make it parse new functions and structs Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 01/41] docs: kdoc_re: add support for groups() Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 02/41] docs: kdoc_re: don't go past the end of a line Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 03/41] docs: kdoc_parser: move var transformers to the beginning Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 04/41] docs: kdoc_parser: don't mangle with function defines Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 05/41] docs: kdoc_parser: add functions support for NestedMatch Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 06/41] docs: kdoc_parser: use NestedMatch to handle __attribute__ on functions Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 07/41] docs: kdoc_parser: fix variable regexes to work with size_t Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 08/41] docs: kdoc_parser: fix the default_value logic for variables Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 09/41] docs: kdoc_parser: add some debug for variable parsing Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 10/41] docs: kdoc_parser: don't exclude defaults from prototype Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 11/41] docs: kdoc_parser: fix parser to support multi-word types Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 12/41] docs: kdoc_parser: ignore context analysis and lock attributes Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 13/41] docs: kdoc_parser: add support for LIST_HEAD Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 14/41] docs: kdoc_parser: handle struct member macro VIRTIO_DECLARE_FEATURES(name) Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 15/41] docs: kdoc_re: properly handle strings and escape chars on it Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 16/41] docs: kdoc_re: better show KernRe() at documentation Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 17/41] docs: kdoc_re: don't recompile NestedMatch regex every time Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 18/41] docs: kdoc_re: Change NestedMath args replacement to \0 Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 19/41] docs: kdoc_re: make NestedMatch use KernRe Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 20/41] docs: kdoc_re: add support on NestedMatch for argument replacement Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 21/41] docs: kdoc_parser: better handle struct_group macros Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 22/41] docs: kdoc_re: fix a parse bug on struct page_pool_params Mauro Carvalho Chehab
2026-01-31 14:24 ` [PATCH v4 23/41] docs: kdoc_re: add a helper class to declare C function matches Mauro Carvalho Chehab
2026-01-31 14:24 ` Mauro Carvalho Chehab [this message]
2026-01-31 14:24 ` [PATCH v4 25/41] docs: kdoc_parser: minimize differences with struct_group_tagged Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 26/41] docs: kdoc_parser: move transform lists to a separate file Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 27/41] docs: kdoc_re: don't remove the trailing ";" with NestedMatch Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 28/41] docs: kdoc_re: prevent adding whitespaces on sub replacements Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 29/41] docs: xforms_lists.py: use CFuntion to handle all function macros Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 30/41] docs: kdoc_files: allows the caller to use a different xforms class Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 31/41] docs: kdoc_re: Fix NestedMatch.sub() which causes PDF builds to break Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 32/41] docs: sphinx-build-wrapper: allow -v override -q Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 33/41] tools: sphinx-build-wrapper: improve its help message Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 34/41] docs: kdoc_files: document KernelFiles() ABI Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 35/41] docs: kdoc_output: add optional args to ManOutput class Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 36/41] docs: sphinx-build-wrapper: better handle troff .TH markups Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 37/41] docs: kdoc_output: use a more standard order for .TH on man pages Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 38/41] docs: kdoc_output: describe the class init parameters Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 39/41] docs: kdoc_output: pick a better default for modulename Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 40/41] docs: python: add helpers to run unit tests Mauro Carvalho Chehab
2026-01-31 14:25 ` [PATCH v4 41/41] tools: unittests: add tests for kernel-doc NestedMatch and KernRe Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=06eaea98108e280144f088cbb3f35bf1d2fb5937.1769867953.git.mchehab+huawei@kernel.org \
    --to=mchehab+huawei@kernel.org \
    --cc=aleksandr.loktionov@intel.com \
    --cc=corbet@lwn.net \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®