Skip to content

Commit 3631ffc

Browse files
authored
Use sphinx.errors.ConfigError (#697)
1 parent d2e2448 commit 3631ffc

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/furo/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from pygments.token import Text
1717
from sphinx.builders.html import StandaloneHTMLBuilder
1818
from sphinx.environment.adapters.toctree import TocTree
19+
from sphinx.errors import ConfigError
1920
from sphinx.highlighting import PygmentsBridge
2021
from sphinx.transforms.post_transforms import SphinxPostTransform
2122

@@ -175,7 +176,7 @@ def _html_page_context(
175176
) -> None:
176177
if "css_files" in context:
177178
if "_static/styles/furo.css" not in [c.filename for c in context["css_files"]]:
178-
raise Exception(
179+
raise ConfigError(
179180
"This documentation is not using `furo.css` as the stylesheet. "
180181
"If you have set `html_style` in your conf.py file, remove it."
181182
)
@@ -220,14 +221,17 @@ def _html_page_context(
220221

221222
def _builder_inited(app: sphinx.application.Sphinx) -> None:
222223
if "furo" in app.config.extensions:
223-
raise Exception(
224+
raise ConfigError(
224225
"Did you list 'furo' in the `extensions` in conf.py? "
225226
"If so, please remove it. Furo does not work with non-HTML builders "
226227
"and specifying it as an `html_theme` is sufficient."
227228
)
228229

229-
if not isinstance(app.builder, StandaloneHTMLBuilder):
230-
raise Exception(
230+
if not isinstance(app.builder, StandaloneHTMLBuilder) or app.builder.name not in {
231+
"html",
232+
"dirhtml",
233+
}:
234+
raise ConfigError(
231235
"Furo is being used as an extension in a non-HTML build. "
232236
"This should not happen."
233237
)

0 commit comments

Comments
 (0)