Debian Codegraph @

docs/user_guide/navigation.rst

raw
1 .. _navigation-depth:
2
3 Navigation depth and collapsing sidebars
4 ========================================
5
6 By default, this theme allows expanding/collapsing subsections in the primary
7 sidebar navigation (without actually navigating to the page itself), and this extends
8 up to 4 levels deep:
9
10 .. image:: /_static/demo-expandable-navigation.gif
11
12
13 Control how many navigation levels are shown by default
14 -------------------------------------------------------
15
16 You can control how many navigation levels are shown when a page is
17 loaded. By default, this level is 1, and only top-level pages are shown,
18 with drop-boxes to reveal their children. To make their children show up by
19 default, you can use the following configuration in ``conf.py``:
20
21 .. code:: python
22
23 html_theme_options = {
24 "show_nav_level": 2
25 }
26
27 This will make the first two navigation levels show up by default (AKA, top-level
28 pages and their immediate children).
29
30 Collapse entire toctree captions/parts
31 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
33 If your ``toctree`` elements have captions assigned to them (with ``:caption:``), you may
34 collapse navigation items so that only the caption is visible. Clicking on the
35 caption will display the items below.
36
37 To enable this behavior, set the ``show_nav_level`` value to 0, like below:
38
39 .. code:: python
40
41 html_theme_options = {
42 "show_nav_level": 0
43 }
44
45 You can only collapse your ``toctree`` items underneath their caption if a caption is defined for them!
46 If your ``toctree`` does not have a caption defined, then all the pages underneath it will be displayed
47 (the same as the default theme behavior). See `the toctree documentation <https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-toctree>`_
48 for more details.
49
50 .. note::
51
52 In some Sphinx sites, the top-level ``toctree`` groupings make up "parts" in the documentation, with
53 each page beneath making up a "chapter".
54
55 .. _navigation-levels:
56
57 Control the number of navigation levels
58 ---------------------------------------
59
60 In addition, you can also control how many levels of the navigation are shown
61 in the sidebar (with a default of 4):
62
63 .. code:: python
64
65 html_theme_options = {
66 "navigation_depth": 2
67 }
68
69
70 Remove reveal buttons for sidebar items
71 ---------------------------------------
72
73 It is possible to turn off the expandable navigation entirely by setting
74 the `collapse_navigation` config option to True:
75
76 .. code:: python
77
78 html_theme_options = {
79 "collapse_navigation": True
80 }