Skip to content

Commit 3354956

Browse files
committed
Fix multiple option with no default as well
1 parent 88e1a84 commit 3354956

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

sphinx_click/ext.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,12 @@ def _write_opts(opts: ty.List[str]) -> str:
110110
# documentation thus needs a manually written string.
111111
extras.append(':default: ``%s``' % show_default)
112112
elif show_default and opt.default is not None:
113-
extras.append(
114-
':default: ``%s``'
115-
% (
116-
', '.join(str(d) for d in opt.default)
117-
if isinstance(opt.default, (list, tuple))
118-
else repr(opt.default),
119-
)
120-
)
113+
if isinstance(opt.default, (list, tuple)):
114+
default = ', '.join(str(d) for d in opt.default)
115+
else:
116+
default = repr(opt.default)
117+
if default.strip():
118+
extras.append(f":default: ``{default}``")
121119

122120
if isinstance(opt.type, click.Choice):
123121
extras.append(':options: %s' % ' | '.join(str(x) for x in opt.type.choices))

0 commit comments

Comments
 (0)