(
ctx: Context,
params: List[Parameter],
formatter: RootCommandHelpTextFormatter,
formatting_options: Dict[str, Dict],
write_rd_overrides: Optional[Dict[str, Any]] = None,
)
| 36 | |
| 37 | @staticmethod |
| 38 | def _format_options( |
| 39 | ctx: Context, |
| 40 | params: List[Parameter], |
| 41 | formatter: RootCommandHelpTextFormatter, |
| 42 | formatting_options: Dict[str, Dict], |
| 43 | write_rd_overrides: Optional[Dict[str, Any]] = None, |
| 44 | ): |
| 45 | write_rd_overrides = write_rd_overrides or {} |
| 46 | for option_heading, options in formatting_options.items(): |
| 47 | opts: List[RowDefinition] = sorted( |
| 48 | [ |
| 49 | CoreCommand.convert_param_to_row_definition( |
| 50 | ctx=ctx, param=param, rank=options.get("option_names", {}).get(param.name, {}).get("rank", 0) |
| 51 | ) |
| 52 | for param in params |
| 53 | if param.name in options.get("option_names", {}).keys() |
| 54 | ], |
| 55 | key=lambda row_def: row_def.rank, |
| 56 | ) |
| 57 | extras = options.get("extras", []) |
| 58 | |
| 59 | # Skip section entirely if no options and no extras |
| 60 | if not opts and not extras: |
| 61 | continue |
| 62 | |
| 63 | with formatter.indented_section(name=option_heading, extra_indents=1): |
| 64 | rows = [] |
| 65 | if extras: |
| 66 | rows.extend(extras) |
| 67 | |
| 68 | if opts: |
| 69 | rows.extend(opts) |
| 70 | |
| 71 | formatter.write_rd(rows, **write_rd_overrides) |
| 72 | |
| 73 | @staticmethod |
| 74 | def convert_param_to_row_definition(ctx: Context, param: Parameter, rank: int): |
no test coverage detected