Skip to content

Commit fa57266

Browse files
donaldhkuba-moo
authored andcommitted
tools: ynl: render event op docs correctly
The docs for YNL event ops currently render raw python structs. For example in: https://docs.kernel.org/netlink/specs/ethtool.html#cable-test-ntf event: {‘attributes’: [‘header’, ‘status’, ‘nest’], ‘__lineno__’: 2385} Handle event ops correctly and render their op attributes: event: attributes: [header, status] Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20260112153436.75495-1-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent ffe4ccd commit fa57266

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tools/net/ynl/pyynl/lib/doc_generator.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ def parse_do(self, do_dict: Dict[str, Any], level: int = 0) -> str:
166166
continue
167167
lines.append(self.fmt.rst_paragraph(self.fmt.bold(key), level + 1))
168168
if key in ['request', 'reply']:
169-
lines.append(self.parse_do_attributes(do_dict[key], level + 1) + "\n")
169+
lines.append(self.parse_op_attributes(do_dict[key], level + 1) + "\n")
170170
else:
171171
lines.append(self.fmt.headroom(level + 2) + do_dict[key] + "\n")
172172

173173
return "\n".join(lines)
174174

175-
def parse_do_attributes(self, attrs: Dict[str, Any], level: int = 0) -> str:
175+
def parse_op_attributes(self, attrs: Dict[str, Any], level: int = 0) -> str:
176176
"""Parse 'attributes' section"""
177177
if "attributes" not in attrs:
178178
return ""
@@ -184,7 +184,7 @@ def parse_do_attributes(self, attrs: Dict[str, Any], level: int = 0) -> str:
184184

185185
def parse_operations(self, operations: List[Dict[str, Any]], namespace: str) -> str:
186186
"""Parse operations block"""
187-
preprocessed = ["name", "doc", "title", "do", "dump", "flags"]
187+
preprocessed = ["name", "doc", "title", "do", "dump", "flags", "event"]
188188
linkable = ["fixed-header", "attribute-set"]
189189
lines = []
190190

@@ -217,6 +217,9 @@ def parse_operations(self, operations: List[Dict[str, Any]], namespace: str) ->
217217
if "dump" in operation:
218218
lines.append(self.fmt.rst_paragraph(":dump:", 0))
219219
lines.append(self.parse_do(operation["dump"], 0))
220+
if "event" in operation:
221+
lines.append(self.fmt.rst_paragraph(":event:", 0))
222+
lines.append(self.parse_op_attributes(operation["event"], 0))
220223

221224
# New line after fields
222225
lines.append("\n")

0 commit comments

Comments
 (0)