mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Changed 'rel' to 'alternate'
This commit is contained in:
@@ -280,7 +280,7 @@ package.
|
||||
|
||||
.. versionadded:: 0.5
|
||||
|
||||
.. method:: Sphinx.add_stylesheet(filename, rel=None, title=None)
|
||||
.. method:: Sphinx.add_stylesheet(filename, alternate=None, title=None)
|
||||
|
||||
Add *filename* to the list of CSS files that the default HTML template will
|
||||
include. Like for :meth:`add_javascript`, the filename must be relative to
|
||||
@@ -289,8 +289,8 @@ package.
|
||||
.. versionadded:: 1.0
|
||||
|
||||
.. versionchanged:: 1.4
|
||||
Optional ``rel`` and/or ``title`` attributes can be supplied with the *rel*
|
||||
and *title* arguments.
|
||||
Optional ``alternate`` and/or ``title`` attributes can be supplied with
|
||||
the *alternate* (of boolean type) and *title* (a string) arguments.
|
||||
|
||||
.. method:: Sphinx.add_latex_package(packagename, options=None)
|
||||
|
||||
|
||||
@@ -207,14 +207,16 @@ Overriding works like this::
|
||||
{% set css_files = css_files + ["_static/mystyle.css"] %}
|
||||
|
||||
.. versionchanged:: 1.4
|
||||
Optionally, ``rel`` and/or ``title`` attributes can be provided by supplying
|
||||
a Python dictionary, in which case the filename is given in the ``filename``
|
||||
key::
|
||||
Optionally, ``alternate`` and/or ``title`` attributes can be provided by
|
||||
supplying a Python dictionary, in which case the filename is given in the
|
||||
``filename`` key::
|
||||
|
||||
{% set css_files = css_files + [{"filename":"_static/mystyle.css", "rel":"stylesheet", "title":"Default"}] %}
|
||||
{% set css_files = css_files + [{"filename":"_static/mystyle.css", "alternate":False, "title":"Default"}] %}
|
||||
|
||||
The default is no title and ``rel='stylesheet'``, but if only ``title``
|
||||
is given, the default is ``rel='alternate stylesheet'``.
|
||||
The default is no title and ``alternate=False``, but if only ``title`` is
|
||||
given, the default is ``alternate=True``. If ``alternate`` is ``True``, it
|
||||
will be translated to ``rel="alternate stylesheet"``, otherwise it will be
|
||||
``rel="stylesheet"``.
|
||||
|
||||
Helper Functions
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -681,12 +681,12 @@ class Sphinx(object):
|
||||
StandaloneHTMLBuilder.script_files.append(
|
||||
posixpath.join('_static', filename))
|
||||
|
||||
def add_stylesheet(self, filename, rel=None, title=None):
|
||||
def add_stylesheet(self, filename, alternate=None, title=None):
|
||||
self.debug('[app] adding stylesheet: %r', filename)
|
||||
from sphinx.builders.html import StandaloneHTMLBuilder
|
||||
item = {}
|
||||
if rel is not None:
|
||||
item['rel'] = rel
|
||||
if alternate is not None:
|
||||
item['alternate'] = bool(alternate)
|
||||
if title is not None:
|
||||
item['title'] = title
|
||||
if '://' in filename:
|
||||
|
||||
@@ -108,19 +108,19 @@
|
||||
{%- else %}
|
||||
{%- set filename = cssfile %}
|
||||
{%- endif %}
|
||||
{%- if cssfile.rel is defined %}
|
||||
{%- set rel = cssfile.rel %}
|
||||
{%- if cssfile.alternate is defined %}
|
||||
{%- set alt = cssfile.alternate %}
|
||||
{%- endif %}
|
||||
{%- if cssfile.title is defined and cssfile.title is string %}
|
||||
{%- if cssfile.rel is not defined %}
|
||||
{%- set rel = "alternate stylesheet" %}
|
||||
{%- if cssfile.alternate is not defined %}
|
||||
{%- set alt = True %}
|
||||
{%- endif %}
|
||||
<link rel="{{ rel }}" href="{{ pathto(filename, 1) }}" type="text/css" title="{{ cssfile.title }}" />
|
||||
<link rel="{% if alt %}alternate {% endif %}stylesheet" href="{{ pathto(filename, 1) }}" type="text/css" title="{{ cssfile.title }}" />
|
||||
{%- else %}
|
||||
{%- if cssfile.rel is not defined %}
|
||||
{%- set rel = "stylesheet" %}
|
||||
{%- if cssfile.alternate is not defined %}
|
||||
{%- set alt = False %}
|
||||
{%- endif %}
|
||||
<link rel="{{ rel }}" href="{{ pathto(filename, 1) }}" type="text/css" />
|
||||
<link rel="{% if alt %}alternate {% endif %}stylesheet" href="{{ pathto(filename, 1) }}" type="text/css" />
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- endmacro %}
|
||||
|
||||
Reference in New Issue
Block a user