diff --git a/docs/_static/custom.css b/docs/_static/custom.css
index 4bf1395fc..3053eb1c7 100644
--- a/docs/_static/custom.css
+++ b/docs/_static/custom.css
@@ -64,3 +64,21 @@ body div.document {
outline: 0;
}
+
+div.sphinxsidebar {
+ font-size: inherit;
+ line-height: inherit;
+}
+
+#sidebartoc li {
+ margin-top: 0.75ex;
+ margin-bottom: 0.75ex;
+}
+
+#sidebartoc ul {
+ list-style: none !important;
+}
+
+#sidebartoc a[href]:hover {
+ color: red;
+}
diff --git a/docs/_templates/localtoc.html b/docs/_templates/localtoc.html
new file mode 100644
index 000000000..655bdb7c4
--- /dev/null
+++ b/docs/_templates/localtoc.html
@@ -0,0 +1,6 @@
+{%- if display_toc %}
+
+
+{%- endif %}
diff --git a/docs/conf.py b/docs/conf.py
index 9480031d2..c74d8228e 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -234,6 +234,26 @@ def commit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
return [node], []
+def create_toc(app, pagename):
+ toctree = app.env.get_toc_for(pagename, app.builder)
+ if toctree is not None:
+ subtree = toctree[toctree.first_child_matching_class(nodes.list_item)]
+ bl = subtree.first_child_matching_class(nodes.bullet_list)
+ if bl is None:
+ return # Empty ToC
+ subtree = subtree[bl]
+ # for li in subtree.traverse(nodes.list_item):
+ # modify_li(li)
+ # subtree['ids'] = [ID]
+ return app.builder.render_partial(subtree)['fragment']
+
+
+def add_html_context(app, pagename, templatename, context, *args):
+ if 'toc' in context:
+ context['toc'] = create_toc(app, pagename) or context['toc']
+
+
def setup(app):
app.add_role('iss', issue_role)
app.add_role('commit', commit_role)
+ app.connect('html-page-context', add_html_context)
diff --git a/docs/graphics-protocol.rst b/docs/graphics-protocol.rst
index f41799912..938daca1a 100644
--- a/docs/graphics-protocol.rst
+++ b/docs/graphics-protocol.rst
@@ -1,3 +1,5 @@
+:tocdepth: 3
+
The terminal graphics protocol
==================================
diff --git a/docs/index.rst b/docs/index.rst
index dfc1c76fe..078e3fcfc 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,3 +1,5 @@
+:tocdepth: 2
+
==========================================================
kitty - the fast, featureful, GPU based, terminal emulator
==========================================================