Skip to content

Commit f297b9d

Browse files
committed
Fix creating HTMLThemeFactory objects in third-party extensions
1 parent e5cacbc commit f297b9d

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

CHANGES.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ Bugs fixed
3535
Patch by Adam Turner
3636
* #14050: LaTeXTranslator fails to build documents using the "acronym"
3737
standard role.
38-
Patch (PR #14202) by Günter Milde
39-
38+
Patch by Günter Milde
39+
* #14207: Fix creating ``HTMLThemeFactory`` objects in third-party extensions.
40+
Patch by Adam Turner
4041

4142
Testing
4243
-------

sphinx/theming.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
import sys
1111
import tempfile
1212
import tomllib
13+
import warnings
1314
from importlib.metadata import entry_points
1415
from pathlib import Path
1516
from typing import TYPE_CHECKING
1617
from zipfile import ZipFile
1718

1819
from sphinx import package_dir
1920
from sphinx.config import check_confval_types as _config_post_init
21+
from sphinx.deprecation import RemovedInSphinx10Warning
2022
from sphinx.errors import ThemeError
2123
from sphinx.locale import __
2224
from sphinx.util import logging
@@ -152,12 +154,30 @@ class HTMLThemeFactory:
152154

153155
def __init__(
154156
self,
157+
_deprecated_positional_parameter: Sphinx | None = None,
158+
/,
155159
*,
156-
confdir: Path,
157-
app: Sphinx,
158-
config: Config,
159-
registry: SphinxComponentRegistry,
160+
confdir: Path | None = None,
161+
app: Sphinx | None = None,
162+
config: Config | None = None,
163+
registry: SphinxComponentRegistry | None = None,
160164
) -> None:
165+
if _deprecated_positional_parameter is not None:
166+
warnings.warn(
167+
'Positional parameters for HTMLThemeFactory are deprecated, '
168+
'and will be removed in Sphinx 10. '
169+
'Please use keyword parameters instead.',
170+
category=RemovedInSphinx10Warning,
171+
stacklevel=2,
172+
)
173+
app = _deprecated_positional_parameter
174+
confdir = app.confdir
175+
config = app.config
176+
registry = app.registry
177+
assert app is not None
178+
assert confdir is not None
179+
assert config is not None
180+
assert registry is not None
161181
self._app = app
162182
self._confdir = confdir
163183
self._themes = registry.html_themes

0 commit comments

Comments
 (0)