Skip to content

Commit 3336467

Browse files
committed
Add deprecation warning for html_logo
1 parent bf78285 commit 3336467

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/pydata_sphinx_theme/__init__.py

+25-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@
2929
logger = logging.getLogger(__name__)
3030

3131

32-
def update_config(app):
32+
def update_config_deprecations(app):
33+
"""Update deprecated config values and raise warnings.
34+
35+
Each section should contain a comment describing which release
36+
to remove the deprecated value entirely.
37+
"""
3338
theme_options = app.config.html_theme_options
39+
config = app.config
3440

3541
# DEPRECATE >= v0.10
3642
if theme_options.get("search_bar_position") == "navbar":
@@ -43,27 +49,41 @@ def update_config(app):
4349
if theme_options.get("left_sidebar_end"):
4450
theme_options["primary_sidebar_end"] = theme_options.get("left_sidebar_end")
4551
logger.warning(
46-
"The configuration `left_sidebar_end` is deprecated."
52+
"The configuration `left_sidebar_end` is deprecated. "
4753
"Use `primary_sidebar_end`"
4854
)
4955

56+
# DEPRECATE >= 0.13
5057
if theme_options.get("logo_text"):
5158
logo = theme_options.get("logo", {})
5259
logo["text"] = theme_options.get("logo_text")
5360
theme_options["logo"] = logo
5461
logger.warning(
55-
"The configuration `logo_text` is deprecated." "Use `'logo': {'text': }`."
62+
"The configuration `logo_text` is deprecated. " "Use `'logo': {'text': }`."
5663
)
5764

65+
# DEPRECATE >= 0.13
5866
if theme_options.get("page_sidebar_items"):
5967
theme_options["secondary_sidebar_items"] = theme_options.get(
6068
"page_sidebar_items"
6169
)
6270
logger.warning(
63-
"The configuration `page_sidebar_items` is deprecated."
71+
"The configuration `page_sidebar_items` is deprecated. "
6472
"Use `secondary_sidebar_items`."
6573
)
6674

75+
# DEPRECATE >= 0.14
76+
if hasattr(config, "html_logo"):
77+
config.__dict__["html_logo_url"] = config.html_logo
78+
logger.warning(
79+
"Config value `html_logo` is deprecated. " "Use `html_logo_url` instead."
80+
)
81+
82+
83+
def update_config(app):
84+
"""Update configuration values with defaults and validation."""
85+
theme_options = app.config.html_theme_options
86+
6787
# Validate icon links
6888
if not isinstance(theme_options.get("icon_links", []), list):
6989
raise ExtensionError(
@@ -1048,6 +1068,7 @@ def setup(app):
10481068
app.set_translator("readthedocs", BootstrapHTML5Translator, override=True)
10491069
app.set_translator("readthedocsdirhtml", BootstrapHTML5Translator, override=True)
10501070

1071+
app.connect("builder-inited", update_config_deprecations)
10511072
app.connect("builder-inited", update_config)
10521073
app.connect("html-page-context", setup_edit_url)
10531074
app.connect("html-page-context", add_toctree_functions)

0 commit comments

Comments
 (0)