diff --git a/sphinx_click/ext.py b/sphinx_click/ext.py index 32903eb..f1ddd36 100644 --- a/sphinx_click/ext.py +++ b/sphinx_click/ext.py @@ -88,7 +88,7 @@ def _write_opts(opts): ) if isinstance(opt.type, click.Choice): - extras.append(':options: %s' % ' | '.join(opt.type.choices)) + extras.append(':options: %s' % ' | '.join(str(x) for x in opt.type.choices)) if extras: if out: diff --git a/tests/test_formatter.py b/tests/test_formatter.py index f6c7a7a..43496e8 100644 --- a/tests/test_formatter.py +++ b/tests/test_formatter.py @@ -8,6 +8,8 @@ class CommandTestCase(unittest.TestCase): """Validate basic ``click.Command`` instances.""" + maxDiff = None + def test_no_parameters(self): """Validate a `click.Command` with no parameters. @@ -52,6 +54,12 @@ def test_basic_parameters(self): help='A sample option with choices', type=click.Choice(['Option1', 'Option2']), ) + @click.option( + '--numeric-choice', + metavar='', + help='A sample option with numeric choices', + type=click.Choice([1, 2, 3]), + ) @click.argument('ARG', envvar='ARG') def foobar(bar): """A sample command.""" @@ -86,6 +94,12 @@ def foobar(bar): :options: Option1 | Option2 + .. option:: --numeric-choice + + A sample option with numeric choices + + :options: 1 | 2 | 3 + .. rubric:: Arguments .. option:: ARG