diff options
author | Donald Hunter | 2023-12-15 09:37:17 +0000 |
---|---|---|
committer | Jakub Kicinski | 2023-12-18 14:39:44 -0800 |
commit | 6235b3d8bc3f81e81561c151237503fcf7868a98 (patch) | |
tree | 488c1cb92dfc7596d87aeebc259ef0e0c2241340 /tools | |
parent | 646158f20cbc4f93f5318f8adee0f3f5b92ff6a8 (diff) |
tools/net/ynl-gen-rst: Add sub-messages to generated docs
Add a section for sub-messages to the generated .rst files.
Reviewed-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://lore.kernel.org/r/20231215093720.18774-11-donald.hunter@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/net/ynl/ynl-gen-rst.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/net/ynl/ynl-gen-rst.py b/tools/net/ynl/ynl-gen-rst.py index 8c62e040df5d..6825db92c899 100755 --- a/tools/net/ynl/ynl-gen-rst.py +++ b/tools/net/ynl/ynl-gen-rst.py @@ -256,6 +256,24 @@ def parse_attr_sets(entries: List[Dict[str, Any]]) -> str: 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: """Format the whole YAML into a RST string""" lines = [] @@ -292,6 +310,11 @@ def parse_yaml(obj: Dict[str, Any]) -> str: lines.append(rst_subtitle("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) |