[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250820131023.855661-2-o.rempel@pengutronix.de>
Date: Wed, 20 Aug 2025 15:10:21 +0200
From: Oleksij Rempel <o.rempel@...gutronix.de>
To: Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Florian Fainelli <f.fainelli@...il.com>,
Maxime Chevallier <maxime.chevallier@...tlin.com>,
Kory Maincent <kory.maincent@...tlin.com>,
Lukasz Majewski <lukma@...x.de>,
Jonathan Corbet <corbet@....net>,
Donald Hunter <donald.hunter@...il.com>,
Vadim Fedorenko <vadim.fedorenko@...ux.dev>,
Jiri Pirko <jiri@...nulli.us>,
Vladimir Oltean <vladimir.oltean@....com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>
Cc: Oleksij Rempel <o.rempel@...gutronix.de>,
kernel@...gutronix.de,
linux-kernel@...r.kernel.org,
netdev@...r.kernel.org,
Russell King <linux@...linux.org.uk>,
Divya.Koppera@...rochip.com,
Sabrina Dubroca <sd@...asysnail.net>,
Stanislav Fomichev <sdf@...ichev.me>
Subject: [PATCH net-next v3 1/3] tools: ynl-gen: generate kdoc for attribute enums
Parse 'doc' strings from the YAML spec to generate kernel-doc comments
for the corresponding enums in the C UAPI header, making the headers
self-documenting.
The generated comment format depends on the documentation available:
- a full kdoc block ('/**') with @member tags is used if attributes are
documented
- a simple block comment ('/*') is used if only the set itself has a doc
string
Signed-off-by: Oleksij Rempel <o.rempel@...gutronix.de>
---
tools/net/ynl/pyynl/ynl_gen_c.py | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index ef032e17fec4..d7634560c461 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -3225,6 +3225,29 @@ def render_uapi(family, cw):
if attr_set.subset_of:
continue
+ # Write kdoc for attribute-set enums
+ has_main_doc = 'doc' in attr_set.yaml and attr_set.yaml['doc']
+ has_attr_doc = any('doc' in attr for _, attr in attr_set.items())
+
+ if has_main_doc or has_attr_doc:
+ if has_attr_doc:
+ cw.p('/**')
+ # Construct the main description line for the enum
+ doc_line = f"enum {c_lower(family.ident_name + '_' + attr_set.name)}"
+ if has_main_doc:
+ doc_line += f" - {attr_set.yaml['doc']}"
+ cw.write_doc_line(doc_line)
+
+ # Write documentation for each attribute (enum member)
+ for _, attr in attr_set.items():
+ if 'doc' in attr and attr['doc']:
+ doc = f"@{attr.enum_name}: {attr['doc']}"
+ cw.write_doc_line(doc)
+ else: # Only has main doc, use a simpler comment block
+ cw.p('/*')
+ cw.write_doc_line(attr_set.yaml['doc'], indent=False)
+ cw.p(' */')
+
max_value = f"({attr_set.cnt_name} - 1)"
val = 0
--
2.39.5
Powered by blists - more mailing lists