Skip to content

Commit c4e6d71

Browse files
committed
Support numeric choices
Signed-off-by: Stephen Finucane <[email protected]> Fixes: #75
1 parent 934c203 commit c4e6d71

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

sphinx_click/ext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def _write_opts(opts):
8888
)
8989

9090
if isinstance(opt.type, click.Choice):
91-
extras.append(':options: %s' % ' | '.join(opt.type.choices))
91+
extras.append(':options: %s' % ' | '.join(str(x) for x in opt.type.choices))
9292

9393
if extras:
9494
if out:

tests/test_formatter.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
class CommandTestCase(unittest.TestCase):
99
"""Validate basic ``click.Command`` instances."""
1010

11+
maxDiff = None
12+
1113
def test_no_parameters(self):
1214
"""Validate a `click.Command` with no parameters.
1315
@@ -52,6 +54,12 @@ def test_basic_parameters(self):
5254
help='A sample option with choices',
5355
type=click.Choice(['Option1', 'Option2']),
5456
)
57+
@click.option(
58+
'--numeric-choice',
59+
metavar='<choice>',
60+
help='A sample option with numeric choices',
61+
type=click.Choice([1, 2, 3]),
62+
)
5563
@click.argument('ARG', envvar='ARG')
5664
def foobar(bar):
5765
"""A sample command."""
@@ -86,6 +94,12 @@ def foobar(bar):
8694
8795
:options: Option1 | Option2
8896
97+
.. option:: --numeric-choice <choice>
98+
99+
A sample option with numeric choices
100+
101+
:options: 1 | 2 | 3
102+
89103
.. rubric:: Arguments
90104
91105
.. option:: ARG

0 commit comments

Comments
 (0)