Skip to content

Commit 28fef37

Browse files
authored
feat: add the indices to the optional sidebar components (#922)
* add an indices component * add indices.html to the list of component * add an indices page * Update docs/user_guide/indices.rst
1 parent d9b89c5 commit 28fef37

File tree

6 files changed

+75
-0
lines changed

6 files changed

+75
-0
lines changed

docs/user_guide/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ navigation
3636
page-toc
3737
header-links
3838
source-buttons
39+
indices
3940
```
4041

4142
```{toctree}

docs/user_guide/indices.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
==============
2+
Sphinx indices
3+
==============
4+
5+
Sphinx generates indices named `genindex`, `modindex` and `py-modindex` when building a documentation. More information about them can be found in the Sphinx documentation `here <https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-index>`__.
6+
7+
Add indices links
8+
=================
9+
10+
By design the indices pages are not linked in a documentation generated with this theme. To include them in the left sidebar of each page, add the following configuration to your ``conf.py`` file in ``html_theme_options`` and the available indices will be display at the bottom.
11+
12+
.. code-block:: python
13+
14+
html_theme_options = {
15+
#[...]
16+
"left_sidebar_end": ["indices.html", "sidebar-ethical-ads.html"]
17+
#[...]
18+
}
19+
20+
.. note::
21+
22+
don't forget to add back the ``"sidebar-ethical-ads.html"`` template if you are serving your documentation using `ReadTheDocs <https://readthedocs.org>`__.

docs/user_guide/layout.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ will be named accordingly).
461461
- ``sphinx-version.html``
462462
- ``theme-switcher.html``
463463
- ``version-switcher.html``
464+
- ``indices.html``
464465

465466

466467
Add your own HTML templates to theme sections
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.sidebar-indices-items {
2+
display: flex;
3+
flex-direction: column;
4+
border-top: 1px solid var(--pst-color-border);
5+
6+
@include media-breakpoint-up($breakpoint-sidebar-primary) {
7+
border-top: none;
8+
}
9+
10+
.sidebar-indices-items__title {
11+
font-weight: var(--pst-sidebar-header-font-weight);
12+
font-size: var(--pst-sidebar-header-font-size);
13+
color: var(--pst-color-text-base);
14+
margin-bottom: 0.5rem;
15+
}
16+
17+
ul.indices-link {
18+
margin-right: -1rem;
19+
list-style: none;
20+
padding: 0;
21+
22+
li > a {
23+
display: block;
24+
padding: 0.25rem 0;
25+
color: var(--pst-color-text-muted);
26+
27+
&:hover {
28+
color: var(--pst-color-primary);
29+
text-decoration: none;
30+
background-color: transparent;
31+
}
32+
}
33+
}
34+
}

src/pydata_sphinx_theme/assets/styles/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ $grid-breakpoints: (
5454
@import "./components/switcher-version";
5555
@import "./components/toc-inpage";
5656
@import "./components/versionmodified";
57+
@import "./components/indices";
5758

5859
// Content blocks in standard Sphinx
5960
@import "./content/admonitions";
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<nav class="sidebar-indices-items">
2+
<p class="sidebar-indices-items__title" role="heading" aria-level="1">
3+
{{ _("Indices") }}
4+
</p>
5+
<ul class="indices-link">
6+
{%- for rellink in rellinks %}
7+
{%- if rellink[0] == 'genindex' %}
8+
<li class="toctree-l1"><a class="reference internal" href="{{ pathto('genindex') }}" accesskey="I">{{ _('General Index') }}</a></li>
9+
{%- elif rellink[0] == 'modindex' %}
10+
<li class="toctree-l1"><a class="reference internal" href="{{ pathto('modindex') }}">{{ _('Global Module Index') }}</a></li>
11+
{%- elif rellink[0] == 'py-modindex' %}
12+
<li class="toctree-l1"><a class="reference internal" href="{{ pathto('py-modindex') }}">{{ _('Python Module Index') }}</a></li>
13+
{%- endif %}
14+
{%- endfor %}
15+
</ul>
16+
</nav>

0 commit comments

Comments
 (0)