From 3631ffc4ea2f241b89bbd9b6c9d76e52a4226c56 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Thu, 17 Aug 2023 21:47:14 +0100 Subject: [PATCH] Use ``sphinx.errors.ConfigError`` (#697) --- src/furo/__init__.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/furo/__init__.py b/src/furo/__init__.py index 02030131..24711a58 100644 --- a/src/furo/__init__.py +++ b/src/furo/__init__.py @@ -16,6 +16,7 @@ from pygments.token import Text from sphinx.builders.html import StandaloneHTMLBuilder from sphinx.environment.adapters.toctree import TocTree +from sphinx.errors import ConfigError from sphinx.highlighting import PygmentsBridge from sphinx.transforms.post_transforms import SphinxPostTransform @@ -175,7 +176,7 @@ def _html_page_context( ) -> None: if "css_files" in context: if "_static/styles/furo.css" not in [c.filename for c in context["css_files"]]: - raise Exception( + raise ConfigError( "This documentation is not using `furo.css` as the stylesheet. " "If you have set `html_style` in your conf.py file, remove it." ) @@ -220,14 +221,17 @@ def _html_page_context( def _builder_inited(app: sphinx.application.Sphinx) -> None: if "furo" in app.config.extensions: - raise Exception( + raise ConfigError( "Did you list 'furo' in the `extensions` in conf.py? " "If so, please remove it. Furo does not work with non-HTML builders " "and specifying it as an `html_theme` is sufficient." ) - if not isinstance(app.builder, StandaloneHTMLBuilder): - raise Exception( + if not isinstance(app.builder, StandaloneHTMLBuilder) or app.builder.name not in { + "html", + "dirhtml", + }: + raise ConfigError( "Furo is being used as an extension in a non-HTML build. " "This should not happen." )