From 5e80b2bd08dbe4b2b74c229efda335e1d33ed824 Mon Sep 17 00:00:00 2001 From: Benjamin Balder Bach Date: Tue, 17 Jan 2023 22:48:39 +0100 Subject: [PATCH] Sphinx 6: Use logo_url instead of logo (#1405) * Sphinx 6: Use logo_url instead of logo * Handle removal of favicon template context + refactor display of logo and link so it's easier to see what belongs to <4.0 and what is >=4.0 * Adds a favicon to the demo * Import condensed version logic @agjohnson * Update sphinx_rtd_theme/layout.html Co-authored-by: Anthony Co-authored-by: Anthony --- docs/conf.py | 1 + docs/demo/static/favicon.ico | Bin 0 -> 766 bytes sphinx_rtd_theme/layout.html | 39 ++++++++++++++--------------------- 3 files changed, 17 insertions(+), 23 deletions(-) create mode 100644 docs/demo/static/favicon.ico diff --git a/docs/conf.py b/docs/conf.py index 5a27944c3..25d002c02 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -70,6 +70,7 @@ html_logo = "demo/static/logo-wordmark-light.svg" html_show_sourcelink = True +html_favicon = "demo/static/favicon.ico" htmlhelp_basename = slug diff --git a/docs/demo/static/favicon.ico b/docs/demo/static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..42e8969edc8c3345e10706d5e1c4f57ed92469e1 GIT binary patch literal 766 zcmZQzU<5)11py$*!tjELfkBLcfk6X^6@b_Qh(Y4GKt!M$!}^6i46mO*!li_|;*5eo xAi$sm1`0sOQHc+9rIHeod8G1*cMk&t$o&ZON#&F3e^SjyS5KOKKz|J-001VUA|?O; literal 0 HcmV?d00001 diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html index bb0c069a2..94a40cc1c 100644 --- a/sphinx_rtd_theme/layout.html +++ b/sphinx_rtd_theme/layout.html @@ -40,14 +40,14 @@ {%- endfor -%} - {#- FAVICON #} - {%- if favicon %} - {%- if sphinx_version_info < (4, 0) -%} - - {%- else %} - - {%- endif %} - {%- endif -%} + {#- FAVICON + favicon_url is the only context var necessary since Sphinx 4. + In Sphinx<4, we use favicon but need to prepend path info. + #} + {%- set _favicon_url = favicon_url | default(pathto('_static/' + (favicon or ""), 1)) %} + {%- if favicon_url or favicon %} + + {%- endif %} {#- CANONICAL URL (deprecated) #} {%- if theme_canonical_url and not pageurl %} @@ -133,22 +133,15 @@