Skip to content

Commit

Permalink
Merge pull request #1008 from sphinx-contrib/cleanup-publish-debug-op…
Browse files Browse the repository at this point in the history
…tions

cleanup publish debug options (format/presentation)
  • Loading branch information
jdknight authored Jul 1, 2024
2 parents 54b1fea + 2fcbbfa commit 87c029a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ Advanced publishing configuration

.. versionchanged:: 2.6

Introduce the ``headers_and_data`` option.
Introduce the ``headers-and-data`` option.

.. warning::

Expand All @@ -1544,7 +1544,7 @@ Advanced publishing configuration
- ``deprecated``: Log warnings when a deprecated API call is used
(*for development purposes*).
- ``headers``: Log requests and responses, including their headers.
- ``headers_and_data``: Log header data along with request/response bodies.
- ``headers-and-data``: Log header data along with request/response bodies.
- ``urllib3``: Enable urllib3 library debugging messages.

An example debugging configuration is as follows:
Expand Down
4 changes: 1 addition & 3 deletions sphinxcontrib/confluencebuilder/config/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,13 @@ def conf_translate(value):
# ##################################################################

# confluence_publish_debug
opts = PublishDebug._member_names_ # pylint: disable=no-member
try:
validator.conf('confluence_publish_debug').bool() # deprecated
except ConfluenceConfigError:
try:
validator.conf('confluence_publish_debug').enum(PublishDebug)
except ConfluenceConfigError as ex:
opts_str = '\n - '.join(opts)
raise ConfluencePublishDebugConfigError(ex, opts_str) from ex
raise ConfluencePublishDebugConfigError(ex) from ex

# ##################################################################

Expand Down
3 changes: 2 additions & 1 deletion sphinxcontrib/confluencebuilder/config/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def apply_defaults(builder):
if publish_debug is True:
conf.confluence_publish_debug = PublishDebug.urllib3
elif isinstance(publish_debug, str) and publish_debug:
conf.confluence_publish_debug = PublishDebug[publish_debug.lower()]
raw_debug = publish_debug.replace('-', '_').lower()
conf.confluence_publish_debug = PublishDebug[raw_debug]
else:
conf.confluence_publish_debug = PublishDebug.none

Expand Down
7 changes: 5 additions & 2 deletions sphinxcontrib/confluencebuilder/config/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,18 @@ def __init__(self):


class ConfluencePublishDebugConfigError(ConfluenceConfigError):
def __init__(self, msg, opts):
def __init__(self, msg):
super().__init__(f'''\
{msg}
The option 'confluence_publish_debug' has been configured to enable publish
debugging. Accepted values include:
- all
- {opts}
- deprecated
- headers
- headers-and-data
- urllib3
''')


Expand Down
2 changes: 1 addition & 1 deletion sphinxcontrib/confluencebuilder/config/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def enum(self, etype):

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

0 comments on commit 87c029a

Please sign in to comment.