Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup publish debug options (format/presentation) #1008

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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