Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sphinx 6: Use logo_url instead of logo #1405

Merged
merged 5 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file added docs/demo/static/favicon.ico
Binary file not shown.
39 changes: 16 additions & 23 deletions sphinx_rtd_theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
{%- endfor -%}

{#- FAVICON #}
{%- if favicon %}
{%- if sphinx_version_info < (4, 0) -%}
<link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/>
{%- else %}
<link rel="shortcut icon" href="{{ favicon_url }}"/>
{%- 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 %}
<link rel="shortcut icon" href="{{ _favicon_url }}"/>
{%- endif %}

{#- CANONICAL URL (deprecated) #}
{%- if theme_canonical_url and not pageurl %}
Expand Down Expand Up @@ -133,22 +133,15 @@
<div class="wy-side-nav-search" {% if theme_style_nav_header_background %} style="background: {{theme_style_nav_header_background}}" {% endif %}>
{%- block sidebartitle %}

{%- if logo and theme_logo_only %}
<a href="{{ pathto(master_doc) }}">
{%- else %}
<a href="{{ pathto(master_doc) }}" class="icon icon-home"> {{ project }}
{%- endif %}

{%- if logo %}
{#- Not strictly valid HTML, but it's the only way to display/scale
it properly, without weird scripting or heaps of work
#}
{%- if sphinx_version_info < (4, 0) -%}
<img src="{{ pathto('_static/' + logo, 1) }}" class="logo" alt="{{ _('Logo') }}"/>
{%- else %}
<img src="{{ logo_url }}" class="logo" alt="{{ _('Logo') }}"/>
{# the logo helper function was removed in Sphinx 6 and deprecated since Sphinx 4 #}
{# the master_doc variable was renamed to root_doc in Sphinx 4 (master_doc still exists in later Sphinx versions) #}
{%- set _logo_url = logo_url|default(pathto('_static/' + (logo or ""), 1)) %}
{%- set _root_doc = root_doc|default(master_doc) %}
<a href="{{ pathto(_root_doc) }}"{% if not theme_logo_only %} class="icon icon-home"{% endif %}>
{% if not theme_logo_only %}{{ project }}{% endif %}
{%- if logo or logo_url %}
<img src="{{ _logo_url }}" class="logo" alt="{{ _('Logo') }}"/>
{%- endif %}
{%- endif %}
</a>

{%- if theme_display_version %}
Expand Down