mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
[themes]: Include project name in logo_alt
by default (#12421)
The "alt" attribute of an `<img>` 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.
This commit is contained in:
parent
581bcdd140
commit
6471027d19
@ -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,
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
<div class="header">
|
||||
{%- if logo_url %}
|
||||
<p class="logo"><a href="{{ pathto(root_doc)|e }}">
|
||||
<img class="logo" src="{{ logo_url|e }}" alt="Logo"/>
|
||||
<img class="logo" src="{{ logo_url|e }}" alt="{{ logo_alt|e }}"/>
|
||||
</a></p>
|
||||
{%- endif %}
|
||||
{%- block headertitle %}
|
||||
|
@ -50,7 +50,7 @@
|
||||
{%- block sidebarlogo %}
|
||||
{%- if logo_url %}
|
||||
<p class="logo"><a href="{{ pathto(root_doc)|e }}">
|
||||
<img class="logo" src="{{ logo_url|e }}" alt="Logo"/>
|
||||
<img class="logo" src="{{ logo_url|e }}" alt="{{ logo_alt|e }}"/>
|
||||
</a></p>
|
||||
{%- endif %}
|
||||
{%- endblock %}
|
||||
|
@ -36,11 +36,11 @@
|
||||
{%- block haikuheader %}
|
||||
{%- if theme_full_logo != "false" %}
|
||||
<a href="{{ pathto(root_doc)|e }}">
|
||||
<img class="logo" src="{{ logo_url|e }}" alt="Logo"/>
|
||||
<img class="logo" src="{{ logo_url|e }}" alt="{{ logo_alt|e }}"/>
|
||||
</a>
|
||||
{%- else %}
|
||||
{%- if logo -%}
|
||||
<img class="rightlogo" src="{{ logo_url|e }}" alt="Logo"/>
|
||||
<img class="rightlogo" src="{{ logo_url|e }}" alt="{{ logo_alt|e }}"/>
|
||||
{%- endif -%}
|
||||
<h1 class="heading"><a href="{{ pathto(root_doc)|e }}">
|
||||
<span>{{ shorttitle|e }}</span></a></h1>
|
||||
|
@ -13,7 +13,7 @@
|
||||
<div class="header" role="banner">
|
||||
<div class="logo">
|
||||
<a href="{{ pathto(root_doc)|e }}">
|
||||
<img class="logo" src="{{ logo_url|e }}" alt="Logo"/>
|
||||
<img class="logo" src="{{ logo_url|e }}" alt="{{ logo_alt|e }}"/>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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 ('<img class="logo" src="https://www.python.org/static/img/python-logo.png" alt="Logo"/>' in result)
|
||||
assert ('<img class="logo" src="https://www.python.org/static/img/python-logo.png" alt="Logo of Python"/>' in result)
|
||||
assert ('<link rel="icon" href="https://www.python.org/static/favicon.ico"/>' 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 ('<img class="logo" src="_static/img.png" alt="Logo"/>' in result)
|
||||
assert ('<img class="logo" src="_static/img.png" alt="Logo of Python"/>' in result)
|
||||
assert (app.outdir / '_static/img.png').exists()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user