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>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: [PATCH 07/23] tools: docs: parse_data_structs.py: add namespace support
Date: Wed, 1 Oct 2025 16:49:30 +0200 [thread overview]
Message-ID: <cc27ec60ceb3bdac4197fb7266d2df8155edacda.1759329363.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1759329363.git.mchehab+huawei@kernel.org>
C domain supports a ".. c:namespace::" tag that allows setting a
symbol namespace. This is used within the kernel to avoid warnings
about duplicated symbols. This is specially important for syscalls,
as each subsystem may have their own documentation for them.
This is specially true for ioctl.
When such tag is used, all C domain symbols have c++ style,
e.g. they'll become "{namespace}.{reference}".
Allow specifying C namespace at the exception files, avoiding
the need of override rules for every symbol.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
tools/docs/lib/parse_data_structs.py | 43 +++++++++++++++++++++-------
1 file changed, 32 insertions(+), 11 deletions(-)
diff --git a/tools/docs/lib/parse_data_structs.py b/tools/docs/lib/parse_data_structs.py
index cbdbf7dfe785..0d537e989ea7 100755
--- a/tools/docs/lib/parse_data_structs.py
+++ b/tools/docs/lib/parse_data_structs.py
@@ -53,11 +53,19 @@ class ParseDataStructs:
replace <type> <old_symbol> <new_reference>
- Replaces how old_symbol with a new reference. The new_reference can be:
+ Replaces how old_symbol with a new reference. The new_reference can be:
+
- A simple symbol name;
- A full Sphinx reference.
- On both cases, <type> can be:
+ 3. Namespace rules
+
+ namespace <namespace>
+
+ Sets C namespace to be used during cross-reference generation. Can
+ be overridden by replace rules.
+
+ On ignore and replace rules, <type> can be:
- ioctl: for defines that end with _IO*, e.g. ioctl definitions
- define: for other defines
- symbol: for symbols defined within enums;
@@ -71,6 +79,8 @@ class ParseDataStructs:
ignore ioctl VIDIOC_ENUM_FMT
replace ioctl VIDIOC_DQBUF vidioc_qbuf
replace define V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ :c:type:`v4l2_event_motion_det`
+
+ namespace MC
"""
# Parser regexes with multiple ways to capture enums and structs
@@ -140,6 +150,7 @@ class ParseDataStructs:
self.symbols = {}
+ self.namespace = None
self.ignore = []
self.replace = []
@@ -173,6 +184,11 @@ class ParseDataStructs:
match.group(3)))
continue
+ match = re.match(r"^namespace\s+(\S+)", line)
+ if match:
+ self.namespace = match.group(1)
+ continue
+
sys.exit(f"{name}:{ln}: invalid line: {line}")
def apply_exceptions(self):
@@ -237,18 +253,23 @@ class ParseDataStructs:
ref_type = defs.get("ref_type")
# Determine ref_link based on symbol type
- if ref_type:
- if symbol_type == "enum":
- ref_link = f"{ref_type}:`{symbol}`"
- else:
- if not ref_name:
- ref_name = symbol.lower()
+ if ref_type or self.namespace:
+ if not ref_name:
+ ref_name = symbol.lower()
- # c-type references don't support hash
- if ref_type == ":ref" and replace_underscores:
- ref_name = ref_name.replace("_", "-")
+ # c-type references don't support hash
+ if ref_type == ":ref" and replace_underscores:
+ ref_name = ref_name.replace("_", "-")
+ # C domain references may have namespaces
+ if ref_type.startswith(":c:"):
+ if self.namespace:
+ ref_name = f"{self.namespace}.{ref_name}"
+
+ if ref_type:
ref_link = f"{ref_type}:`{symbol} <{ref_name}>`"
+ else:
+ ref_link = f"`{symbol} <{ref_name}>`"
else:
ref_link = symbol
--
2.51.0
next prev parent reply other threads:[~2025-10-01 14:49 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-01 14:49 [PATCH 00/23] Fix media uAPI cross references Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 01/23] tools: docs: parse_data_structs.py: drop contents header Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 02/23] tools: docs: parse_data_structs.py: output a line number Mauro Carvalho Chehab
2025-10-20 10:46 ` Hans Verkuil
2025-10-20 11:56 ` Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 03/23] docs: kernel_include.py: fix line numbers for TOC Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 04/23] docs: kernel_include.py: propose alternatives Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 05/23] tools: docs: parse_data_structs: make process_exceptions two stages Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 06/23] tools: docs: parse_data_structs.py: get rid of process_exceptions() Mauro Carvalho Chehab
2025-10-01 14:49 ` Mauro Carvalho Chehab [this message]
2025-10-01 14:49 ` [PATCH 08/23] tools: docs: parse_data_structs.py: accept more reftypes Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 09/23] docs: media: dvb: use TOC instead of file contents at headers Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 10/23] docs: media: dvb: enable warnings for most headers Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 11/23] docs: media: rc: use TOC instead of file contents for LIRC header Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 12/23] docs: media: mediactl: use TOC instead of file contents Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 13/23] docs: kernel_include.py: use get_close_matches() to propose alternatives Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 14/23] docs: media: add missing c namespace to V4L headers Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 15/23] docs: media: videodev2.h.rst.exceptions: fix namespace on refs Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 16/23] media: docs: add a missing reference for VIDIOC_QUERY_CTRL Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 17/23] media: docs: videodev2.h.rst.exceptions: ignore struct __kernel_v4l2_timeval Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 18/23] media: docs: add some C domain missing references Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 19/23] docs: cec: cec.h.rst.exceptions: fix broken references from cec.h Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 20/23] docs: cec: show broken xrefs and show TOC instead of cec.h content Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 21/23] docs: media: dmx_types: place kerneldoc at the right namespace Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 22/23] docs: media: dvb: headers: warn about broken cross references Mauro Carvalho Chehab
2025-10-01 14:49 ` [PATCH 23/23] docs: media: dvb: fix dmx.h.rst.exceptions Mauro Carvalho Chehab
2025-10-17 20:08 ` [PATCH 00/23] Fix media uAPI cross references Jonathan Corbet
2025-10-18 10:53 ` Mauro Carvalho Chehab
2025-10-20 10:51 ` Hans Verkuil
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=cc27ec60ceb3bdac4197fb7266d2df8155edacda.1759329363.git.mchehab+huawei@kernel.org \
--to=mchehab+huawei@kernel.org \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.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®