From 6471027d1936f0a0a38ef281862f0b29c53618f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 18 Jun 2024 01:47:14 +0200 Subject: [PATCH] [themes]: Include project name in `logo_alt` by default (#12421) The "alt" attribute of an `` is required to convey all information. Make it clear which logo is shown. Also make it possible for users to override the logo_alt with a custom value. --- sphinx/builders/html/__init__.py | 1 + sphinx/themes/agogo/layout.html | 2 +- sphinx/themes/basic/layout.html | 2 +- sphinx/themes/haiku/layout.html | 4 ++-- sphinx/themes/pyramid/layout.html | 2 +- tests/test_builders/test_build_html_image.py | 4 ++-- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py index ee4474b64..6ae25129a 100644 --- a/sphinx/builders/html/__init__.py +++ b/sphinx/builders/html/__init__.py @@ -552,6 +552,7 @@ class StandaloneHTMLBuilder(Builder): 'builder': self.name, 'parents': [], 'logo_url': logo, + 'logo_alt': _('Logo of %s') % self.config.project, 'favicon_url': favicon, 'html5_doctype': True, } diff --git a/sphinx/themes/agogo/layout.html b/sphinx/themes/agogo/layout.html index 833b19977..9f5fabf3e 100644 --- a/sphinx/themes/agogo/layout.html +++ b/sphinx/themes/agogo/layout.html @@ -15,7 +15,7 @@
{%- if logo_url %} {%- endif %} {%- block headertitle %} diff --git a/sphinx/themes/basic/layout.html b/sphinx/themes/basic/layout.html index 31d9c6220..d91414a0d 100644 --- a/sphinx/themes/basic/layout.html +++ b/sphinx/themes/basic/layout.html @@ -50,7 +50,7 @@ {%- block sidebarlogo %} {%- if logo_url %} {%- endif %} {%- endblock %} diff --git a/sphinx/themes/haiku/layout.html b/sphinx/themes/haiku/layout.html index 217647a9d..b23937fbb 100644 --- a/sphinx/themes/haiku/layout.html +++ b/sphinx/themes/haiku/layout.html @@ -36,11 +36,11 @@ {%- block haikuheader %} {%- if theme_full_logo != "false" %} - + {%- else %} {%- if logo -%} - + {%- endif -%}

{{ shorttitle|e }}

diff --git a/sphinx/themes/pyramid/layout.html b/sphinx/themes/pyramid/layout.html index ffa93135e..583f5dc4c 100644 --- a/sphinx/themes/pyramid/layout.html +++ b/sphinx/themes/pyramid/layout.html @@ -13,7 +13,7 @@ diff --git a/tests/test_builders/test_build_html_image.py b/tests/test_builders/test_build_html_image.py index 08ed6187c..f385d1189 100644 --- a/tests/test_builders/test_build_html_image.py +++ b/tests/test_builders/test_build_html_image.py @@ -29,7 +29,7 @@ def test_html_remote_logo(app, status, warning): app.build(force_all=True) result = (app.outdir / 'index.html').read_text(encoding='utf8') - assert ('' in result) + assert ('' in result) assert ('' in result) assert not (app.outdir / 'python-logo.png').exists() @@ -39,7 +39,7 @@ def test_html_local_logo(app, status, warning): app.build(force_all=True) result = (app.outdir / 'index.html').read_text(encoding='utf8') - assert ('' in result) + assert ('' in result) assert (app.outdir / '_static/img.png').exists()