@@ -96,138 +96,156 @@ The ``toctree`` directive is the central element.
9696 You can also add external links, by giving an HTTP URL instead of a document
9797 name.
9898
99- **Section numbering **
99+ The special entry name ``self `` stands for the document containing the
100+ toctree directive. This is useful if you want to generate a "sitemap" from
101+ the toctree.
100102
101- If you want to have section numbers even in HTML output, give the
102- **toplevel ** toctree a ``numbered `` option. For example::
103+ In the end, all documents in the :term: `source directory ` (or subdirectories)
104+ must occur in some ``toctree `` directive; Sphinx will emit a warning if it
105+ finds a file that is not included, because that means that this file will not
106+ be reachable through standard navigation.
103107
104- .. toctree::
105- :numbered:
108+ Use :confval: `exclude_patterns ` to explicitly exclude documents or
109+ directories from building completely. Use :ref: `the "orphan" metadata
110+ <metadata>` to let a document be built, but notify Sphinx that it is not
111+ reachable via a toctree.
106112
107- foo
108- bar
113+ The "root document" (selected by :confval: `root_doc `) is the "root" of the TOC
114+ tree hierarchy. It can be used as the documentation's main page, or as a
115+ "full table of contents" if you don't give a ``:maxdepth: `` option.
109116
110- Numbering then starts at the heading of `` foo ``. Sub-toctrees are
111- automatically numbered (don't give the `` numbered `` flag to those) .
117+ .. versionchanged :: 0.6
118+ Added support for external links and "self" references .
112119
113- Numbering up to a specific depth is also possible, by giving the depth as a
114- numeric argument to ``numbered ``.
120+ .. rubric :: options
115121
116- **Additional options **
122+ .. rst:directive:option:: class: class names
123+ :type: a list of class names, separated by spaces
117124
118- You can use the `` caption `` option to provide a toctree caption and you can
119- use the `` name `` option to provide an implicit target name that can be
120- referenced by using :rst:role: ` ref ` ::
125+ Assign `class attributes`_.
126+ This is a :dudir:`common option <common-options>`.
127+ For example ::
121128
122- .. toctree::
123- :caption: Table of Contents
124- :name: mastertoc
129+ .. toctree::
130+ :class: custom-toc
125131
126- foo
132+ .. _class attributes: https://docutils.sourceforge.io/docs/ref/doctree.html#classes
127133
128- As with :dudir: `most directives <common-options> `,
129- you can use the ``class `` option to assign `class attributes `_::
134+ .. versionadded:: 7.4
130135
131- .. toctree::
132- :class: custom-toc
136+ .. rst:directive:option:: name: label
137+ :type: text
133138
134- .. _class attributes : https://docutils.sourceforge.io/docs/ref/doctree.html#classes
139+ An implicit target name that can be referenced using :rst:role:`ref`.
140+ This is a :dudir:`common option <common-options>`.
141+ For example::
135142
136- If you want only the titles of documents in the tree to show up, not other
137- headings of the same level, you can use the `` titlesonly `` option::
143+ .. toctree::
144+ :name: mastertoc
138145
139- .. toctree::
140- :titlesonly:
146+ foo
141147
142- foo
143- bar
148+ .. versionadded:: 1.3
144149
145- You can use "globbing" in toctree directives, by giving the ``glob `` flag
146- option. All entries are then matched against the list of available
147- documents, and matches are inserted into the list alphabetically. Example::
150+ .. rst:directive:option:: caption
151+ :type: text
148152
149- .. toctree::
150- :glob :
153+ Add a caption to the toctree.
154+ For example: :
151155
152- intro*
153- recipe/*
154- *
156+ .. toctree::
157+ :caption: Table of Contents
155158
156- This includes first all documents whose names start with ``intro ``, then all
157- documents in the ``recipe `` folder, then all remaining documents (except the
158- one containing the directive, of course.) [# ]_
159+ foo
159160
160- The special entry name ``self `` stands for the document containing the
161- toctree directive. This is useful if you want to generate a "sitemap" from
162- the toctree.
161+ .. versionadded:: 1.3
163162
164- You can use the ``reversed `` flag option to reverse the order of the entries
165- in the list. This can be useful when using the ``glob `` flag option to
166- reverse the ordering of the files. Example::
163+ .. rst:directive:option:: numbered
164+ numbered: depth
167165
168- .. toctree::
169- :glob:
170- :reversed :
166+ If you want to have section numbers even in HTML output,
167+ add the ``:numbered:`` option to the *top-level* toctree.
168+ For example: :
171169
172- recipe/*
170+ .. toctree::
171+ :numbered:
173172
174- You can also give a "hidden" option to the directive, like this::
173+ foo
174+ bar
175175
176- .. toctree::
177- :hidden:
176+ Section numbering then starts at the heading of ``foo``.
177+ Sub-toctrees are automatically numbered
178+ (don't give the ``numbered`` flag to those).
178179
179- doc_1
180- doc_2
180+ Numbering up to a specific depth is also possible,
181+ by giving the depth as a numeric argument to ``numbered``.
181182
182- This will still notify Sphinx of the document hierarchy, but not insert links
183- into the document at the location of the directive -- this makes sense if you
184- intend to insert these links yourself, in a different style, or in the HTML
185- sidebar.
183+ .. versionadded:: 0.6
186184
187- In cases where you want to have only one top-level toctree and hide all other
188- lower level toctrees you can add the "includehidden" option to the top-level
189- toctree entry::
185+ .. versionchanged:: 1.1
186+ Added the numeric *depth* argument.
190187
191- .. toctree::
192- :includehidden:
188+ .. rst:directive:option:: titlesonly
193189
194- doc_1
195- doc_2
190+ Only list document titles, not other headings of the same level.
191+ For example::
196192
197- All other toctree entries can then be eliminated by the "hidden" option.
193+ .. toctree::
194+ :titlesonly:
198195
199- In the end, all documents in the :term: `source directory ` (or subdirectories)
200- must occur in some ``toctree `` directive; Sphinx will emit a warning if it
201- finds a file that is not included, because that means that this file will not
202- be reachable through standard navigation.
196+ foo
197+ bar
203198
204- Use :confval: `exclude_patterns ` to explicitly exclude documents or
205- directories from building completely. Use :ref: `the "orphan" metadata
206- <metadata>` to let a document be built, but notify Sphinx that it is not
207- reachable via a toctree.
199+ .. versionadded:: 1.0
208200
209- The "root document" (selected by :confval: `root_doc `) is the "root" of the TOC
210- tree hierarchy. It can be used as the documentation's main page, or as a
211- "full table of contents" if you don't give a ``maxdepth `` option.
201+ .. rst:directive:option:: glob
212202
213- .. versionchanged :: 0.3
214- Added "globbing" option.
203+ Parse glob wildcards in toctree entries.
204+ All entries are matched against the list of available documents,
205+ and matches are inserted into the list alphabetically.
206+ For example::
215207
216- .. versionchanged :: 0.6
217- Added "numbered" and "hidden" options as well as external links and
218- support for "self" references.
208+ .. toctree::
209+ :glob:
219210
220- .. versionchanged :: 1.0
221- Added "titlesonly" option.
211+ intro*
212+ recipe/*
213+ *
222214
223- .. versionchanged :: 1.1
224- Added numeric argument to "numbered".
215+ This includes first all documents whose names start with ``intro``,
216+ then all documents in the ``recipe`` folder, then all remaining documents
217+ (except the one containing the directive, of course.) [#]_
225218
226- .. versionchanged :: 1.2
227- Added "includehidden" option.
219+ .. versionadded:: 0.3
220+
221+ .. rst:directive:option:: reversed
222+
223+ Reverse the order of the entries in the list.
224+ This is particularly useful when using the ``:glob:`` option.
225+
226+ .. versionadded:: 1.5
227+
228+ .. rst:directive:option:: hidden
229+
230+ A hidden toctree only defines the document hierarchy.
231+ It will not insert links into the document at the location of the directive.
232+
233+ This makes sense if you have other means of navigation,
234+ e.g. through manual links, HTML sidebar navigation,
235+ or if you use the ``:includehidden:`` option on the top-level toctree.
236+
237+ .. versionadded:: 0.6
238+
239+ .. rst:directive:option:: includehidden
240+
241+ If you want one global table of contents showing the complete document structure,
242+ you can add the ``:includehidden:`` option to the *top-level* toctree directive.
243+ All other toctrees on child pages can then be made invisible
244+ with the ``:hidden:`` option.
245+ The top-level toctree with ``:includehidden:`` will then include their entries.
246+
247+ .. versionadded:: 1.2
228248
229- .. versionchanged :: 1.3
230- Added "caption" and "name" option.
231249
232250 Special names
233251^^^^^^^^^^^^^
0 commit comments