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
A minimal ToC defines the top level `main` key, and a single root document page:
28
+
A minimal ToC defines the top level `main` key, and a single root document file:
29
29
30
30
```yaml
31
31
main:
32
-
doc: intro
32
+
file: intro
33
33
```
34
34
35
-
The value of the `doc` key will be a path to a file (relative to the `conf.py`) with or without the file extension.
35
+
The value of the `file` key will be a path to a file (relative to the `conf.py`) with or without the file extension.
36
36
37
37
```{important}
38
-
Each document can only occur once in the ToC!
38
+
Each document file can only occur once in the ToC!
39
39
```
40
40
41
-
Document pages can then have a `parts` key - denoting a list of individual toctrees for that document - and in-turn each part should have a `sections` key - denoting a list of children links, that are one of: `doc`, `url` or `glob`:
41
+
Document files can then have a `parts` key - denoting a list of individual toctrees for that document - and in-turn each part should have a `sections` key - denoting a list of children links, that are one of: `file`, `url` or `glob`:
42
42
43
-
- `doc`: relating to a single document page (as above)
44
-
- `glob`: relating to one or more document pages *via* Unix shell-style wildcards (similar to [`fnmatch`](https://docs.python.org/3/library/fnmatch.html), but single stars don't match slashes.)
45
-
- `url`: relating to an external URL (`http` or `https`)
43
+
- `file`: relating to a single document file
44
+
- `glob`: relating to one or more document files *via* Unix shell-style wildcards (similar to [`fnmatch`](https://docs.python.org/3/library/fnmatch.html), but single stars don't match slashes.)
45
+
- `url`: relating to an external URL (e.g. `http` or `https`)
46
46
47
47
This can proceed recursively to any depth.
48
48
49
49
```yaml
50
50
main:
51
-
doc: intro
51
+
file: intro
52
52
parts:
53
53
- sections:
54
-
- doc: doc1
54
+
- file: doc1
55
55
parts:
56
56
- sections:
57
-
- doc: doc2
57
+
- file: doc2
58
58
- url: https://example.com
59
59
- glob: other*
60
60
```
61
61
62
-
As a shorthand, the `sections` key can be at the same level as the `doc`, which denotes a document with a single `part`.
62
+
As a shorthand, the `sections` key can be at the same level as the `file`, which denotes a document with a single `part`.
63
63
For example, this file is exactly equivalent to the one above:
64
64
65
65
```yaml
66
66
main:
67
-
doc: intro
67
+
file: intro
68
68
sections:
69
-
- doc: doc1
69
+
- file: doc1
70
70
sections:
71
-
- doc: doc2
71
+
- file: doc2
72
72
- url: https://example.com
73
73
- glob: other*
74
74
```
@@ -81,12 +81,12 @@ Each part can also have a `caption`, e.g. for use in ToC side-bars:
81
81
82
82
```yaml
83
83
main:
84
-
doc: intro
84
+
file: intro
85
85
title: Introduction
86
86
parts:
87
87
- caption: Part Caption
88
88
sections:
89
-
- doc: doc1
89
+
- file: doc1
90
90
- url: https://example.com
91
91
title: Example Site
92
92
```
@@ -97,12 +97,12 @@ You can automatically add numbers to all docs with a part by adding the `numbere
97
97
98
98
```yaml
99
99
main:
100
-
doc: intro
100
+
file: intro
101
101
parts:
102
102
- numbered: true
103
103
sections:
104
-
- doc: doc1
105
-
- doc: doc2
104
+
- file: doc1
105
+
- file: doc2
106
106
```
107
107
108
108
You can also **limit the TOC numbering depth** by setting the `numbered` flag to an integer instead of `true`, e.g., `numbered: 3`.
@@ -115,16 +115,46 @@ To have e.g. `numbered` added to all toctrees, set it in under a `defaults` top-
115
115
defaults:
116
116
numbered: true
117
117
main:
118
-
doc: intro
118
+
file: intro
119
119
sections:
120
-
- doc: doc1
120
+
- file: doc1
121
121
sections:
122
-
- doc: doc2
122
+
- file: doc2
123
123
- url: https://example.com
124
124
```
125
125
126
126
Available keys: `numbered`, `titlesonly`, `reversed`
127
127
128
+
## Command-line
129
+
130
+
This package comes with the `sphinx-etoc` command-line program, with some additional tools.
Note, when using `glob` you can also add additional files in `meta`/`create_additional`, e.g.
145
+
146
+
```yaml
147
+
main:
148
+
file: intro
149
+
sections:
150
+
- glob: doc*
151
+
meta:
152
+
create_additional:
153
+
- doc1
154
+
- doc2
155
+
- doc3
156
+
```
157
+
128
158
## API
129
159
130
160
The ToC file is parsed to a `SiteMap`, which is a `MutableMapping` subclass, with keys representing docnames mapping to a `DocItem` that stores information on the toctrees it should contain:
@@ -157,36 +187,6 @@ intro:
157
187
title: Introduction
158
188
```
159
189
160
-
## Command-line
161
-
162
-
This package comes with the `sphinx-etoc` command-line program, with some additional tools.
0 commit comments