Changed 'rel' to 'alternate'

This commit is contained in:
Ignacio Fdez. Galván
2015-03-12 10:51:45 +01:00
parent 2fdd06be44
commit 204b9cc521
4 changed files with 22 additions and 20 deletions

View File

@@ -280,7 +280,7 @@ package.
.. versionadded:: 0.5 .. 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 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 include. Like for :meth:`add_javascript`, the filename must be relative to
@@ -289,8 +289,8 @@ package.
.. versionadded:: 1.0 .. versionadded:: 1.0
.. versionchanged:: 1.4 .. versionchanged:: 1.4
Optional ``rel`` and/or ``title`` attributes can be supplied with the *rel* Optional ``alternate`` and/or ``title`` attributes can be supplied with
and *title* arguments. the *alternate* (of boolean type) and *title* (a string) arguments.
.. method:: Sphinx.add_latex_package(packagename, options=None) .. method:: Sphinx.add_latex_package(packagename, options=None)

View File

@@ -207,14 +207,16 @@ Overriding works like this::
{% set css_files = css_files + ["_static/mystyle.css"] %} {% set css_files = css_files + ["_static/mystyle.css"] %}
.. versionchanged:: 1.4 .. versionchanged:: 1.4
Optionally, ``rel`` and/or ``title`` attributes can be provided by supplying Optionally, ``alternate`` and/or ``title`` attributes can be provided by
a Python dictionary, in which case the filename is given in the ``filename`` supplying a Python dictionary, in which case the filename is given in the
key:: ``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`` The default is no title and ``alternate=False``, but if only ``title`` is
is given, the default is ``rel='alternate stylesheet'``. 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 Helper Functions
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~

View File

@@ -681,12 +681,12 @@ class Sphinx(object):
StandaloneHTMLBuilder.script_files.append( StandaloneHTMLBuilder.script_files.append(
posixpath.join('_static', filename)) 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) self.debug('[app] adding stylesheet: %r', filename)
from sphinx.builders.html import StandaloneHTMLBuilder from sphinx.builders.html import StandaloneHTMLBuilder
item = {} item = {}
if rel is not None: if alternate is not None:
item['rel'] = rel item['alternate'] = bool(alternate)
if title is not None: if title is not None:
item['title'] = title item['title'] = title
if '://' in filename: if '://' in filename:

View File

@@ -108,19 +108,19 @@
{%- else %} {%- else %}
{%- set filename = cssfile %} {%- set filename = cssfile %}
{%- endif %} {%- endif %}
{%- if cssfile.rel is defined %} {%- if cssfile.alternate is defined %}
{%- set rel = cssfile.rel %} {%- set alt = cssfile.alternate %}
{%- endif %} {%- endif %}
{%- if cssfile.title is defined and cssfile.title is string %} {%- if cssfile.title is defined and cssfile.title is string %}
{%- if cssfile.rel is not defined %} {%- if cssfile.alternate is not defined %}
{%- set rel = "alternate stylesheet" %} {%- set alt = True %}
{%- endif %} {%- 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 %} {%- else %}
{%- if cssfile.rel is not defined %} {%- if cssfile.alternate is not defined %}
{%- set rel = "stylesheet" %} {%- set alt = False %}
{%- endif %} {%- 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 %} {%- endif %}
{%- endfor %} {%- endfor %}
{%- endmacro %} {%- endmacro %}