Skip to content

Commit 95d99c8

Browse files
donaldhNipaLocal
authored andcommitted
tools/net/ynl-gen-rst: Add sub-messages to generated docs
Add a section for sub-messages to the generated .rst files. Signed-off-by: Donald Hunter <[email protected]> Reviewed-by: Breno Leitao <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent dc41cc2 commit 95d99c8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tools/net/ynl/ynl-gen-rst.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,24 @@ def parse_attr_sets(entries: List[Dict[str, Any]]) -> str:
256256
return "\n".join(lines)
257257

258258

259+
def parse_sub_messages(entries: List[Dict[str, Any]]) -> str:
260+
"""Parse sub-message definitions"""
261+
lines = []
262+
263+
for entry in entries:
264+
lines.append(rst_section(entry["name"]))
265+
for fmt in entry["formats"]:
266+
value = fmt["value"]
267+
268+
lines.append(rst_bullet(bold(value)))
269+
for attr in ['fixed-header', 'attribute-set']:
270+
if attr in fmt:
271+
lines.append(rst_fields(attr, fmt[attr], 2))
272+
lines.append("\n")
273+
274+
return "\n".join(lines)
275+
276+
259277
def parse_yaml(obj: Dict[str, Any]) -> str:
260278
"""Format the whole YAML into a RST string"""
261279
lines = []
@@ -292,6 +310,11 @@ def parse_yaml(obj: Dict[str, Any]) -> str:
292310
lines.append(rst_subtitle("Attribute sets"))
293311
lines.append(parse_attr_sets(obj["attribute-sets"]))
294312

313+
# Sub-messages
314+
if "sub-messages" in obj:
315+
lines.append(rst_subtitle("Sub-messages"))
316+
lines.append(parse_sub_messages(obj["sub-messages"]))
317+
295318
return "\n".join(lines)
296319

297320

0 commit comments

Comments
 (0)