Skip to content

Commit

Permalink
Use sphinx.errors.ConfigError (#697)
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Aug 17, 2023
1 parent d2e2448 commit 3631ffc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/furo/__init__.py
Expand Up @@ -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

Expand Down Expand Up @@ -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."
)
Expand Down Expand Up @@ -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."
)
Expand Down

0 comments on commit 3631ffc

Please sign in to comment.