Skip to content

Commit

Permalink
Handle removal of favicon template context + refactor display of logo…
Browse files Browse the repository at this point in the history
… and link so it's easier to see what belongs to <4.0 and what is >=4.0
  • Loading branch information
benjaoming committed Jan 11, 2023
1 parent 2142c6d commit 35f565d
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions sphinx_rtd_theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@
{%- 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 }}"/>
{%- if sphinx_version_info < (4, 0) -%}
{%- if favicon %}
<link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/>
{%- else %}
{%- if favicon_url %}
<link rel="shortcut icon" href="{{ favicon_url }}"/>
{%- endif %}
{%- endif -%}

Expand Down Expand Up @@ -134,24 +135,31 @@
{%- block sidebartitle %}

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

{%- if sphinx_version_info < (4, 0) -%}
{# 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) #}
{%- if logo %}
<a href="{{ pathto(master_doc) }}">
<img src="{{ pathto('_static/' + logo, 1) }}" class="logo" alt="{{ _('Logo') }}"/>
</a>
{%- endif %}
{# Behavior since Sphinx 4 #}
{%- else %}
{% if logo_url %}
<img src="{{ logo_url }}" class="logo" alt="{{ _('Logo') }}"/>
<a href="{{ pathto(root_doc) }}">
<img src="{{ logo_url }}" class="logo" alt="{{ _('Logo') }}"/>
</a>
{%- endif %}
{%- endif %}

</a>
{%- else %}
{%- if sphinx_version_info < (4, 0) -%}
<a href="{{ pathto(master_doc) }}" class="icon icon-home"> {{ project }}</a>
{%- else %}
<a href="{{ pathto(root_doc) }}" class="icon icon-home"> {{ project }}</a>
{%- endif %}
{%- endif %}

{%- if theme_display_version %}
{%- set nav_version = version %}
Expand Down

0 comments on commit 35f565d

Please sign in to comment.