(command: click.Command, opt: click.Option, flags: list[str])
| 154 | |
| 155 | |
| 156 | def format_option(command: click.Command, opt: click.Option, flags: list[str]) -> StrGenerator: |
| 157 | if isinstance(opt, click.Argument): |
| 158 | yield f"\n.. option:: {opt.name}\n" |
| 159 | return |
| 160 | yield "\n.. option:: {}\n".format( |
| 161 | ", ".join( |
| 162 | arg if opt.metavar is None else f"{arg} {opt.metavar}" |
| 163 | for arg in sorted(opt.opts, reverse=True) |
| 164 | ) |
| 165 | ) |
| 166 | |
| 167 | help = ( |
| 168 | OPTION_HELP_OVERRIDES[command.name][opt.name] |
| 169 | if command.name in OPTION_HELP_OVERRIDES and opt.name in OPTION_HELP_OVERRIDES[command.name] |
| 170 | else opt.help.strip() |
| 171 | ) |
| 172 | |
| 173 | # TODO: Make metavars link to the option as well. |
| 174 | help, default = extract_default_value(help) |
| 175 | help = transform_add_option_refs(help, flags) |
| 176 | |
| 177 | yield f"\n {help}\n" |
| 178 | if default is not None: |
| 179 | yield f"\n Default: ``{default}``\n" |
| 180 | |
| 181 | |
| 182 | def generate_command_help( |
no test coverage detected