mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Rename add_stylesheet() to add_css_file()
This commit is contained in:
parent
99fbd44e20
commit
3afc72fba4
2
CHANGES
2
CHANGES
@ -35,6 +35,7 @@ Deprecated
|
|||||||
* #2157: helper function ``warn()`` for HTML themes is deprecated
|
* #2157: helper function ``warn()`` for HTML themes is deprecated
|
||||||
* ``env._nitpick_ignore`` is deprecated
|
* ``env._nitpick_ignore`` is deprecated
|
||||||
* ``app.override_domain()`` is deprecated
|
* ``app.override_domain()`` is deprecated
|
||||||
|
* ``app.add_stylesheet()`` is deprecated
|
||||||
|
|
||||||
For more details, see `deprecation APIs list
|
For more details, see `deprecation APIs list
|
||||||
<http://www.sphinx-doc.org/en/master/extdev/index.html#deprecated-apis>`_
|
<http://www.sphinx-doc.org/en/master/extdev/index.html#deprecated-apis>`_
|
||||||
@ -58,7 +59,6 @@ Features added
|
|||||||
* LaTeX: new key ``'fvset'`` for :confval:`latex_elements`. For
|
* LaTeX: new key ``'fvset'`` for :confval:`latex_elements`. For
|
||||||
XeLaTeX/LuaLaTeX its default sets ``fanvyvrb`` to use normal, not small,
|
XeLaTeX/LuaLaTeX its default sets ``fanvyvrb`` to use normal, not small,
|
||||||
fontsize in code-blocks (refs: #4793)
|
fontsize in code-blocks (refs: #4793)
|
||||||
* ``app.add_stylesheet()`` allows additional attributes
|
|
||||||
|
|
||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
@ -113,6 +113,11 @@ The following is a list of deprecated interface.
|
|||||||
- (will be) Removed
|
- (will be) Removed
|
||||||
- Alternatives
|
- Alternatives
|
||||||
|
|
||||||
|
* - :meth:`~sphinx.application.Sphinx.add_stylesheet()`
|
||||||
|
- 1.8
|
||||||
|
- 4.0
|
||||||
|
- :meth:`~sphinx.application.Sphinx.add_css_file()`
|
||||||
|
|
||||||
* - ``sphinx.application.Sphinx.override_domain()``
|
* - ``sphinx.application.Sphinx.override_domain()``
|
||||||
- 1.8
|
- 1.8
|
||||||
- 3.0
|
- 3.0
|
||||||
|
@ -27,7 +27,9 @@ from six.moves import cStringIO
|
|||||||
import sphinx
|
import sphinx
|
||||||
from sphinx import package_dir, locale
|
from sphinx import package_dir, locale
|
||||||
from sphinx.config import Config
|
from sphinx.config import Config
|
||||||
from sphinx.deprecation import RemovedInSphinx20Warning, RemovedInSphinx30Warning
|
from sphinx.deprecation import (
|
||||||
|
RemovedInSphinx20Warning, RemovedInSphinx30Warning, RemovedInSphinx40Warning
|
||||||
|
)
|
||||||
from sphinx.environment import BuildEnvironment
|
from sphinx.environment import BuildEnvironment
|
||||||
from sphinx.errors import (
|
from sphinx.errors import (
|
||||||
ApplicationError, ConfigError, ExtensionError, VersionRequirementError
|
ApplicationError, ConfigError, ExtensionError, VersionRequirementError
|
||||||
@ -1001,7 +1003,7 @@ class Sphinx(object):
|
|||||||
StandaloneHTMLBuilder.script_files.append(
|
StandaloneHTMLBuilder.script_files.append(
|
||||||
posixpath.join('_static', filename))
|
posixpath.join('_static', filename))
|
||||||
|
|
||||||
def add_stylesheet(self, filename, **kwargs):
|
def add_css_file(self, filename, **kwargs):
|
||||||
# type: (unicode, **unicode) -> None
|
# type: (unicode, **unicode) -> None
|
||||||
"""Register a stylesheet to include in the HTML output.
|
"""Register a stylesheet to include in the HTML output.
|
||||||
|
|
||||||
@ -1012,14 +1014,14 @@ class Sphinx(object):
|
|||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
app.add_stylesheet('custom.css')
|
app.add_css_file('custom.css')
|
||||||
# => <link rel="stylesheet" href="_static/custom.css" type="text/css" />
|
# => <link rel="stylesheet" href="_static/custom.css" type="text/css" />
|
||||||
|
|
||||||
app.add_stylesheet('print.css', media='print')
|
app.add_css_file('print.css', media='print')
|
||||||
# => <link rel="stylesheet" href="_static/print.css"
|
# => <link rel="stylesheet" href="_static/print.css"
|
||||||
# type="text/css" media="print" />
|
# type="text/css" media="print" />
|
||||||
|
|
||||||
app.add_stylesheet('fancy.css', rel='alternate stylesheet', title='fancy')
|
app.add_css_file('fancy.css', rel='alternate stylesheet', title='fancy')
|
||||||
# => <link rel="alternate stylesheet" href="_static/fancy.css"
|
# => <link rel="alternate stylesheet" href="_static/fancy.css"
|
||||||
# type="text/css" title="fancy" />
|
# type="text/css" title="fancy" />
|
||||||
|
|
||||||
@ -1033,18 +1035,32 @@ class Sphinx(object):
|
|||||||
<https://mdn.io/Web/CSS/Alternative_style_sheets>`__.
|
<https://mdn.io/Web/CSS/Alternative_style_sheets>`__.
|
||||||
|
|
||||||
.. versionchanged:: 1.8
|
.. versionchanged:: 1.8
|
||||||
Allows keyword arguments as attributes of link tag.
|
Renamed from ``app.add_stylesheet()``.
|
||||||
|
And it allows keyword arguments as attributes of link tag.
|
||||||
"""
|
"""
|
||||||
logger.debug('[app] adding stylesheet: %r', filename)
|
logger.debug('[app] adding stylesheet: %r', filename)
|
||||||
if '://' not in filename:
|
if '://' not in filename:
|
||||||
filename = posixpath.join('_static', filename)
|
filename = posixpath.join('_static', filename)
|
||||||
if kwargs.pop('alternate', None):
|
|
||||||
warnings.warn('The alternate option for app.add_stylesheet() is deprecated. '
|
|
||||||
'Please use rel="alternate stylesheet" option instead.',
|
|
||||||
RemovedInSphinx30Warning)
|
|
||||||
kwargs['rel'] = 'alternate stylesheet'
|
|
||||||
self.registry.add_css_files(filename, **kwargs)
|
self.registry.add_css_files(filename, **kwargs)
|
||||||
|
|
||||||
|
def add_stylesheet(self, filename, alternate=False, title=None):
|
||||||
|
# type: (unicode, bool, unicode) -> None
|
||||||
|
"""An alias of :meth:`add_css_file`."""
|
||||||
|
warnings.warn('The app.add_stylesheet() is deprecated. '
|
||||||
|
'Please use app.add_css_file() instead.',
|
||||||
|
RemovedInSphinx40Warning)
|
||||||
|
|
||||||
|
attributes = {} # type: Dict[unicode, unicode]
|
||||||
|
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, options=None):
|
def add_latex_package(self, packagename, options=None):
|
||||||
# type: (unicode, unicode) -> None
|
# type: (unicode, unicode) -> None
|
||||||
r"""Register a package to include in the LaTeX source code.
|
r"""Register a package to include in the LaTeX source code.
|
||||||
|
@ -33,6 +33,10 @@ class RemovedInSphinx30Warning(PendingDeprecationWarning):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class RemovedInSphinx40Warning(PendingDeprecationWarning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
RemovedInNextVersionWarning = RemovedInSphinx18Warning
|
RemovedInNextVersionWarning = RemovedInSphinx18Warning
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user