Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close #9683: Revert the removal of add_stylesheet() API #9699

Merged
merged 3 commits into from Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -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
----------
Expand Down
2 changes: 1 addition & 1 deletion doc/extdev/deprecated.rst
Expand Up @@ -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()`
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