Skip to content

Commit 9f80fc5

Browse files
local toc with immediate parents, less in the global toc
1 parent b379f1b commit 9f80fc5

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

Doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@
366366
html_sidebars = {
367367
# Defaults taken from https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_sidebars
368368
# Removes the quick search block
369-
'**': ['localtoc.html', 'relations.html', 'customsourcelink.html'],
369+
'**': ['customlocaltoc.html', 'relations.html', 'customsourcelink.html'],
370370
'index': ['indexsidebar.html'],
371371
}
372372

Doc/contents.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44

55
.. toctree::
6+
:maxdepth: 2
67

78
whatsnew/index.rst
89
tutorial/index.rst
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{#
2+
Customization of sphinx's basic/localtoc.html
3+
4+
- Always display links to the parent pages within sections,
5+
rather than link to the global contents
6+
-
7+
#}
8+
<div>
9+
<div>
10+
{%- if parents %}
11+
{%- for parent in parents %}
12+
<h{{ loop.index0 + 3 }}>
13+
<a href="{{ parent.link|e }}"
14+
title="{{ parent.title }}">
15+
{{ parent.title }}
16+
</a>
17+
</h{{ loop.index0 + 3 }}>
18+
{%- endfor %}
19+
{%- else %}
20+
<h3><a href="{{ pathto(root_doc)|e }}">{{ docstitle|e }}</a></h3>
21+
{%- endif %}
22+
</div>
23+
{{ toc }}
24+
</div>

0 commit comments

Comments
 (0)