Skip to content

Commit

Permalink
Handle iterables of iterables as default values
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #91
  • Loading branch information
stephenfin committed Jan 27, 2022
1 parent d53cd26 commit 6aeee37
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sphinx_click/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _write_opts(opts):
extras.append(
':default: %s'
% (
', '.join('%s' % d for d in opt.default)
', '.join(str(d) for d in opt.default)
if isinstance(opt.default, (list, tuple))
else opt.default,
)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ def test_defaults(self):
default=lambda: None,
show_default='Something computed at runtime',
)
@click.option(
'--group',
default=[('foo', 'bar')],
nargs=2,
type=click.Tuple([str, str]),
multiple=True,
show_default=True,
)
def foobar(bar):
"""A sample command."""
pass
Expand All @@ -195,6 +203,10 @@ def foobar(bar):
.. option:: --param <param>
:default: Something computed at runtime
.. option:: --group <group>
:default: ('foo', 'bar')
"""
).lstrip(),
'\n'.join(output),
Expand Down

0 comments on commit 6aeee37

Please sign in to comment.