Skip to content

Commit 6dd4e7b

Browse files
committed
deprecate favicons
1 parent abf3837 commit 6dd4e7b

File tree

4 files changed

+38
-45
lines changed

4 files changed

+38
-45
lines changed

docs/user_guide/branding.rst

+4
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ Add favicons
112112

113113
``pydata_sphinx_theme`` supports the `standard sphinx favicon configuration <https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_favicon>`_, using ``html_favicon``.
114114

115+
.. warning::
116+
117+
The support for complex and multiple favicons will be dropped in version 0.15. Instead you can use the `sphinx-favicon <https://sphinx-favicon.readthedocs.io/en/stable/>`__ extention that provide the same functionalities using more flexible parameters.
118+
115119
Additionally you may add any number of browser- or device-specific favicons of any size.
116120
To do so, use the ``html_theme_options["favicons"]`` configuration key.
117121
The only required argument is ``href``, which can be either an absolute URL (beginning with ``http``) or a local path relative to your ``html_static_path``.

src/pydata_sphinx_theme/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
def update_config(app):
3333
theme_options = app.config.html_theme_options
3434

35+
# DEPRECATE >= v0.15
36+
if theme_options.get("favicons"):
37+
logger.warning(
38+
"Deprecated config `favicons` used."
39+
"The favicon configuration have been droped in favor of the sphinx-favicon extention."
40+
"Please see their documentation for more information."
41+
)
42+
3543
# DEPRECATE >= v0.10
3644
if theme_options.get("search_bar_position") == "navbar":
3745
logger.warning(

tests/sites/deprecated/conf.py

+17
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@
2828
"edit-this-page.html",
2929
"sourcelink.html",
3030
],
31+
"favicons": [
32+
{
33+
"rel": "icon",
34+
"sizes": "16x16",
35+
"href": "https://secure.example.com/favicon/favicon-16x16.png",
36+
},
37+
{
38+
"rel": "icon",
39+
"sizes": "32x32",
40+
"href": "favicon-32x32.png",
41+
},
42+
{
43+
"rel": "apple-touch-icon",
44+
"sizes": "180x180",
45+
"href": "apple-touch-icon-180x180.png",
46+
},
47+
],
3148
}
3249

3350
html_sidebars = {"section1/index": ["sidebar-nav-bs.html"]}

tests/test_build.py

+9-45
Original file line numberDiff line numberDiff line change
@@ -235,50 +235,6 @@ def test_logo_external_image(sphinx_build_factory):
235235
assert f'src="{test_url}"' in index_str
236236

237237

238-
def test_favicons(sphinx_build_factory):
239-
"""Test that arbitrary favicons are included."""
240-
html_theme_options_favicons = {
241-
"favicons": [
242-
{
243-
"rel": "icon",
244-
"sizes": "16x16",
245-
"href": "https://secure.example.com/favicon/favicon-16x16.png",
246-
},
247-
{
248-
"rel": "icon",
249-
"sizes": "32x32",
250-
"href": "favicon-32x32.png",
251-
},
252-
{
253-
"rel": "apple-touch-icon",
254-
"sizes": "180x180",
255-
"href": "apple-touch-icon-180x180.png",
256-
},
257-
]
258-
}
259-
confoverrides = {"html_theme_options": html_theme_options_favicons}
260-
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
261-
262-
index_html = sphinx_build.html_tree("index.html")
263-
264-
icon_16 = (
265-
'<link href="https://secure.example.com/favicon/favicon-16x16.png" '
266-
'rel="icon" sizes="16x16" type="image/png"/>'
267-
)
268-
icon_32 = (
269-
'<link href="_static/favicon-32x32.png" rel="icon" sizes="32x32" '
270-
'type="image/png"/>'
271-
)
272-
icon_180 = (
273-
'<link href="_static/apple-touch-icon-180x180.png" '
274-
'rel="apple-touch-icon" sizes="180x180" type="image/png"/>'
275-
)
276-
print(index_html.select("head")[0])
277-
assert icon_16 in str(index_html.select("head")[0])
278-
assert icon_32 in str(index_html.select("head")[0])
279-
assert icon_180 in str(index_html.select("head")[0])
280-
281-
282238
def test_navbar_align_default(sphinx_build_factory):
283239
"""The navbar items align with the proper part of the page."""
284240
sphinx_build = sphinx_build_factory("base").build()
@@ -755,7 +711,7 @@ def test_deprecated_build_html(sphinx_build_factory, file_regression):
755711

756712
# check the deprecation warnings
757713
warnings = sphinx_build.warnings.split("WARNING: ")
758-
assert len(warnings) == 5 # testing the text of the warning is not necessary here
714+
assert len(warnings) == 6 # testing the text of the warning is not necessary here
759715

760716
index_html = sphinx_build.html_tree("index.html")
761717
subpage_html = sphinx_build.html_tree("section1/index.html")
@@ -770,6 +726,14 @@ def test_deprecated_build_html(sphinx_build_factory, file_regression):
770726
sidebar.prettify(), basename="sidebar_subpage", extension=".html"
771727
)
772728

729+
# the favicons
730+
icon_16 = '<link href="https://secure.example.com/favicon/favicon-16x16.png" rel="icon" sizes="16x16" type="image/png"/>' # fmt: skip
731+
assert icon_16 in str(index_html.select("head")[0])
732+
icon_32 = '<link href="_static/favicon-32x32.png" rel="icon" sizes="32x32" type="image/png"/>' # fmt: skip
733+
assert icon_32 in str(index_html.select("head")[0])
734+
icon_180 = '<link href="_static/apple-touch-icon-180x180.png" rel="apple-touch-icon" sizes="180x180" type="image/png"/>' # fmt: skip
735+
assert icon_180 in str(index_html.select("head")[0])
736+
773737
# Secondary sidebar should not have in-page TOC if it is empty
774738
assert not sphinx_build.html_tree("page1.html").select("div.onthispage")
775739

0 commit comments

Comments
 (0)