Commit 6235b3d8 authored by Donald Hunter's avatar Donald Hunter Committed by Jakub Kicinski

tools/net/ynl-gen-rst: Add sub-messages to generated docs

Add a section for sub-messages to the generated .rst files.
Reviewed-by: default avatarBreno Leitao <leitao@debian.org>
Signed-off-by: default avatarDonald Hunter <donald.hunter@gmail.com>
Link: https://lore.kernel.org/r/20231215093720.18774-11-donald.hunter@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 646158f2
...@@ -256,6 +256,24 @@ def parse_attr_sets(entries: List[Dict[str, Any]]) -> str: ...@@ -256,6 +256,24 @@ def parse_attr_sets(entries: List[Dict[str, Any]]) -> str:
return "\n".join(lines) return "\n".join(lines)
def parse_sub_messages(entries: List[Dict[str, Any]]) -> str:
"""Parse sub-message definitions"""
lines = []
for entry in entries:
lines.append(rst_section(entry["name"]))
for fmt in entry["formats"]:
value = fmt["value"]
lines.append(rst_bullet(bold(value)))
for attr in ['fixed-header', 'attribute-set']:
if attr in fmt:
lines.append(rst_fields(attr, fmt[attr], 2))
lines.append("\n")
return "\n".join(lines)
def parse_yaml(obj: Dict[str, Any]) -> str: def parse_yaml(obj: Dict[str, Any]) -> str:
"""Format the whole YAML into a RST string""" """Format the whole YAML into a RST string"""
lines = [] lines = []
...@@ -292,6 +310,11 @@ def parse_yaml(obj: Dict[str, Any]) -> str: ...@@ -292,6 +310,11 @@ def parse_yaml(obj: Dict[str, Any]) -> str:
lines.append(rst_subtitle("Attribute sets")) lines.append(rst_subtitle("Attribute sets"))
lines.append(parse_attr_sets(obj["attribute-sets"])) lines.append(parse_attr_sets(obj["attribute-sets"]))
# Sub-messages
if "sub-messages" in obj:
lines.append(rst_subtitle("Sub-messages"))
lines.append(parse_sub_messages(obj["sub-messages"]))
return "\n".join(lines) return "\n".join(lines)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment