@@ -87,6 +87,12 @@ def render_list(l, markdown_help, settings=None):
8787 return all_children
8888
8989
90+ def format_choices (choices ):
91+ if isinstance (choices , range ) and choices .step == 1 :
92+ return f'Value range: { choices .start } to { choices .stop } \n '
93+ return f'Possible choices: { ", " .join (str (c ) for c in choices )} \n '
94+
95+
9096def _is_suppressed (item : str | None ) -> bool :
9197 """Return whether item should not be printed."""
9298 if item is None :
@@ -157,9 +163,7 @@ def print_action_groups(
157163 # Build the help text
158164 arg = []
159165 if 'choices' in entry :
160- arg .append (
161- f"Possible choices: { ', ' .join (str (c ) for c in entry ['choices' ])} \n "
162- )
166+ arg .append (format_choices (entry ['choices' ]))
163167 if 'help' in entry :
164168 arg .append (entry ['help' ])
165169 if not _is_suppressed (entry ['default' ]):
@@ -400,9 +404,7 @@ def _format_positional_arguments(self, parser_info):
400404 elif 'choices' not in arg :
401405 arg_items .append (nodes .paragraph (text = 'Undocumented' ))
402406 if 'choices' in arg :
403- arg_items .append (
404- nodes .paragraph (text = 'Possible choices: ' + ', ' .join (arg ['choices' ]))
405- )
407+ arg_items .append (format_choices (arg ['choices' ]))
406408 items .append (
407409 nodes .option_list_item (
408410 '' ,
@@ -432,9 +434,7 @@ def _format_optional_arguments(self, parser_info):
432434 elif 'choices' not in opt :
433435 opt_items .append (nodes .paragraph (text = 'Undocumented' ))
434436 if 'choices' in opt :
435- opt_items .append (
436- nodes .paragraph (text = 'Possible choices: ' + ', ' .join (opt ['choices' ]))
437- )
437+ arg_items .append (format_choices (opt ['choices' ]))
438438 items .append (
439439 nodes .option_list_item (
440440 '' ,
0 commit comments