Debian Codegraph @

docs/user_guide/page-toc.rst

raw
1 Page Table of Contents
2 ======================
3
4 Show more levels of the in-page TOC by default
5 ----------------------------------------------
6
7 Normally only the 2nd-level headers of a page are shown in the right
8 table of contents and deeper levels are only shown when they are part
9 of an active section (when it is scrolled on screen).
10
11 You can show deeper levels by default by using the following configuration, indicating how many levels should be displayed:
12
13 .. code-block:: python
14
15 html_theme_options = {
16 "show_toc_level": 2
17 }
18
19 All headings up to and including the level specified will now be shown
20 regardless of what is displayed on the page.
21
22 Remove the Table of Contents
23 ----------------------------
24
25 To remove the Table of Contents, add ``:html_theme.sidebar_secondary.remove:`` to the `file-wide metadata <https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html#file-wide-metadata>`_ at the top of a page.
26 This will remove the Table of Contents from that page only.
27
28 Per-page secondary-sidebar content
29 ----------------------------------
30
31 ``html_theme_options['secondary_sidebar_items']`` accepts either a ``list`` of secondary sidebar
32 templates to render on every page:
33
34 .. code-block:: python
35
36 html_theme_options = {
37 "secondary_sidebar_items": ["page-toc", "sourcelink"]
38 }
39
40 or a ``dict`` which maps page names to ``list`` of secondary sidebar templates:
41
42 .. code-block:: python
43
44 html_theme_options = {
45 "secondary_sidebar_items": {
46 "**": ["page-toc", "sourcelink"],
47 "index": ["page-toc"],
48 }
49 }
50
51 If a ``dict`` is specified, the keys can contain glob-style patterns; page names which
52 match the pattern will contain the sidebar templates specified. This closely follows the behavior of
53 the ``html_sidebars`` option that is part of Sphinx itself, except that it operates on the
54 secondary sidebar instead of the primary sidebar. For more information, see `the Sphinx
55 documentation <https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_sidebars>`__.