Merge pull request #3663 from tk0miya/3662_deprecate_builder.css_files

deprecate builder.css_files
This commit is contained in:
Takeshi KOMIYA 2017-04-27 10:08:06 +09:00 committed by GitHub
commit 83d3fd2c36
2 changed files with 38 additions and 1 deletions

View File

@ -9,6 +9,9 @@ Incompatible changes
Deprecated
----------
* #3662: ``builder.css_files`` is deprecated. Please use ``add_stylesheet()``
API instead.
Features added
--------------

View File

@ -13,6 +13,7 @@ import os
import re
import sys
import codecs
import warnings
import posixpath
from os import path
from hashlib import md5
@ -38,6 +39,7 @@ from sphinx.util.docutils import is_html5_writer_available, __version_info__
from sphinx.util.fileutil import copy_asset
from sphinx.util.matching import patmatch, Matcher, DOTFILES
from sphinx.config import string_classes
from sphinx.deprecation import RemovedInSphinx20Warning
from sphinx.locale import _, l_
from sphinx.search import js_index
from sphinx.theming import HTMLThemeFactory
@ -86,6 +88,38 @@ def get_stable_hash(obj):
return md5(text_type(obj).encode('utf8')).hexdigest()
class CSSContainer(list):
"""The container of stylesheets.
To support the extensions which access the container directly, this wraps
the entry with Stylesheet class.
"""
def append(self, obj):
if isinstance(obj, Stylesheet):
super(CSSContainer, self).append(obj)
else:
super(CSSContainer, self).append(Stylesheet(obj, None, 'stylesheet'))
def extend(self, other):
warnings.warn('builder.css_files is deprecated. '
'Please use app.add_stylesheet() instead.',
RemovedInSphinx20Warning)
for item in other:
self.append(item)
def __iadd__(self, other):
warnings.warn('builder.css_files is deprecated. '
'Please use app.add_stylesheet() instead.',
RemovedInSphinx20Warning)
for item in other:
self.append(item)
def __add__(self, other):
ret = CSSContainer(self)
ret += other
return ret
class Stylesheet(text_type):
"""The metadata of stylesheet.
@ -135,7 +169,7 @@ class StandaloneHTMLBuilder(Builder):
script_files = ['_static/jquery.js', '_static/underscore.js',
'_static/doctools.js'] # type: List[unicode]
# Ditto for this one (Sphinx.add_stylesheet).
css_files = [] # type: List[Dict[unicode, unicode]]
css_files = CSSContainer() # type: List[Dict[unicode, unicode]]
imgpath = None # type: unicode
domain_indices = [] # type: List[Tuple[unicode, Type[Index], List[Tuple[unicode, List[List[Union[unicode, int]]]]], bool]] # NOQA