|
| 1 | +.. highlight:: rest |
| 2 | + |
1 | 3 | .. _concepts: |
2 | 4 |
|
3 | 5 | Sphinx concepts |
4 | 6 | =============== |
5 | 7 |
|
| 8 | +Document names |
| 9 | +-------------- |
| 10 | + |
| 11 | + |
| 12 | + |
6 | 13 |
|
7 | 14 | The TOC tree |
8 | 15 | ------------ |
9 | 16 |
|
| 17 | +Since reST does not have facilities to interconnect several documents, or split |
| 18 | +documents into multiple output files, Sphinx uses a custom directive to add |
| 19 | +relations between the single files the documentation is made of, as well as |
| 20 | +tables of contents. The ``toctree`` directive is the central element. |
10 | 21 |
|
11 | | -Document names |
12 | | --------------- |
| 22 | +.. directive:: toctree |
| 23 | + |
| 24 | + This directive inserts a "TOC tree" at the current location, using the |
| 25 | + individual TOCs (including "sub-TOC trees") of the files given in the |
| 26 | + directive body. A numeric ``maxdepth`` option may be given to indicate the |
| 27 | + depth of the tree; by default, all levels are included. |
| 28 | + |
| 29 | + Consider this example (taken from the Python docs' library reference index):: |
| 30 | + |
| 31 | + .. toctree:: |
| 32 | + :maxdepth: 2 |
| 33 | + |
| 34 | + intro.rst |
| 35 | + strings.rst |
| 36 | + datatypes.rst |
| 37 | + numeric.rst |
| 38 | + (many more files listed here) |
| 39 | + |
| 40 | + This accomplishes two things: |
| 41 | + |
| 42 | + * Tables of contents from all those files are inserted, with a maximum depth |
| 43 | + of two, that means one nested heading. ``toctree`` directives in those |
| 44 | + files are also taken into account. |
| 45 | + * Sphinx knows that the relative order of the files ``intro.rst``, |
| 46 | + ``strings.rst`` and so forth, and it knows that they are children of the |
| 47 | + shown file, the library index. From this information it generates "next |
| 48 | + chapter", "previous chapter" and "parent chapter" links. |
13 | 49 |
|
| 50 | + In the end, all files included in the build process must occur in one |
| 51 | + ``toctree`` directive; Sphinx will emit a warning if it finds a file that is |
| 52 | + not included, because that means that this file will not be reachable through |
| 53 | + standard navigation. Use :confval:`unused_documents` to explicitly exclude |
| 54 | + documents from this check. |
14 | 55 |
|
| 56 | + The "master file" (selected by :confval:`master_file`) is the "root" of the |
| 57 | + TOC tree hierarchy. It can be used as the documentation's main page, or as a |
| 58 | + "full table of contents" if you don't give a ``maxdepth`` option. |
0 commit comments