sphinx-click icon indicating copy to clipboard operation
sphinx-click copied to clipboard

Fix rendering of string-valued defaults

Open hoodmane opened this issue 1 year ago • 1 comments

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

  • [x] Added unit tests
  • [x] Added documentation for new features (where applicable)
  • [x] Added release notes (using reno)
  • [x] Ran test suite and style checks and built documentation (tox)

hoodmane avatar May 09 '24 14:05 hoodmane

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

hoodmane avatar May 09 '24 15:05 hoodmane

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

stephenfin avatar May 14 '24 12:05 stephenfin

Thanks for maintaining sphinx-click @stephenfin!

hoodmane avatar May 16 '24 13:05 hoodmane