click-contrib / sphinx-click

A Sphinx plugin to automatically document click-based applications
MIT License
212 stars 57 forks source link

Fix rendering of string-valued defaults #137

Closed hoodmane closed 2 months ago

hoodmane commented 2 months ago

Summary

Before this patch, string defaults are formatted without quotes around them. However, if the default is a tuple or list of strings, quotes will be included:

default="a" ==> :default: ``a``
default=("a",) ==> :default: ``('a')``

This is a slightly annoying inconsistency, and leads to potential for confusion between default="0" and default=0. Most bothersome is that in the case of an empty string we get:

:default: ````

Which makes docutils angry:

CRITICAL: Unexpected section title or transition: ````

This fixes the trouble by formatting the repr of the default.

On top of #136.

Tasks

hoodmane commented 2 months ago

There's still a CRITICAL: Unexpected section title or transition if a multiple option has an empty list default.

stephenfin commented 2 months ago

You can rebase this now that #136 is merged too.

hoodmane commented 2 months ago

Thanks for maintaining sphinx-click @stephenfin!