diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-10-03 16:34:57 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-10-03 16:34:57 +0900 |
commit | 1fbca4997066de1be565b9b5984b04d725df896c (patch) | |
tree | a1886d86434641f481292217a405c48b0c538c97 /sphinx/application.py | |
parent | 9922923d6f2ef12e24afd7a4f0b0d6533fc80737 (diff) | |
download | sphinx-git-1fbca4997066de1be565b9b5984b04d725df896c.tar.gz |
Close #9683: Revert the removal of ``add_stylesheet()`` API
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.
Diffstat (limited to 'sphinx/application.py')
-rw-r--r-- | sphinx/application.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sphinx/application.py b/sphinx/application.py index b55eb76c1..4a75a83fe 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -1046,6 +1046,26 @@ class Sphinx: 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. |