Skip to content

Commit

Permalink
Close #9683: Revert the removal of add_stylesheet() API
Browse files Browse the repository at this point in the history
It will be kept until the Sphinx-6.0 release.

Note: Now it emits a warning instead of DeprecationWarning to let the
users know the deprecation.
  • Loading branch information
tk0miya committed Oct 3, 2021
1 parent 9922923 commit 1fbca49
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -22,6 +22,8 @@ Features added
* #9691: C, added new info-field ``retval``
for :rst:dir:`c:function` and :rst:dir:`c:macro`.
* C++, added new info-field ``retval`` for :rst:dir:`cpp:function`.
* #9683: Revert the removal of ``add_stylesheet()`` API. It will be kept until
the Sphinx-6.0 release

Bugs fixed
----------
Expand Down
2 changes: 1 addition & 1 deletion doc/extdev/deprecated.rst
Expand Up @@ -1207,7 +1207,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()`
Expand Down
20 changes: 20 additions & 0 deletions sphinx/application.py
Expand Up @@ -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.
Expand Down

0 comments on commit 1fbca49

Please sign in to comment.