Merge pull request #3464 from mkdocs/rtnav

Fix readthedocs theme expanding all top level ToC entries
This commit is contained in:
Oleh Prypin
2023-11-21 21:10:44 +01:00
committed by GitHub
4 changed files with 21 additions and 7 deletions

View File

@@ -112,7 +112,15 @@
{%- set navlevel = 1 %}
{%- for nav_item in nav %}
{%- if nav_item.is_section %}
{%- if nav_item.is_page %}
<ul><li{% if nav_item == page %} class="current-section"{% endif %}>
<a href="{% if nav_item == page %}#{% else %}{{ nav_item.url|url }}{% endif %}" style="padding: 0; font-size: inherit; line-height: inherit">
{%- endif %}
<p class="caption"><span class="caption-text">{{ nav_item.title }}</span></p>
{%- if nav_item.is_page %}
</a>
</li></ul>
{%- endif %}
<ul{% if nav_item.active %} class="current"{% endif %}>
{%- for nav_item in nav_item.children %}
<li class="toctree-l{{ navlevel }}{% if nav_item.active %} current{% endif %}">

View File

@@ -155,6 +155,12 @@ td, th {
padding-bottom: 40px;
}
/* For section-index only */
.wy-menu-vertical .current-section p {
background-color: #e3e3e3;
color: #404040;
}
/*
* The second step of above amendment: Here we make sure the items are aligned
* correctly within the .rst-current-version container. Using flexbox, we

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
<a class="{% if not nav_item.is_link %}reference internal{% endif %}{% if nav_item.active%} current{%endif%}" href="{% if not nav_item.is_section %}{{ nav_item.url|url }}{% else %}#{% endif %}">{{ nav_item.title }}</a>
<a class="{% if not nav_item.is_link %}reference internal{% endif %}{% if nav_item.active%} current{%endif%}" {% if nav_item == page %}href="#"{% elif nav_item.is_page or nav_item.is_link %}href="{{ nav_item.url|url }}"{% endif %}>{{ nav_item.title }}</a>
{%- set navlevel = navlevel + 1 %}
{%- if navlevel <= config.theme.navigation_depth
and ((nav_item.is_page and nav_item.toc.items
@@ -6,16 +6,16 @@
and (nav_item == page or not config.theme.collapse_navigation)))
or (nav_item.is_section and nav_item.children)) %}
<ul{% if nav_item.active %} class="current"{% endif %}>
{%- if nav_item.is_page %}
{#- Skip first level of toc which is page title. #}
{%- set toc_item = nav_item.toc.items[0] %}
{%- include 'toc.html' %}
{%- elif nav_item.is_section %}
{%- if nav_item.is_section %}
{%- for nav_item in nav_item.children %}
<li class="toctree-l{{ navlevel }}{% if nav_item.active%} current{%endif%}">
{%- include 'nav.html' %}
</li>
{%- endfor %}
{%- elif nav_item.is_page %}
{#- Skip first level of toc which is page title. #}
{%- set toc_item = nav_item.toc.items and nav_item.toc.items[0] %}
{%- include 'toc.html' %}
{%- endif %}
</ul>
{%- endif %}