diff --git a/docs/user_guide/index.md b/docs/user_guide/index.md index 38443220b..6a25c428f 100644 --- a/docs/user_guide/index.md +++ b/docs/user_guide/index.md @@ -36,6 +36,7 @@ navigation page-toc header-links source-buttons +indices ``` ```{toctree} diff --git a/docs/user_guide/indices.rst b/docs/user_guide/indices.rst new file mode 100644 index 000000000..7fc98cd92 --- /dev/null +++ b/docs/user_guide/indices.rst @@ -0,0 +1,22 @@ +============== +Sphinx indices +============== + +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 `__. + +Add indices links +================= + +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. + +.. code-block:: python + + html_theme_options = { + #[...] + "left_sidebar_end": ["indices.html", "sidebar-ethical-ads.html"] + #[...] + } + +.. note:: + + don't forget to add back the ``"sidebar-ethical-ads.html"`` template if you are serving your documentation using `ReadTheDocs `__. diff --git a/docs/user_guide/layout.rst b/docs/user_guide/layout.rst index 113cdcded..073a1d962 100644 --- a/docs/user_guide/layout.rst +++ b/docs/user_guide/layout.rst @@ -461,6 +461,7 @@ will be named accordingly). - ``sphinx-version.html`` - ``theme-switcher.html`` - ``version-switcher.html`` +- ``indices.html`` Add your own HTML templates to theme sections diff --git a/src/pydata_sphinx_theme/assets/styles/components/_indices.scss b/src/pydata_sphinx_theme/assets/styles/components/_indices.scss new file mode 100644 index 000000000..d55aa5637 --- /dev/null +++ b/src/pydata_sphinx_theme/assets/styles/components/_indices.scss @@ -0,0 +1,34 @@ +.sidebar-indices-items { + display: flex; + flex-direction: column; + border-top: 1px solid var(--pst-color-border); + + @include media-breakpoint-up($breakpoint-sidebar-primary) { + border-top: none; + } + + .sidebar-indices-items__title { + font-weight: var(--pst-sidebar-header-font-weight); + font-size: var(--pst-sidebar-header-font-size); + color: var(--pst-color-text-base); + margin-bottom: 0.5rem; + } + + ul.indices-link { + margin-right: -1rem; + list-style: none; + padding: 0; + + li > a { + display: block; + padding: 0.25rem 0; + color: var(--pst-color-text-muted); + + &:hover { + color: var(--pst-color-primary); + text-decoration: none; + background-color: transparent; + } + } + } +} diff --git a/src/pydata_sphinx_theme/assets/styles/index.scss b/src/pydata_sphinx_theme/assets/styles/index.scss index 210772a43..6130ecc51 100644 --- a/src/pydata_sphinx_theme/assets/styles/index.scss +++ b/src/pydata_sphinx_theme/assets/styles/index.scss @@ -54,6 +54,7 @@ $grid-breakpoints: ( @import "./components/switcher-version"; @import "./components/toc-inpage"; @import "./components/versionmodified"; +@import "./components/indices"; // Content blocks in standard Sphinx @import "./content/admonitions"; diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html new file mode 100644 index 000000000..c7cc809da --- /dev/null +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html @@ -0,0 +1,16 @@ +