From 437e0789a4b6d7d40e80f281959323a61df48035 Mon Sep 17 00:00:00 2001 From: David Lord Date: Fri, 19 Apr 2024 10:25:23 -0700 Subject: [PATCH] compatibility with sphinx 7.3 --- CHANGES.rst | 1 + src/pallets_sphinx_themes/theme_check.py | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index a6303d0..e96a068 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,7 @@ Unreleased - Use modern packaging metadata with ``pyproject.toml`` instead of ``setup.cfg``. - Use ``flit_core`` instead of ``setuptools`` as build backend. +- Compatibility with changes in Sphinx 7.3. :pr:`100` Version 2.1.1 diff --git a/src/pallets_sphinx_themes/theme_check.py b/src/pallets_sphinx_themes/theme_check.py index c7c0192..30b32c6 100644 --- a/src/pallets_sphinx_themes/theme_check.py +++ b/src/pallets_sphinx_themes/theme_check.py @@ -1,5 +1,7 @@ from functools import wraps +from sphinx.theming import HTMLThemeFactory + def set_is_pallets_theme(app): """Set the ``is_pallets_theme`` config to ``True`` if the current @@ -10,14 +12,12 @@ def set_is_pallets_theme(app): theme = getattr(app.builder, "theme", None) - while theme is not None: - if theme.name == "pocoo": - app.config.is_pallets_theme = True - break - - theme = theme.base - else: + if theme is None: app.config.is_pallets_theme = False + return + + pocoo_dir = HTMLThemeFactory(app).create("pocoo").get_theme_dirs()[0] + app.config.is_pallets_theme = pocoo_dir in theme.get_theme_dirs() def only_pallets_theme(default=None):