Skip to content

Commit

Permalink
Fix _Opt deprecation warnings (#313)
Browse files Browse the repository at this point in the history
* Fix _Opt deprecation warnings

* Update extension.py

---------

Co-authored-by: Manuel Kaufmann <[email protected]>
  • Loading branch information
Zac-HD and humitos authored Dec 2, 2024
1 parent a2f83db commit f702d3e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions hoverxref/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ def copy_asset_files(app, exception):
if exception is None: # build succeeded

context = {}
for attr in app.config.values:
for attr, opt in app.config.values.items():
if attr.startswith('hoverxref_'):
# First, add the default values to the context
context[attr] = app.config.values[attr][0]
context[attr] = opt.default if hasattr(opt, "default") else opt[0]

for attr in dir(app.config):
if attr.startswith('hoverxref_'):
Expand Down Expand Up @@ -264,7 +264,8 @@ def setup_theme(app, exception):
"""
css_file = None
theme = app.config.html_theme
default, rebuild, types = app.config.values.get('hoverxref_modal_class')
opt = app.config.values['hoverxref_modal_class']
default = opt.default if hasattr(opt, "default") else opt[0]
if theme == 'sphinx_material':
if app.config.hoverxref_modal_class == default:
app.config.hoverxref_modal_class = 'md-typeset'
Expand Down Expand Up @@ -296,8 +297,8 @@ def setup_assets_policy(app, exception):

def deprecated_configs_warning(app, exception):
"""Log warning message if old configs are used."""
default, rebuild, types = app.config.values.get('hoverxref_tooltip_api_host')
if app.config.hoverxref_tooltip_api_host != default:
opt = app.config.values['hoverxref_tooltip_api_host']
if app.config.hoverxref_tooltip_api_host != (opt.default if hasattr(opt, "default") else opt[0]):
message = '"hoverxref_tooltip_api_host" is deprecated and replaced by "hoverxref_api_host".'
logger.warning(message)
app.config.hoverxref_api_host = app.config.hoverxref_tooltip_api_host
Expand Down

0 comments on commit f702d3e

Please sign in to comment.