Skip to content

Commit 6d75ecf

Browse files
stefanvjarrodmillman
authored andcommitted
Add toctree rendering
1 parent f217444 commit 6d75ecf

5 files changed

Lines changed: 77 additions & 1 deletion

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Style the toctree component in pages (avoid modifying the navbars)
3+
*/
4+
.toctree-wrapper {
5+
p.caption {
6+
font-size: 1.5em;
7+
margin-bottom: 0em;
8+
}
9+
10+
& > ul {
11+
padding-left: 0;
12+
}
13+
14+
li[class^="toctree-l"] {
15+
list-style: none;
16+
margin-bottom: 0.2em;
17+
18+
& > a {
19+
list-style: none;
20+
font-size: 1.1em;
21+
}
22+
23+
& > ul {
24+
list-style: none;
25+
padding-inline-start: 1.5em;
26+
}
27+
}
28+
29+
// slightly bigger font for l1
30+
.toctree-l1 > a {
31+
font-size: 1.3em;
32+
}
33+
}
34+
35+
div.topic.contents, // Docutils <= 0.17
36+
nav.contents // Docutils >= 0.18
37+
{
38+
// Style similarly to toctree
39+
ul.simple {
40+
list-style: none;
41+
padding-left: 0;
42+
}
43+
}

assets/theme-css/pst/pydata-sphinx-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
//@import "./content/quotes";
6060
//@import "./content/spans";
6161
//@import "./content/tables";
62-
//@import "./content/toctree";
62+
@import "./content/toctree";
6363
//@import "./content/math";
6464

6565
//// Content blocks from Sphinx extensions

assets/theme-css/styles.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ p {
136136
margin-left: 15px;
137137
}
138138

139+
.content-container .toctree-wrapper ul:first-child {
140+
margin-left: 0;
141+
padding-left: 0.75rem;
142+
}
143+
144+
.content-container .toctree-wrapper ul {
145+
margin-left: 0.75rem;
146+
}
147+
139148
.content-container ol {
140149
padding: 10px;
141150
margin-left: 15px;

doc/content/examples/_index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
---
22
title: Examples
33
---
4+
5+
{{< toctree >}}

layouts/shortcodes/toctree.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<div class="toctree-wrapper">
2+
{{- range $section := .Page.Sections }}
3+
<ul>
4+
<li class="toctree-l1"><a href="{{ $section.RelPermalink }}">{{ $section.Title | safeHTML }}</a></li>
5+
{{- range $page := .RegularPages }}
6+
<ul>
7+
<li class="toctree-l2"><a href="{{ $page.RelPermalink }}">{{ $page.Title }}</a></li>
8+
<ul>
9+
{{- range .Fragments.Headings -}}
10+
{{/* H2 */}}
11+
{{- range .Headings }}
12+
<li class="toctree-l3">
13+
<a href="{{ $page.RelPermalink }}#{{ .ID }}">{{ .Title | safeHTML }}</a>
14+
</li>
15+
{{- end -}}
16+
{{- end }}
17+
</ul>
18+
</ul>
19+
{{- end }}
20+
</ul>
21+
{{- end }}
22+
</div>

0 commit comments

Comments
 (0)