diff --git a/CHANGES b/CHANGES index d2d8b0985a5..39d55649b4d 100644 --- a/CHANGES +++ b/CHANGES @@ -39,6 +39,8 @@ Features added * C++, added new info-field ``retval`` for :rst:dir:`cpp:function`. * #9672: More CSS classes on Python domain descriptions * #9695: More CSS classes on Javascript domain descriptions +* #9683: Revert the removal of ``add_stylesheet()`` API. It will be kept until + the Sphinx-6.0 release Bugs fixed ---------- diff --git a/doc/extdev/deprecated.rst b/doc/extdev/deprecated.rst index 72220811f04..0a4830e79d3 100644 --- a/doc/extdev/deprecated.rst +++ b/doc/extdev/deprecated.rst @@ -1212,7 +1212,7 @@ The following is a list of deprecated interfaces. * - :meth:`~sphinx.application.Sphinx.add_stylesheet()` - 1.8 - - 4.0 + - 6.0 - :meth:`~sphinx.application.Sphinx.add_css_file()` * - :meth:`~sphinx.application.Sphinx.add_javascript()` diff --git a/sphinx/application.py b/sphinx/application.py index b55eb76c1a9..4a75a83fec3 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -1046,6 +1046,26 @@ def add_css_file(self, filename: str, priority: int = 500, **kwargs: Any) -> Non if hasattr(self.builder, 'add_css_file'): self.builder.add_css_file(filename, priority=priority, **kwargs) # type: ignore + def add_stylesheet(self, filename: str, alternate: bool = False, title: str = None + ) -> None: + """An alias of :meth:`add_css_file`. + + .. deprecated:: 1.8 + """ + logger.warning('The app.add_stylesheet() is deprecated. ' + 'Please use app.add_css_file() instead.') + + attributes = {} # type: Dict[str, Any] + if alternate: + attributes['rel'] = 'alternate stylesheet' + else: + attributes['rel'] = 'stylesheet' + + if title: + attributes['title'] = title + + self.add_css_file(filename, **attributes) + def add_latex_package(self, packagename: str, options: str = None, after_hyperref: bool = False) -> None: r"""Register a package to include in the LaTeX source code.