You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a re-working of jupyter-book/jupyter-book#757
(by @choldgraf and @AakashGfude),
but improved since the replacement is made in the `doctree-read` phase
(rather than a post transform)
and so does not have to deal with any builder specific logic.
Also better warnings and testing 😉
Note, the current implementation does not wrap the toctrees in
`compound(classes=["tableofcontents-wrapper"])`, like in jupyter-book,
but I feel this is unnecessary.
Copy file name to clipboardExpand all lines: README.md
+26-1Lines changed: 26 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,6 +114,11 @@ main:
114
114
115
115
You can also **limit the TOC numbering depth** by setting the `numbered` flag to an integer instead of `true`, e.g., `numbered: 3`.
116
116
117
+
:::{note}
118
+
By default, section numbering restarts for each `part`.
119
+
If you want want this numbering to be continuous, check-out the [sphinx-multitoc-numbering extension](https://github.com/executablebooks/sphinx-multitoc-numbering).
120
+
:::
121
+
117
122
### Defaults
118
123
119
124
To have e.g. `numbered` added to all toctrees, set it under a `defaults` top-level key:
@@ -132,6 +137,26 @@ main:
132
137
133
138
Available keys: `numbered`, `titlesonly`, `reversed`
134
139
140
+
## Add a ToC to a page's content
141
+
142
+
By default, the `toctree` generated per document (one per `part`) are appended to the end of the document and hidden (then, for example, most HTML themes show them in a side-bar).
143
+
But if you would like them to be visible at a certain place within the document body, you may do so by using the `tableofcontents` directive:
144
+
145
+
ReStructuredText:
146
+
147
+
```restructuredtext
148
+
.. tableofcontents::
149
+
```
150
+
151
+
MyST Markdown:
152
+
153
+
````md
154
+
```{tableofcontents}
155
+
```
156
+
````
157
+
158
+
Currently, only one `tableofcontents` should be used per page (all `toctree` will be added here), and only if it is a page with child/descendant documents.
159
+
135
160
## Excluding files not in ToC
136
161
137
162
By default, Sphinx will build all document files, regardless of whether they are specified in the Table of Contents, if they:
@@ -241,7 +266,7 @@ Questions / TODOs:
241
266
it will add `doc.rst` to the excluded patterns but then, when looking for `doc.md`,
242
267
will still select `doc.rst` (since it is first in `source_suffix`).
243
268
Maybe open an issue on sphinx, that `doc2path` should respect exclude patterns.
244
-
269
+
- Intergrate https://github.com/executablebooks/sphinx-multitoc-numbering into this extension? (or upstream PR)
A sphinx extension that allows the documentation toctree to be defined in a single file.
3
+
A sphinx extension that allows the documentation toctree to be defined in a single YAML file.
4
4
5
5
In normal Sphinx documentation, the documentation structure is defined *via* a bottom-up approach - adding [`toctree` directives](https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#table-of-contents) within pages of the documentation.
6
6
7
7
This extension facilitates a **top-down** approach to defining the structure, within a single file that is external to the documentation.
0 commit comments