From 10ad01dd44c85e4d374fac138af18b4f68367058 Mon Sep 17 00:00:00 2001 From: Jared Dillard Date: Tue, 27 Jan 2026 13:11:15 -0800 Subject: [PATCH] Add notoc theme option --- docs/configuration.rst | 1 + sphinx_simplepdf/themes/simplepdf_theme/page.html | 3 ++- .../themes/simplepdf_theme/static/styles/sources/_toc.scss | 2 ++ .../simplepdf_theme/static/styles/sources/_variables.scss | 1 + sphinx_simplepdf/themes/simplepdf_theme/theme.conf | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 233c40e..8bccb4d 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -179,6 +179,7 @@ Additional options for the theme. The default theme ``simplepdf_theme`` inherits ``simplepdf_theme`` options: :nocover: Do not display cover pages (front and back cover) +:notoc: Do not display the Table of Contents page simplepdf_weasyprint_filter diff --git a/sphinx_simplepdf/themes/simplepdf_theme/page.html b/sphinx_simplepdf/themes/simplepdf_theme/page.html index 0d373e3..ac0c035 100644 --- a/sphinx_simplepdf/themes/simplepdf_theme/page.html +++ b/sphinx_simplepdf/themes/simplepdf_theme/page.html @@ -1,5 +1,6 @@ {%- extends "layout.html" %} {%- set render_cover = (not theme_nocover|tobool) %} +{%- set render_toc = (not theme_notoc|tobool) %} {%- block extrahead %} @@ -8,7 +9,7 @@ {%- if render_cover %} {%- include "cover.html" -%} {%- endif %} - {{ sidebar() }} + {%- if render_toc %}{{ sidebar() }}{%- endif %} {% endblock %} {% block body %} {{ body }} diff --git a/sphinx_simplepdf/themes/simplepdf_theme/static/styles/sources/_toc.scss b/sphinx_simplepdf/themes/simplepdf_theme/static/styles/sources/_toc.scss index 91b3266..fab6f9d 100644 --- a/sphinx_simplepdf/themes/simplepdf_theme/static/styles/sources/_toc.scss +++ b/sphinx_simplepdf/themes/simplepdf_theme/static/styles/sources/_toc.scss @@ -71,6 +71,7 @@ } // .. toctree:: config +@if not $notoc { .sphinxsidebarwrapper { page-break-before: always; @@ -159,3 +160,4 @@ } } } +} // @if not $notoc diff --git a/sphinx_simplepdf/themes/simplepdf_theme/static/styles/sources/_variables.scss b/sphinx_simplepdf/themes/simplepdf_theme/static/styles/sources/_variables.scss index c70b70c..bcbacbb 100644 --- a/sphinx_simplepdf/themes/simplepdf_theme/static/styles/sources/_variables.scss +++ b/sphinx_simplepdf/themes/simplepdf_theme/static/styles/sources/_variables.scss @@ -25,3 +25,4 @@ $bottom-center-content: config('bottom-center-content', '') !default; $bottom-right-content: config('bottom-right-content', '') !default; $nocover: theme_option('nocover', false) !default; +$notoc: theme_option('notoc', false) !default; diff --git a/sphinx_simplepdf/themes/simplepdf_theme/theme.conf b/sphinx_simplepdf/themes/simplepdf_theme/theme.conf index 67d2a9e..993b09e 100644 --- a/sphinx_simplepdf/themes/simplepdf_theme/theme.conf +++ b/sphinx_simplepdf/themes/simplepdf_theme/theme.conf @@ -14,3 +14,4 @@ globaltoc_collapse = false globaltoc_includehidden = false globaltoc_maxdepth = 1 nocover = false +notoc = false