Add nested navigation to the ReadTheDocs theme

This commit is contained in:
Dougal Matthews
2015-05-01 12:30:56 +01:00
parent a413dfd48b
commit 1a87bede35
3 changed files with 35 additions and 38 deletions

View File

@@ -57,7 +57,11 @@
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
{% include "toc.html" %}
<ul class="current">
{% for nav_item in nav %}
<li>{% include "toc.html" %}<li>
{% endfor %}
</ul>
</div>
&nbsp;
</nav>

View File

@@ -25,7 +25,7 @@ h3, h4, h5, h6 {
color: #838383;
}
.wy-menu-vertical .toctree-l2 a {
.wy-menu-vertical .subnav a {
padding: 0.4045em 2.427em;
}
@@ -116,3 +116,11 @@ code.cs, code.c {
padding: 6px 12px;
border-color: #D1D4D5;
}
.wy-menu-vertical li ul {
display: inherit;
}
.wy-menu-vertical li ul.subnav ul.subnav{
padding-left: 1em;
}

View File

@@ -1,38 +1,23 @@
<ul class="current">
{% for nav_item in nav %}
{% if nav_item.children %}
<span>{{ nav_item.title }}</span>
{% for nav_item in nav_item.children %}
<li class="toctree-l2 {% if nav_item.active%}current{%endif%}">
<a class="{% if nav_item.active%}current{%endif%}" href="{{ nav_item.url }}">{{ nav_item.title }}</a>
{% if nav_item == current_page %}
<ul>
{% for toc_item in toc %}
<li class="toctree-l3"><a href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
{% for toc_item in toc_item.children %}
<li><a class="toctree-l4" href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
{% endfor %}
{% endfor %}
</ul>
{% endif %}
</li>
{% if nav_item.children %}
<ul class="subnav">
<li><span>{{ nav_item.title }}</span></li>
{% for nav_item in nav_item.children %}
{% include 'toc.html' %}
{% endfor %}
</ul>
{% else %}
<li class="toctree-l1 {% if nav_item.active%}current{%endif%}">
<a class="{% if nav_item.active%}current{%endif%}" href="{{ nav_item.url }}">{{ nav_item.title }}</a>
{% if nav_item == current_page %}
<ul>
{% for toc_item in toc %}
<li class="toctree-l3"><a href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
{% for toc_item in toc_item.children %}
<li><a class="toctree-l4" href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
{% endfor %}
{% endfor %}
{% else %}
<li class="toctree-l1 {% if nav_item.active%}current{%endif%}">
<a class="{% if nav_item.active%}current{%endif%}" href="{{ nav_item.url }}">{{ nav_item.title }}</a>
{% if nav_item == current_page %}
<ul>
{% for toc_item in toc %}
<li class="toctree-l3"><a href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
{% for toc_item in toc_item.children %}
<li><a class="toctree-l4" href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
{% endfor %}
{% endfor %}
</ul>
{% endif %}
</li>
</ul>
{% endif %}
{% endfor %}
</ul>
</li>
{% endif %}