Skip to content

Commit ea28688

Browse files
committed
cleanup publish debug options (format/presentation)
Updating the configuration handling of publish debugging options to promote the uses of dashes of underscores (e.g. `headers-and-data` over `headers_and_data`). Both values are still accepted, but the dash variant will be the value shown in documentation. This commit also adjusts the configuration check to explicitly list supported options. The previous use of populating values from the enumeration does not work for all desired entries. Best to list the explicit values we want to inform a user on. Signed-off-by: James Knight <[email protected]>
1 parent 54b1fea commit ea28688

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

sphinxcontrib/confluencebuilder/config/checks.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,15 +533,13 @@ def conf_translate(value):
533533
# ##################################################################
534534

535535
# confluence_publish_debug
536-
opts = PublishDebug._member_names_ # pylint: disable=no-member
537536
try:
538537
validator.conf('confluence_publish_debug').bool() # deprecated
539538
except ConfluenceConfigError:
540539
try:
541540
validator.conf('confluence_publish_debug').enum(PublishDebug)
542541
except ConfluenceConfigError as ex:
543-
opts_str = '\n - '.join(opts)
544-
raise ConfluencePublishDebugConfigError(ex, opts_str) from ex
542+
raise ConfluencePublishDebugConfigError(ex) from ex
545543

546544
# ##################################################################
547545

sphinxcontrib/confluencebuilder/config/defaults.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ def apply_defaults(builder):
107107
if publish_debug is True:
108108
conf.confluence_publish_debug = PublishDebug.urllib3
109109
elif isinstance(publish_debug, str) and publish_debug:
110-
conf.confluence_publish_debug = PublishDebug[publish_debug.lower()]
110+
raw_debug = publish_debug.replace('-', '_').lower()
111+
conf.confluence_publish_debug = PublishDebug[raw_debug]
111112
else:
112113
conf.confluence_publish_debug = PublishDebug.none
113114

sphinxcontrib/confluencebuilder/config/exceptions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,18 @@ def __init__(self):
229229

230230

231231
class ConfluencePublishDebugConfigError(ConfluenceConfigError):
232-
def __init__(self, msg, opts):
232+
def __init__(self, msg):
233233
super().__init__(f'''\
234234
{msg}
235235
236236
The option 'confluence_publish_debug' has been configured to enable publish
237237
debugging. Accepted values include:
238238
239239
- all
240-
- {opts}
240+
- deprecated
241+
- headers
242+
- headers-and-data
243+
- urllib3
241244
''')
242245

243246

sphinxcontrib/confluencebuilder/config/validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def enum(self, etype):
218218

219219
if value is not None and not isinstance(value, etype):
220220
try:
221-
value = etype[value.lower()]
221+
value = etype[value.replace('-', '_').lower()]
222222
except (AttributeError, KeyError) as ex:
223223
msg = f'{self.key} is not an enumeration ({etype.__name__})'
224224
raise ConfluenceConfigError(msg) from ex

0 commit comments

Comments
 (0)