Lines Matching +full:sub +full:- +full:message

2 # SPDX-License-Identifier: GPL-2.0
3 # -*- coding: utf-8; mode: python -*-
34 def headroom(level: int) -> str:
39 def bold(text: str) -> str:
44 def inline(text: str) -> str:
49 def sanitize(text: str) -> str:
55 def rst_fields(key: str, value: str, level: int = 0) -> str:
60 def rst_definition(key: str, value: Any, level: int = 0) -> str:
65 def rst_paragraph(paragraph: str, level: int = 0) -> str:
70 def rst_bullet(item: str, level: int = 0) -> str:
72 return headroom(level) + f"- {item}"
75 def rst_subsection(title: str) -> str:
76 """Add a sub-section to the document"""
77 return f"{title}\n" + "-" * len(title)
80 def rst_subsubsection(title: str) -> str:
81 """Add a sub-sub-section to the document"""
85 def rst_section(namespace: str, prefix: str, title: str) -> str:
87 return f".. _{namespace}-{prefix}-{title}:\n\n{title}\n" + "=" * len(title)
90 def rst_subtitle(title: str) -> str:
92 return "\n" + "-" * len(title) + f"\n{title}\n" + "-" * len(title) + "\n\n"
95 def rst_title(title: str) -> str:
100 def rst_list_inline(list_: List[str], level: int = 0) -> str:
105 def rst_ref(namespace: str, prefix: str, name: str) -> str:
108 'fixed-header': 'definition',
109 'nested-attributes': 'attribute-set',
113 return f":ref:`{namespace}-{prefix}-{name}`"
116 def rst_header() -> str:
120 lines.append(rst_paragraph(".. SPDX-License-Identifier: GPL-2.0"))
121 lines.append(rst_paragraph(".. NOTE: This document was auto-generated.\n\n"))
126 def rst_toctree(maxdepth: int = 2) -> str:
136 def rst_label(title: str) -> str:
145 def parse_mcast_group(mcast_group: List[Dict[str, Any]]) -> str:
154 def parse_do(do_dict: Dict[str, Any], level: int = 0) -> str:
167 def parse_do_attributes(attrs: Dict[str, Any], level: int = 0) -> str:
176 def parse_operations(operations: List[Dict[str, Any]], namespace: str) -> str:
179 linkable = ["fixed-header", "attribute-set"]
210 def parse_entries(entries: List[Dict[str, Any]], level: int) -> str:
235 def parse_definitions(defs: Dict[str, Any], namespace: str) -> str:
238 ignored = ["render-max"] # This is not printed
260 def parse_attr_sets(entries: List[Dict[str, Any]], namespace: str) -> str:
261 """Parse attribute from attribute-set"""
263 linkable = ["enum", "nested-attributes", "struct", "sub-message"]
268 lines.append(rst_section(namespace, 'attribute-set', entry["name"]))
291 def parse_sub_messages(entries: List[Dict[str, Any]], namespace: str) -> str:
292 """Parse sub-message definitions"""
296 lines.append(rst_section(namespace, 'sub-message', entry["name"]))
301 for attr in ['fixed-header', 'attribute-set']:
311 def parse_yaml(obj: Dict[str, Any]) -> str:
335 if "mcast-groups" in obj:
337 lines.append(parse_mcast_group(obj["mcast-groups"]["list"]))
345 if "attribute-sets" in obj:
347 lines.append(parse_attr_sets(obj["attribute-sets"], family))
349 # Sub-messages
350 if "sub-messages" in obj:
351 lines.append(rst_subtitle("Sub-messages"))
352 lines.append(parse_sub_messages(obj["sub-messages"], family))
361 def parse_arguments() -> argparse.Namespace:
365 parser.add_argument("-v", "--verbose", action="store_true")
366 parser.add_argument("-o", "--output", help="Output file name")
371 "-x", "--index", action="store_true", help="Generate the index page"
373 group.add_argument("-i", "--input", help="YAML file name")
382 sys.exit(-1)
386 sys.exit(-1)
394 def parse_yaml_file(filename: str) -> str:
395 """Transform the YAML specified by filename into a rst-formmated string"""
396 with open(filename, "r", encoding="utf-8") as spec_file:
403 def write_to_rstfile(content: str, filename: str) -> None:
407 with open(filename, "w", encoding="utf-8") as rst_file:
411 def generate_main_index_rst(output: str) -> None:
431 def main() -> None:
443 sys.exit(-1)