Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Donald Hunter and committed by
Jakub Kicinski
fa572669 ffe4ccd3

+6 -3
+6 -3
tools/net/ynl/pyynl/lib/doc_generator.py
··· 166 166 continue 167 167 lines.append(self.fmt.rst_paragraph(self.fmt.bold(key), level + 1)) 168 168 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") 170 170 else: 171 171 lines.append(self.fmt.headroom(level + 2) + do_dict[key] + "\n") 172 172 173 173 return "\n".join(lines) 174 174 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: 176 176 """Parse 'attributes' section""" 177 177 if "attributes" not in attrs: 178 178 return "" ··· 184 184 185 185 def parse_operations(self, operations: List[Dict[str, Any]], namespace: str) -> str: 186 186 """Parse operations block""" 187 - preprocessed = ["name", "doc", "title", "do", "dump", "flags"] 187 + preprocessed = ["name", "doc", "title", "do", "dump", "flags", "event"] 188 188 linkable = ["fixed-header", "attribute-set"] 189 189 lines = [] 190 190 ··· 217 217 if "dump" in operation: 218 218 lines.append(self.fmt.rst_paragraph(":dump:", 0)) 219 219 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)) 220 223 221 224 # New line after fields 222 225 lines.append("\n")