Merge pull request #5532 from tk0miya/5471_better_deprecation_warnings

Fix #5471: Show appropriate warning for deprecated APIs
This commit is contained in:
Takeshi KOMIYA 2018-10-25 22:58:54 +09:00 committed by GitHub
commit d0b6c52954
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 114 additions and 113 deletions

View File

@ -13,6 +13,8 @@ Deprecated
Features added Features added
-------------- --------------
* #5471: Show appropriate deprecation warnings
Bugs fixed Bugs fixed
---------- ----------

View File

@ -31,8 +31,7 @@ if False:
# by default, all DeprecationWarning under sphinx package will be emit. # by default, all DeprecationWarning under sphinx package will be emit.
# Users can avoid this by using environment variable: PYTHONWARNINGS= # Users can avoid this by using environment variable: PYTHONWARNINGS=
if 'PYTHONWARNINGS' not in os.environ: if 'PYTHONWARNINGS' not in os.environ:
warnings.filterwarnings('default', warnings.filterwarnings('default', category=RemovedInNextVersionWarning)
category=RemovedInNextVersionWarning, module='sphinx')
# docutils.io using mode='rU' for open # docutils.io using mode='rU' for open
warnings.filterwarnings('ignore', "'U' mode is deprecated", warnings.filterwarnings('ignore', "'U' mode is deprecated",
DeprecationWarning, module='docutils.io') DeprecationWarning, module='docutils.io')

View File

@ -205,7 +205,7 @@ class math(nodes.math):
if key == 'latex' and 'latex' not in self.attributes: if key == 'latex' and 'latex' not in self.attributes:
warnings.warn("math node for Sphinx was replaced by docutils'. " warnings.warn("math node for Sphinx was replaced by docutils'. "
"Therefore please use ``node.astext()`` to get an equation instead.", "Therefore please use ``node.astext()`` to get an equation instead.",
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return self.astext() return self.astext()
else: else:
return nodes.math.__getitem__(self, key) return nodes.math.__getitem__(self, key)
@ -224,7 +224,7 @@ class math_block(nodes.math_block):
if key == 'latex' and 'latex' not in self.attributes: if key == 'latex' and 'latex' not in self.attributes:
warnings.warn("displaymath node for Sphinx was replaced by docutils'. " warnings.warn("displaymath node for Sphinx was replaced by docutils'. "
"Therefore please use ``node.astext()`` to get an equation instead.", "Therefore please use ``node.astext()`` to get an equation instead.",
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return self.astext() return self.astext()
else: else:
return nodes.math_block.__getitem__(self, key) return nodes.math_block.__getitem__(self, key)

View File

@ -385,7 +385,7 @@ class Sphinx(object):
Use :mod:`sphinx.util.logging` instead. Use :mod:`sphinx.util.logging` instead.
""" """
warnings.warn('app.warning() is now deprecated. Use sphinx.util.logging instead.', warnings.warn('app.warning() is now deprecated. Use sphinx.util.logging instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
logger.warning(message, type=type, subtype=subtype, location=location) logger.warning(message, type=type, subtype=subtype, location=location)
def info(self, message='', nonl=False): def info(self, message='', nonl=False):
@ -399,7 +399,7 @@ class Sphinx(object):
Use :mod:`sphinx.util.logging` instead. Use :mod:`sphinx.util.logging` instead.
""" """
warnings.warn('app.info() is now deprecated. Use sphinx.util.logging instead.', warnings.warn('app.info() is now deprecated. Use sphinx.util.logging instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
logger.info(message, nonl=nonl) logger.info(message, nonl=nonl)
def verbose(self, message, *args, **kwargs): def verbose(self, message, *args, **kwargs):
@ -410,7 +410,7 @@ class Sphinx(object):
Use :mod:`sphinx.util.logging` instead. Use :mod:`sphinx.util.logging` instead.
""" """
warnings.warn('app.verbose() is now deprecated. Use sphinx.util.logging instead.', warnings.warn('app.verbose() is now deprecated. Use sphinx.util.logging instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
logger.verbose(message, *args, **kwargs) logger.verbose(message, *args, **kwargs)
def debug(self, message, *args, **kwargs): def debug(self, message, *args, **kwargs):
@ -421,7 +421,7 @@ class Sphinx(object):
Use :mod:`sphinx.util.logging` instead. Use :mod:`sphinx.util.logging` instead.
""" """
warnings.warn('app.debug() is now deprecated. Use sphinx.util.logging instead.', warnings.warn('app.debug() is now deprecated. Use sphinx.util.logging instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
logger.debug(message, *args, **kwargs) logger.debug(message, *args, **kwargs)
def debug2(self, message, *args, **kwargs): def debug2(self, message, *args, **kwargs):
@ -432,7 +432,7 @@ class Sphinx(object):
Use :mod:`sphinx.util.logging` instead. Use :mod:`sphinx.util.logging` instead.
""" """
warnings.warn('app.debug2() is now deprecated. Use debug() instead.', warnings.warn('app.debug2() is now deprecated. Use debug() instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
logger.debug(message, *args, **kwargs) logger.debug(message, *args, **kwargs)
# ---- general extensibility interface ------------------------------------- # ---- general extensibility interface -------------------------------------
@ -470,7 +470,7 @@ class Sphinx(object):
""" """
warnings.warn('app.import_object() is deprecated. ' warnings.warn('app.import_object() is deprecated. '
'Use sphinx.util.add_object_type() instead.', 'Use sphinx.util.add_object_type() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return import_object(objname, source=None) return import_object(objname, source=None)
# event interface # event interface
@ -663,7 +663,7 @@ class Sphinx(object):
# type: () -> Dict[nodes.Node, Tuple[unicode, TitleGetter]] # type: () -> Dict[nodes.Node, Tuple[unicode, TitleGetter]]
warnings.warn('app.enumerable_nodes() is deprecated. ' warnings.warn('app.enumerable_nodes() is deprecated. '
'Use app.get_domain("std").enumerable_nodes instead.', 'Use app.get_domain("std").enumerable_nodes instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return self.registry.enumerable_nodes return self.registry.enumerable_nodes
def add_directive(self, name, obj, content=None, arguments=None, override=False, **options): # NOQA def add_directive(self, name, obj, content=None, arguments=None, override=False, **options): # NOQA
@ -801,7 +801,7 @@ class Sphinx(object):
""" """
warnings.warn('app.override_domain() is deprecated. ' warnings.warn('app.override_domain() is deprecated. '
'Use app.add_domain() with override option instead.', 'Use app.add_domain() with override option instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
self.registry.add_domain(domain, override=True) self.registry.add_domain(domain, override=True)
def add_directive_to_domain(self, domain, name, obj, has_content=None, argument_spec=None, def add_directive_to_domain(self, domain, name, obj, has_content=None, argument_spec=None,
@ -924,7 +924,7 @@ class Sphinx(object):
""" """
warnings.warn('app.add_description_unit() is now deprecated. ' warnings.warn('app.add_description_unit() is now deprecated. '
'Use app.add_object_type() instead.', 'Use app.add_object_type() instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
self.add_object_type(directivename, rolename, indextemplate, parse_node, self.add_object_type(directivename, rolename, indextemplate, parse_node,
ref_nodeclass, objname, doc_field_types) ref_nodeclass, objname, doc_field_types)
@ -1013,7 +1013,7 @@ class Sphinx(object):
"""An alias of :meth:`add_js_file`.""" """An alias of :meth:`add_js_file`."""
warnings.warn('The app.add_javascript() is deprecated. ' warnings.warn('The app.add_javascript() is deprecated. '
'Please use app.add_js_file() instead.', 'Please use app.add_js_file() instead.',
RemovedInSphinx40Warning) RemovedInSphinx40Warning, stacklevel=2)
self.add_js_file(filename, **kwargs) self.add_js_file(filename, **kwargs)
def add_js_file(self, filename, **kwargs): def add_js_file(self, filename, **kwargs):
@ -1088,7 +1088,7 @@ class Sphinx(object):
"""An alias of :meth:`add_css_file`.""" """An alias of :meth:`add_css_file`."""
warnings.warn('The app.add_stylesheet() is deprecated. ' warnings.warn('The app.add_stylesheet() is deprecated. '
'Please use app.add_css_file() instead.', 'Please use app.add_css_file() instead.',
RemovedInSphinx40Warning) RemovedInSphinx40Warning, stacklevel=2)
attributes = {} # type: Dict[unicode, unicode] attributes = {} # type: Dict[unicode, unicode]
if alternate: if alternate:

View File

@ -150,7 +150,7 @@ class Builder(object):
warnings.warn('builder.translator_class() is now deprecated. ' warnings.warn('builder.translator_class() is now deprecated. '
'Please use builder.create_translator() and ' 'Please use builder.create_translator() and '
'builder.default_translator_class instead.', 'builder.default_translator_class instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
return None return None
return self.create_translator return self.create_translator

View File

@ -109,7 +109,7 @@ class CSSContainer(list):
# type: (int, Union[unicode, Stylesheet]) -> None # type: (int, Union[unicode, Stylesheet]) -> None
warnings.warn('builder.css_files is deprecated. ' warnings.warn('builder.css_files is deprecated. '
'Please use app.add_stylesheet() instead.', 'Please use app.add_stylesheet() instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
if isinstance(obj, Stylesheet): if isinstance(obj, Stylesheet):
super(CSSContainer, self).insert(index, obj) super(CSSContainer, self).insert(index, obj)
else: else:
@ -119,7 +119,7 @@ class CSSContainer(list):
# type: (List[Union[unicode, Stylesheet]]) -> None # type: (List[Union[unicode, Stylesheet]]) -> None
warnings.warn('builder.css_files is deprecated. ' warnings.warn('builder.css_files is deprecated. '
'Please use app.add_stylesheet() instead.', 'Please use app.add_stylesheet() instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
for item in other: for item in other:
self.append(item) self.append(item)
@ -127,7 +127,7 @@ class CSSContainer(list):
# type: (List[Union[unicode, Stylesheet]]) -> CSSContainer # type: (List[Union[unicode, Stylesheet]]) -> CSSContainer
warnings.warn('builder.css_files is deprecated. ' warnings.warn('builder.css_files is deprecated. '
'Please use app.add_stylesheet() instead.', 'Please use app.add_stylesheet() instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
for item in other: for item in other:
self.append(item) self.append(item)
return self return self
@ -169,14 +169,14 @@ class JSContainer(list):
# type: (int, unicode) -> None # type: (int, unicode) -> None
warnings.warn('builder.script_files is deprecated. ' warnings.warn('builder.script_files is deprecated. '
'Please use app.add_js_file() instead.', 'Please use app.add_js_file() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
super(JSContainer, self).insert(index, obj) super(JSContainer, self).insert(index, obj)
def extend(self, other): # type: ignore def extend(self, other): # type: ignore
# type: (List[unicode]) -> None # type: (List[unicode]) -> None
warnings.warn('builder.script_files is deprecated. ' warnings.warn('builder.script_files is deprecated. '
'Please use app.add_js_file() instead.', 'Please use app.add_js_file() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
for item in other: for item in other:
self.append(item) self.append(item)
@ -184,7 +184,7 @@ class JSContainer(list):
# type: (List[unicode]) -> JSContainer # type: (List[unicode]) -> JSContainer
warnings.warn('builder.script_files is deprecated. ' warnings.warn('builder.script_files is deprecated. '
'Please use app.add_js_file() instead.', 'Please use app.add_js_file() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
for item in other: for item in other:
self.append(item) self.append(item)
return self return self
@ -1092,7 +1092,7 @@ class StandaloneHTMLBuilder(Builder):
warnings.warn('Now html_sidebars only allows list of sidebar ' warnings.warn('Now html_sidebars only allows list of sidebar '
'templates as a value. Support for a string value ' 'templates as a value. Support for a string value '
'will be removed at Sphinx-2.0.', 'will be removed at Sphinx-2.0.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
ctx['sidebars'] = sidebars ctx['sidebars'] = sidebars
ctx['customsidebar'] = customsidebar ctx['customsidebar'] = customsidebar
@ -1161,7 +1161,7 @@ class StandaloneHTMLBuilder(Builder):
"""Simple warn() wrapper for themes.""" """Simple warn() wrapper for themes."""
warnings.warn('The template function warn() was deprecated. ' warnings.warn('The template function warn() was deprecated. '
'Use warning() instead.', 'Use warning() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
self.warn(*args, **kwargs) self.warn(*args, **kwargs)
return '' # return empty string return '' # return empty string
ctx['warn'] = warn ctx['warn'] = warn

View File

@ -27,26 +27,26 @@ if False:
def handle_exception(app, args, exception, stderr=sys.stderr): def handle_exception(app, args, exception, stderr=sys.stderr):
# type: (Sphinx, Any, Union[Exception, KeyboardInterrupt], IO) -> None # type: (Sphinx, Any, Union[Exception, KeyboardInterrupt], IO) -> None
warnings.warn('sphinx.cmdline module is deprecated. Use sphinx.cmd.build instead.', warnings.warn('sphinx.cmdline module is deprecated. Use sphinx.cmd.build instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
build.handle_exception(app, args, exception, stderr) build.handle_exception(app, args, exception, stderr)
def jobs_argument(value): def jobs_argument(value):
# type: (str) -> int # type: (str) -> int
warnings.warn('sphinx.cmdline module is deprecated. Use sphinx.cmd.build instead.', warnings.warn('sphinx.cmdline module is deprecated. Use sphinx.cmd.build instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return build.jobs_argument(value) return build.jobs_argument(value)
def get_parser(): def get_parser():
# type: () -> argparse.ArgumentParser # type: () -> argparse.ArgumentParser
warnings.warn('sphinx.cmdline module is deprecated. Use sphinx.cmd.build instead.', warnings.warn('sphinx.cmdline module is deprecated. Use sphinx.cmd.build instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return build.get_parser() return build.get_parser()
def main(argv=sys.argv[1:]): # type: ignore def main(argv=sys.argv[1:]): # type: ignore
# type: (List[unicode]) -> int # type: (List[unicode]) -> int
warnings.warn('sphinx.cmdline module is deprecated. Use sphinx.cmd.build instead.', warnings.warn('sphinx.cmdline module is deprecated. Use sphinx.cmd.build instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return build.main(argv) return build.main(argv)

View File

@ -168,7 +168,7 @@ class Config(object):
# old style arguments: (dirname, filename, overrides, tags) # old style arguments: (dirname, filename, overrides, tags)
warnings.warn('The argument of Config() class has been changed. ' warnings.warn('The argument of Config() class has been changed. '
'Use Config.read() to read configuration from conf.py.', 'Use Config.read() to read configuration from conf.py.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
dirname, filename, overrides, tags = args dirname, filename, overrides, tags = args
if dirname is None: if dirname is None:
config = {} # type: Dict[unicode, Any] config = {} # type: Dict[unicode, Any]
@ -206,13 +206,13 @@ class Config(object):
def check_types(self): def check_types(self):
# type: () -> None # type: () -> None
warnings.warn('Config.check_types() is deprecated. Use check_confval_types() instead.', warnings.warn('Config.check_types() is deprecated. Use check_confval_types() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
check_confval_types(None, self) check_confval_types(None, self)
def check_unicode(self): def check_unicode(self):
# type: () -> None # type: () -> None
warnings.warn('Config.check_unicode() is deprecated. Use check_unicode() instead.', warnings.warn('Config.check_unicode() is deprecated. Use check_unicode() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
check_unicode(self) check_unicode(self)
def convert_overrides(self, name, value): def convert_overrides(self, name, value):

View File

@ -43,25 +43,25 @@ class DeprecatedDict(dict):
def __setitem__(self, key, value): def __setitem__(self, key, value):
# type: (unicode, Any) -> None # type: (unicode, Any) -> None
warnings.warn(self.message, self.warning) warnings.warn(self.message, self.warning, stacklevel=2)
super(DeprecatedDict, self).__setitem__(key, value) super(DeprecatedDict, self).__setitem__(key, value)
def setdefault(self, key, default=None): def setdefault(self, key, default=None):
# type: (unicode, Any) -> None # type: (unicode, Any) -> None
warnings.warn(self.message, self.warning) warnings.warn(self.message, self.warning, stacklevel=2)
return super(DeprecatedDict, self).setdefault(key, default) return super(DeprecatedDict, self).setdefault(key, default)
def __getitem__(self, key): def __getitem__(self, key):
# type: (unicode) -> None # type: (unicode) -> None
warnings.warn(self.message, self.warning) warnings.warn(self.message, self.warning, stacklevel=2)
return super(DeprecatedDict, self).__getitem__(key) return super(DeprecatedDict, self).__getitem__(key)
def get(self, key, default=None): def get(self, key, default=None):
# type: (unicode, Any) -> None # type: (unicode, Any) -> None
warnings.warn(self.message, self.warning) warnings.warn(self.message, self.warning, stacklevel=2)
return super(DeprecatedDict, self).get(key, default) return super(DeprecatedDict, self).get(key, default)
def update(self, other=None): # type: ignore def update(self, other=None): # type: ignore
# type: (Dict) -> None # type: (Dict) -> None
warnings.warn(self.message, self.warning) warnings.warn(self.message, self.warning, stacklevel=2)
super(DeprecatedDict, self).update(other) super(DeprecatedDict, self).update(other)

View File

@ -62,7 +62,7 @@ class HighlightLang(Highlight):
# type: () -> List[nodes.Node] # type: () -> List[nodes.Node]
warnings.warn('highlightlang directive is deprecated. ' warnings.warn('highlightlang directive is deprecated. '
'Please use highlight directive instead.', 'Please use highlight directive instead.',
RemovedInSphinx40Warning) RemovedInSphinx40Warning, stacklevel=2)
return Highlight.run(self) return Highlight.run(self)

View File

@ -953,7 +953,7 @@ class StandardDomain(Domain):
""" """
warnings.warn('StandardDomain.get_figtype() is deprecated. ' warnings.warn('StandardDomain.get_figtype() is deprecated. '
'Please use get_enumerable_node_type() instead.', 'Please use get_enumerable_node_type() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return self.get_enumerable_node_type(node) return self.get_enumerable_node_type(node)
def get_fignumber(self, env, builder, figtype, docname, target_node): def get_fignumber(self, env, builder, figtype, docname, target_node):

View File

@ -276,7 +276,7 @@ class BuildEnvironment(object):
def set_warnfunc(self, func): def set_warnfunc(self, func):
# type: (Callable) -> None # type: (Callable) -> None
warnings.warn('env.set_warnfunc() is now deprecated. Use sphinx.util.logging instead.', warnings.warn('env.set_warnfunc() is now deprecated. Use sphinx.util.logging instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
def set_versioning_method(self, method, compare): def set_versioning_method(self, method, compare):
# type: (unicode, bool) -> None # type: (unicode, bool) -> None
@ -572,7 +572,7 @@ class BuildEnvironment(object):
""" """
warnings.warn('env.note_toctree() is deprecated. ' warnings.warn('env.note_toctree() is deprecated. '
'Use sphinx.environment.adapters.toctree.TocTree instead.', 'Use sphinx.environment.adapters.toctree.TocTree instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
TocTree(self).note(docname, toctreenode) TocTree(self).note(docname, toctreenode)
def get_toc_for(self, docname, builder): def get_toc_for(self, docname, builder):
@ -580,7 +580,7 @@ class BuildEnvironment(object):
"""Return a TOC nodetree -- for use on the same page only!""" """Return a TOC nodetree -- for use on the same page only!"""
warnings.warn('env.get_toc_for() is deprecated. ' warnings.warn('env.get_toc_for() is deprecated. '
'Use sphinx.environment.adapters.toctre.TocTree instead.', 'Use sphinx.environment.adapters.toctre.TocTree instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
return TocTree(self).get_toc_for(docname, builder) return TocTree(self).get_toc_for(docname, builder)
def get_toctree_for(self, docname, builder, collapse, **kwds): def get_toctree_for(self, docname, builder, collapse, **kwds):
@ -588,7 +588,7 @@ class BuildEnvironment(object):
"""Return the global TOC nodetree.""" """Return the global TOC nodetree."""
warnings.warn('env.get_toctree_for() is deprecated. ' warnings.warn('env.get_toctree_for() is deprecated. '
'Use sphinx.environment.adapters.toctre.TocTree instead.', 'Use sphinx.environment.adapters.toctre.TocTree instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
return TocTree(self).get_toctree_for(docname, builder, collapse, **kwds) return TocTree(self).get_toctree_for(docname, builder, collapse, **kwds)
def get_domain(self, domainname): def get_domain(self, domainname):
@ -683,7 +683,7 @@ class BuildEnvironment(object):
# type: (Builder, bool, Pattern) -> List[Tuple[unicode, List[Tuple[unicode, List[unicode]]]]] # NOQA # type: (Builder, bool, Pattern) -> List[Tuple[unicode, List[Tuple[unicode, List[unicode]]]]] # NOQA
warnings.warn('env.create_index() is deprecated. ' warnings.warn('env.create_index() is deprecated. '
'Use sphinx.environment.adapters.indexentreis.IndexEntries instead.', 'Use sphinx.environment.adapters.indexentreis.IndexEntries instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
return IndexEntries(self).create_index(builder, return IndexEntries(self).create_index(builder,
group_entries=group_entries, group_entries=group_entries,
_fixre=_fixre) _fixre=_fixre)
@ -749,32 +749,32 @@ class BuildEnvironment(object):
def update(self, config, srcdir, doctreedir): def update(self, config, srcdir, doctreedir):
# type: (Config, unicode, unicode) -> List[unicode] # type: (Config, unicode, unicode) -> List[unicode]
warnings.warn('env.update() is deprecated. Please use builder.read() instead.', warnings.warn('env.update() is deprecated. Please use builder.read() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return self.app.builder.read() return self.app.builder.read()
def _read_serial(self, docnames, app): def _read_serial(self, docnames, app):
# type: (List[unicode], Sphinx) -> None # type: (List[unicode], Sphinx) -> None
warnings.warn('env._read_serial() is deprecated. Please use builder.read() instead.', warnings.warn('env._read_serial() is deprecated. Please use builder.read() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return self.app.builder._read_serial(docnames) return self.app.builder._read_serial(docnames)
def _read_parallel(self, docnames, app, nproc): def _read_parallel(self, docnames, app, nproc):
# type: (List[unicode], Sphinx, int) -> None # type: (List[unicode], Sphinx, int) -> None
warnings.warn('env._read_parallel() is deprecated. Please use builder.read() instead.', warnings.warn('env._read_parallel() is deprecated. Please use builder.read() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return self.app.builder._read_parallel(docnames, nproc) return self.app.builder._read_parallel(docnames, nproc)
def read_doc(self, docname, app=None): def read_doc(self, docname, app=None):
# type: (unicode, Sphinx) -> None # type: (unicode, Sphinx) -> None
warnings.warn('env.read_doc() is deprecated. Please use builder.read_doc() instead.', warnings.warn('env.read_doc() is deprecated. Please use builder.read_doc() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
self.app.builder.read_doc(docname) self.app.builder.read_doc(docname)
def write_doctree(self, docname, doctree): def write_doctree(self, docname, doctree):
# type: (unicode, nodes.Node) -> None # type: (unicode, nodes.Node) -> None
warnings.warn('env.write_doctree() is deprecated. ' warnings.warn('env.write_doctree() is deprecated. '
'Please use builder.write_doctree() instead.', 'Please use builder.write_doctree() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
self.app.builder.write_doctree(docname, doctree) self.app.builder.write_doctree(docname, doctree)
@property @property
@ -782,7 +782,7 @@ class BuildEnvironment(object):
# type: () -> List[unicode] # type: () -> List[unicode]
warnings.warn('env._nitpick_ignore is deprecated. ' warnings.warn('env._nitpick_ignore is deprecated. '
'Please use config.nitpick_ignore instead.', 'Please use config.nitpick_ignore instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return self.config.nitpick_ignore return self.config.nitpick_ignore
@staticmethod @staticmethod
@ -790,7 +790,7 @@ class BuildEnvironment(object):
# type: (IO, Sphinx) -> BuildEnvironment # type: (IO, Sphinx) -> BuildEnvironment
warnings.warn('BuildEnvironment.load() is deprecated. ' warnings.warn('BuildEnvironment.load() is deprecated. '
'Please use pickle.load() instead.', 'Please use pickle.load() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
try: try:
env = pickle.load(f) env = pickle.load(f)
except Exception as exc: except Exception as exc:
@ -807,7 +807,7 @@ class BuildEnvironment(object):
# type: (unicode, Sphinx) -> BuildEnvironment # type: (unicode, Sphinx) -> BuildEnvironment
warnings.warn('BuildEnvironment.loads() is deprecated. ' warnings.warn('BuildEnvironment.loads() is deprecated. '
'Please use pickle.loads() instead.', 'Please use pickle.loads() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
io = BytesIO(string) io = BytesIO(string)
return cls.load(io, app) return cls.load(io, app)
@ -816,7 +816,7 @@ class BuildEnvironment(object):
# type: (unicode, Sphinx) -> BuildEnvironment # type: (unicode, Sphinx) -> BuildEnvironment
warnings.warn('BuildEnvironment.frompickle() is deprecated. ' warnings.warn('BuildEnvironment.frompickle() is deprecated. '
'Please use pickle.load() instead.', 'Please use pickle.load() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
with open(filename, 'rb') as f: with open(filename, 'rb') as f:
return cls.load(f, app) return cls.load(f, app)
@ -825,7 +825,7 @@ class BuildEnvironment(object):
# type: (BuildEnvironment, IO) -> None # type: (BuildEnvironment, IO) -> None
warnings.warn('BuildEnvironment.dump() is deprecated. ' warnings.warn('BuildEnvironment.dump() is deprecated. '
'Please use pickle.dump() instead.', 'Please use pickle.dump() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
pickle.dump(env, f, pickle.HIGHEST_PROTOCOL) pickle.dump(env, f, pickle.HIGHEST_PROTOCOL)
@classmethod @classmethod
@ -833,7 +833,7 @@ class BuildEnvironment(object):
# type: (BuildEnvironment) -> unicode # type: (BuildEnvironment) -> unicode
warnings.warn('BuildEnvironment.dumps() is deprecated. ' warnings.warn('BuildEnvironment.dumps() is deprecated. '
'Please use pickle.dumps() instead.', 'Please use pickle.dumps() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
io = BytesIO() io = BytesIO()
cls.dump(env, io) cls.dump(env, io)
return io.getvalue() return io.getvalue()
@ -842,7 +842,7 @@ class BuildEnvironment(object):
# type: (unicode) -> None # type: (unicode) -> None
warnings.warn('env.topickle() is deprecated. ' warnings.warn('env.topickle() is deprecated. '
'Please use pickle.dump() instead.', 'Please use pickle.dump() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
with open(filename, 'wb') as f: with open(filename, 'wb') as f:
self.dump(self, f) self.dump(self, f)
@ -851,14 +851,14 @@ class BuildEnvironment(object):
# type: () -> Dict[unicode, List[Tuple[unicode, unicode, int, unicode, unicode, unicode]]] # NOQA # type: () -> Dict[unicode, List[Tuple[unicode, unicode, int, unicode, unicode, unicode]]] # NOQA
warnings.warn('env.versionchanges() is deprecated. ' warnings.warn('env.versionchanges() is deprecated. '
'Please use ChangeSetDomain instead.', 'Please use ChangeSetDomain instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return self.domaindata['changeset']['changes'] return self.domaindata['changeset']['changes']
def note_versionchange(self, type, version, node, lineno): def note_versionchange(self, type, version, node, lineno):
# type: (unicode, unicode, nodes.Node, int) -> None # type: (unicode, unicode, nodes.Node, int) -> None
warnings.warn('env.note_versionchange() is deprecated. ' warnings.warn('env.note_versionchange() is deprecated. '
'Please use ChangeSetDomain.note_changeset() instead.', 'Please use ChangeSetDomain.note_changeset() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
node['type'] = type node['type'] = type
node['version'] = version node['version'] = version
node.line = lineno node.line = lineno

View File

@ -133,7 +133,7 @@ class AutodocReporter(object):
# type: (ViewList, Reporter) -> None # type: (ViewList, Reporter) -> None
warnings.warn('AutodocReporter is now deprecated. ' warnings.warn('AutodocReporter is now deprecated. '
'Use sphinx.util.docutils.switch_source_input() instead.', 'Use sphinx.util.docutils.switch_source_input() instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
self.viewlist = viewlist self.viewlist = viewlist
self.reporter = reporter self.reporter = reporter
@ -1483,17 +1483,17 @@ class DeprecatedDict(dict):
def __setitem__(self, key, value): def __setitem__(self, key, value):
# type: (unicode, Any) -> None # type: (unicode, Any) -> None
warnings.warn(self.message, RemovedInSphinx20Warning) warnings.warn(self.message, RemovedInSphinx20Warning, stacklevel=2)
super(DeprecatedDict, self).__setitem__(key, value) super(DeprecatedDict, self).__setitem__(key, value)
def setdefault(self, key, default=None): def setdefault(self, key, default=None):
# type: (unicode, Any) -> None # type: (unicode, Any) -> None
warnings.warn(self.message, RemovedInSphinx20Warning) warnings.warn(self.message, RemovedInSphinx20Warning, stacklevel=2)
super(DeprecatedDict, self).setdefault(key, default) super(DeprecatedDict, self).setdefault(key, default)
def update(self, other=None): # type: ignore def update(self, other=None): # type: ignore
# type: (Dict) -> None # type: (Dict) -> None
warnings.warn(self.message, RemovedInSphinx20Warning) warnings.warn(self.message, RemovedInSphinx20Warning, stacklevel=2)
super(DeprecatedDict, self).update(other) super(DeprecatedDict, self).update(other)
@ -1527,7 +1527,7 @@ def add_documenter(cls):
"""Register a new Documenter.""" """Register a new Documenter."""
warnings.warn('sphinx.ext.autodoc.add_documenter() has been deprecated. ' warnings.warn('sphinx.ext.autodoc.add_documenter() has been deprecated. '
'Please use app.add_autodocumenter() instead.', 'Please use app.add_autodocumenter() instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
if not issubclass(cls, Documenter): if not issubclass(cls, Documenter):
raise ExtensionError('autodoc documenter %r must be a subclass ' raise ExtensionError('autodoc documenter %r must be a subclass '
@ -1574,7 +1574,7 @@ def merge_autodoc_default_flags(app, config):
# logger.warning() on 3.0.0 release. # logger.warning() on 3.0.0 release.
warnings.warn('autodoc_default_flags is now deprecated. ' warnings.warn('autodoc_default_flags is now deprecated. '
'Please use autodoc_default_options instead.', 'Please use autodoc_default_options instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
for option in config.autodoc_default_flags: for option in config.autodoc_default_flags:
if isinstance(option, string_types): if isinstance(option, string_types):

View File

@ -33,7 +33,7 @@ def format_annotation(annotation):
""" """
warnings.warn('format_annotation() is now deprecated. ' warnings.warn('format_annotation() is now deprecated. '
'Please use sphinx.util.inspect.Signature instead.', 'Please use sphinx.util.inspect.Signature instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
if isinstance(annotation, typing.TypeVar): # type: ignore if isinstance(annotation, typing.TypeVar): # type: ignore
return annotation.__name__ return annotation.__name__
if annotation == Ellipsis: if annotation == Ellipsis:
@ -114,7 +114,7 @@ def formatargspec(function, args, varargs=None, varkw=None, defaults=None,
""" """
warnings.warn('formatargspec() is now deprecated. ' warnings.warn('formatargspec() is now deprecated. '
'Please use sphinx.util.inspect.Signature instead.', 'Please use sphinx.util.inspect.Signature instead.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
def format_arg_with_annotation(name): def format_arg_with_annotation(name):
# type: (str) -> str # type: (str) -> str

View File

@ -195,7 +195,7 @@ def get_documenter(*args):
obj, parent = args obj, parent = args
warnings.warn('the interface of get_documenter() has been changed. ' warnings.warn('the interface of get_documenter() has been changed. '
'Please give application object as first argument.', 'Please give application object as first argument.',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
if inspect.ismodule(obj): if inspect.ismodule(obj):
# ModuleDocumenter.can_document_member always returns False # ModuleDocumenter.can_document_member always returns False

View File

@ -385,7 +385,7 @@ def debug(argv):
"""Debug functionality to print out an inventory""" """Debug functionality to print out an inventory"""
warnings.warn('sphinx.ext.intersphinx.debug() is deprecated. ' warnings.warn('sphinx.ext.intersphinx.debug() is deprecated. '
'Please use inspect_main() instead', 'Please use inspect_main() instead',
RemovedInSphinx20Warning) RemovedInSphinx20Warning, stacklevel=2)
inspect_main(argv[1:]) inspect_main(argv[1:])

View File

@ -32,14 +32,14 @@ class MathDirective(MathDirectiveBase):
def run(self): def run(self):
warnings.warn('sphinx.ext.mathbase.MathDirective is moved to ' warnings.warn('sphinx.ext.mathbase.MathDirective is moved to '
'sphinx.directives.patches package.', 'sphinx.directives.patches package.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return super(MathDirective, self).run() return super(MathDirective, self).run()
def math_role(role, rawtext, text, lineno, inliner, options={}, content=[]): def math_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
warnings.warn('sphinx.ext.mathbase.math_role() is deprecated. ' warnings.warn('sphinx.ext.mathbase.math_role() is deprecated. '
'Please use docutils.parsers.rst.roles.math_role() instead.', 'Please use docutils.parsers.rst.roles.math_role() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return math_role_base(role, rawtext, text, lineno, inliner, options, content) return math_role_base(role, rawtext, text, lineno, inliner, options, content)
@ -47,7 +47,7 @@ def get_node_equation_number(writer, node):
# type: (Writer, nodes.Node) -> unicode # type: (Writer, nodes.Node) -> unicode
warnings.warn('sphinx.ext.mathbase.get_node_equation_number() is moved to ' warnings.warn('sphinx.ext.mathbase.get_node_equation_number() is moved to '
'sphinx.util.math package.', 'sphinx.util.math package.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
from sphinx.util.math import get_node_equation_number from sphinx.util.math import get_node_equation_number
return get_node_equation_number(writer, node) return get_node_equation_number(writer, node)
@ -56,7 +56,7 @@ def wrap_displaymath(text, label, numbering):
# type: (unicode, unicode, bool) -> unicode # type: (unicode, unicode, bool) -> unicode
warnings.warn('sphinx.ext.mathbase.wrap_displaymath() is moved to ' warnings.warn('sphinx.ext.mathbase.wrap_displaymath() is moved to '
'sphinx.util.math package.', 'sphinx.util.math package.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
from sphinx.util.math import wrap_displaymath from sphinx.util.math import wrap_displaymath
return wrap_displaymath(text, label, numbering) return wrap_displaymath(text, label, numbering)
@ -67,7 +67,7 @@ def is_in_section_title(node):
from sphinx.util.nodes import traverse_parent from sphinx.util.nodes import traverse_parent
warnings.warn('is_in_section_title() is deprecated.', warnings.warn('is_in_section_title() is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
for ancestor in traverse_parent(node): for ancestor in traverse_parent(node):
if isinstance(ancestor, nodes.title) and \ if isinstance(ancestor, nodes.title) and \
@ -80,6 +80,6 @@ def setup_math(app, htmlinlinevisitors, htmldisplayvisitors):
# type: (Sphinx, Tuple[Callable, Callable], Tuple[Callable, Callable]) -> None # type: (Sphinx, Tuple[Callable, Callable], Tuple[Callable, Callable]) -> None
warnings.warn('setup_math() is deprecated. ' warnings.warn('setup_math() is deprecated. '
'Please use app.add_html_math_renderer() instead.', 'Please use app.add_html_math_renderer() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
app.add_html_math_renderer('unknown', htmlinlinevisitors, htmldisplayvisitors) app.add_html_math_renderer('unknown', htmlinlinevisitors, htmldisplayvisitors)

View File

@ -252,7 +252,7 @@ def migrate_viewcode_import(app, config):
if config.viewcode_import is not None: if config.viewcode_import is not None:
warnings.warn('viewcode_import was renamed to viewcode_follow_imported_members. ' warnings.warn('viewcode_import was renamed to viewcode_follow_imported_members. '
'Please update your configuration.', 'Please update your configuration.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
def setup(app): def setup(app):

View File

@ -91,7 +91,7 @@ class PygmentsBridge(object):
self.trim_doctest_flags = trim_doctest_flags self.trim_doctest_flags = trim_doctest_flags
if trim_doctest_flags is not None: if trim_doctest_flags is not None:
warnings.warn('trim_doctest_flags option for PygmentsBridge is now deprecated.', warnings.warn('trim_doctest_flags option for PygmentsBridge is now deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
def get_formatter(self, **kwargs): def get_formatter(self, **kwargs):
# type: (Any) -> Formatter # type: (Any) -> Formatter
@ -101,7 +101,7 @@ class PygmentsBridge(object):
def unhighlighted(self, source): def unhighlighted(self, source):
# type: (unicode) -> unicode # type: (unicode) -> unicode
warnings.warn('PygmentsBridge.unhighlighted() is now deprecated.', warnings.warn('PygmentsBridge.unhighlighted() is now deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
if self.dest == 'html': if self.dest == 'html':
return '<pre>' + htmlescape(source) + '</pre>\n' return '<pre>' + htmlescape(source) + '</pre>\n'
else: else:

View File

@ -129,13 +129,13 @@ class SphinxI18nReader(SphinxBaseReader):
# type: (int) -> None # type: (int) -> None
"""Stores the source line number of original text.""" """Stores the source line number of original text."""
warnings.warn('SphinxI18nReader.set_lineno_for_reporter() is deprecated.', warnings.warn('SphinxI18nReader.set_lineno_for_reporter() is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
@property @property
def line(self): def line(self):
# type: () -> int # type: () -> int
warnings.warn('SphinxI18nReader.line is deprecated.', warnings.warn('SphinxI18nReader.line is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return 0 return 0

View File

@ -187,7 +187,7 @@ def mygettext(string):
not bound yet at that time. not bound yet at that time.
""" """
warnings.warn('sphinx.locale.mygettext() is deprecated. Please use `_()` instead.', warnings.warn('sphinx.locale.mygettext() is deprecated. Please use `_()` instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return _(string) return _(string)
@ -197,7 +197,7 @@ def lazy_gettext(string):
# if isinstance(string, _TranslationProxy): # if isinstance(string, _TranslationProxy):
# return string # return string
warnings.warn('sphinx.locale.laxy_gettext() is deprecated. Please use `_()` instead.', warnings.warn('sphinx.locale.laxy_gettext() is deprecated. Please use `_()` instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return _TranslationProxy(mygettext, string) # type: ignore return _TranslationProxy(mygettext, string) # type: ignore
@ -332,7 +332,7 @@ __ = get_translation('sphinx', 'console')
def l_(*args): def l_(*args):
warnings.warn('sphinx.locale.l_() is deprecated. Please use `_()` instead.', warnings.warn('sphinx.locale.l_() is deprecated. Please use `_()` instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return _(*args) return _(*args)

View File

@ -28,12 +28,12 @@ class Make(make_mode.Make):
def __init__(self, *args): def __init__(self, *args):
warnings.warn('sphinx.make_mode.Make is deprecated. ' warnings.warn('sphinx.make_mode.Make is deprecated. '
'Please use sphinx.cmd.make_mode.Make instead.', 'Please use sphinx.cmd.make_mode.Make instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
super(Make, self).__init__(*args) super(Make, self).__init__(*args)
def run_make_mode(args): def run_make_mode(args):
warnings.warn('sphinx.make_mode.run_make_mode() is deprecated. ' warnings.warn('sphinx.make_mode.run_make_mode() is deprecated. '
'Please use sphinx.cmd.make_mode.run_make_mode() instead.', 'Please use sphinx.cmd.make_mode.run_make_mode() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return make_mode.run_make_mode(args) return make_mode.run_make_mode(args)

View File

@ -186,7 +186,7 @@ class SphinxComponentRegistry(object):
# type: (Type[Domain]) -> None # type: (Type[Domain]) -> None
warnings.warn('registry.override_domain() is deprecated. ' warnings.warn('registry.override_domain() is deprecated. '
'Use app.add_domain(domain, override=True) instead.', 'Use app.add_domain(domain, override=True) instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
self.add_domain(domain, override=True) self.add_domain(domain, override=True)
def add_directive_to_domain(self, domain, name, obj, has_content=None, argument_spec=None, def add_directive_to_domain(self, domain, name, obj, has_content=None, argument_spec=None,
@ -291,7 +291,7 @@ class SphinxComponentRegistry(object):
# old style arguments: (suffix, source_parser) # old style arguments: (suffix, source_parser)
warnings.warn('app.add_source_parser() does not support suffix argument. ' warnings.warn('app.add_source_parser() does not support suffix argument. '
'Use app.add_source_suffix() instead.', 'Use app.add_source_suffix() instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=3)
suffix = args[0] suffix = args[0]
parser = args[1] parser = args[1]
@ -301,7 +301,7 @@ class SphinxComponentRegistry(object):
if len(parser.supported) == 0: if len(parser.supported) == 0:
warnings.warn('Old source_parser has been detected. Please fill Parser.supported ' warnings.warn('Old source_parser has been detected. Please fill Parser.supported '
'attribute: %s' % parser.__name__, 'attribute: %s' % parser.__name__,
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=3)
# create a map from filetype to parser # create a map from filetype to parser
for filetype in parser.supported: for filetype in parser.supported:

View File

@ -563,7 +563,7 @@ class SearchJapanese(SearchLanguage):
dotted_path = self.splitters[type] dotted_path = self.splitters[type]
warnings.warn('html_search_options["type"]: %s is deprecated. ' warnings.warn('html_search_options["type"]: %s is deprecated. '
'Please give "%s" instead.' % (type, dotted_path), 'Please give "%s" instead.' % (type, dotted_path),
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
else: else:
dotted_path = type dotted_path = type
try: try:

View File

@ -207,7 +207,7 @@ def copy_static_entry(source, targetdir, builder, context={},
Handles all possible cases of files, directories and subdirectories. Handles all possible cases of files, directories and subdirectories.
""" """
warnings.warn('sphinx.util.copy_static_entry is deprecated for removal', warnings.warn('sphinx.util.copy_static_entry is deprecated for removal',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
if exclude_matchers: if exclude_matchers:
relpath = relative_path(path.join(builder.srcdir, 'dummy'), source) relpath = relative_path(path.join(builder.srcdir, 'dummy'), source)

View File

@ -124,7 +124,7 @@ def find_catalog_source_files(locale_dirs, locale, domains=None, gettext_compact
""" """
if gettext_compact is not None: if gettext_compact is not None:
warnings.warn('gettext_compact argument for find_catalog_source_files() ' warnings.warn('gettext_compact argument for find_catalog_source_files() '
'is deprecated.', RemovedInSphinx30Warning) 'is deprecated.', RemovedInSphinx30Warning, stacklevel=2)
catalogs = set() # type: Set[CatalogInfo] catalogs = set() # type: Set[CatalogInfo]

View File

@ -87,7 +87,7 @@ def guess_mimetype(filename='', content=None, default=None):
return mime_suffixes[ext] return mime_suffixes[ext]
elif content: elif content:
warnings.warn('The content argument of guess_mimetype() is deprecated.', warnings.warn('The content argument of guess_mimetype() is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return guess_mimetype_for_stream(BytesIO(content), default=default) return guess_mimetype_for_stream(BytesIO(content), default=default)
elif path.exists(filename): elif path.exists(filename):
with open(filename, 'rb') as f: with open(filename, 'rb') as f:

View File

@ -186,7 +186,7 @@ def ustrftime(format, *args):
# type: (unicode, Any) -> unicode # type: (unicode, Any) -> unicode
"""[DEPRECATED] strftime for unicode strings.""" """[DEPRECATED] strftime for unicode strings."""
warnings.warn('sphinx.util.osutil.ustrtime is deprecated for removal', warnings.warn('sphinx.util.osutil.ustrtime is deprecated for removal',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
if not args: if not args:
# If time is not specified, try to use $SOURCE_DATE_EPOCH variable # If time is not specified, try to use $SOURCE_DATE_EPOCH variable

View File

@ -186,6 +186,6 @@ def prepare(document):
# type: (nodes.Node) -> None # type: (nodes.Node) -> None
"""Simple wrapper for UIDTransform.""" """Simple wrapper for UIDTransform."""
warnings.warn('versioning.prepare() is deprecated. Use UIDTransform instead.', warnings.warn('versioning.prepare() is deprecated. Use UIDTransform instead.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
transform = UIDTransform(document) transform = UIDTransform(document)
transform.apply() transform.apply()

View File

@ -902,7 +902,7 @@ class HTMLTranslator(BaseTranslator):
def highlightlang(self): def highlightlang(self):
# type: () -> unicode # type: () -> unicode
warnings.warn('HTMLTranslator.highlightlang is deprecated.', warnings.warn('HTMLTranslator.highlightlang is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return self.builder.config.highlight_language return self.builder.config.highlight_language
@property @property
@ -916,12 +916,12 @@ class HTMLTranslator(BaseTranslator):
def highlightopts(self): def highlightopts(self):
# type: () -> unicode # type: () -> unicode
warnings.warn('HTMLTranslator.highlightopts is deprecated.', warnings.warn('HTMLTranslator.highlightopts is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return self.builder.config.highlight_options return self.builder.config.highlight_options
@property @property
def highlightlinenothreshold(self): def highlightlinenothreshold(self):
# type: () -> int # type: () -> int
warnings.warn('HTMLTranslator.highlightlinenothreshold is deprecated.', warnings.warn('HTMLTranslator.highlightlinenothreshold is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return sys.maxsize return sys.maxsize

View File

@ -853,26 +853,26 @@ class HTML5Translator(BaseTranslator):
def highlightlang(self): def highlightlang(self):
# type: () -> unicode # type: () -> unicode
warnings.warn('HTMLTranslator.highlightlang is deprecated.', warnings.warn('HTMLTranslator.highlightlang is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return self.builder.config.highlight_language return self.builder.config.highlight_language
@property @property
def highlightlang_base(self): def highlightlang_base(self):
# type: () -> unicode # type: () -> unicode
warnings.warn('HTMLTranslator.highlightlang_base is deprecated.', warnings.warn('HTMLTranslator.highlightlang_base is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return self.builder.config.highlight_language return self.builder.config.highlight_language
@property @property
def highlightopts(self): def highlightopts(self):
# type: () -> unicode # type: () -> unicode
warnings.warn('HTMLTranslator.highlightopts is deprecated.', warnings.warn('HTMLTranslator.highlightopts is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return self.builder.config.highlight_options return self.builder.config.highlight_options
@property @property
def highlightlinenothreshold(self): def highlightlinenothreshold(self):
# type: () -> int # type: () -> int
warnings.warn('HTMLTranslator.highlightlinenothreshold is deprecated.', warnings.warn('HTMLTranslator.highlightlinenothreshold is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return sys.maxsize return sys.maxsize

View File

@ -218,7 +218,7 @@ class ExtBabel(Babel):
def get_shorthandoff(self): def get_shorthandoff(self):
# type: () -> unicode # type: () -> unicode
warnings.warn('ExtBabel.get_shorthandoff() is deprecated.', warnings.warn('ExtBabel.get_shorthandoff() is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return SHORTHANDOFF return SHORTHANDOFF
def uses_cyrillic(self): def uses_cyrillic(self):
@ -289,14 +289,14 @@ class Table(object):
def caption_footnotetexts(self): def caption_footnotetexts(self):
# type: () -> List[unicode] # type: () -> List[unicode]
warnings.warn('table.caption_footnotetexts is deprecated.', warnings.warn('table.caption_footnotetexts is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return [] return []
@property @property
def header_footnotetexts(self): def header_footnotetexts(self):
# type: () -> List[unicode] # type: () -> List[unicode]
warnings.warn('table.header_footnotetexts is deprecated.', warnings.warn('table.header_footnotetexts is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return [] return []
def is_longtable(self): def is_longtable(self):
@ -697,7 +697,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
def restrict_footnote(self, node): def restrict_footnote(self, node):
# type: (nodes.Node) -> None # type: (nodes.Node) -> None
warnings.warn('LaTeXWriter.restrict_footnote() is deprecated.', warnings.warn('LaTeXWriter.restrict_footnote() is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
if self.footnote_restricted is False: if self.footnote_restricted is False:
self.footnote_restricted = node self.footnote_restricted = node
@ -706,7 +706,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
def unrestrict_footnote(self, node): def unrestrict_footnote(self, node):
# type: (nodes.Node) -> None # type: (nodes.Node) -> None
warnings.warn('LaTeXWriter.unrestrict_footnote() is deprecated.', warnings.warn('LaTeXWriter.unrestrict_footnote() is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
if self.footnote_restricted == node: if self.footnote_restricted == node:
self.footnote_restricted = False self.footnote_restricted = False
@ -2545,60 +2545,60 @@ class LaTeXTranslator(nodes.NodeVisitor):
def footnotestack(self): def footnotestack(self):
# type: () -> List[Dict[unicode, List[Union[collected_footnote, bool]]]] # type: () -> List[Dict[unicode, List[Union[collected_footnote, bool]]]]
warnings.warn('LaTeXWriter.footnotestack is deprecated.', warnings.warn('LaTeXWriter.footnotestack is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return [] return []
@property @property
def bibitems(self): def bibitems(self):
# type: () -> List[List[unicode]] # type: () -> List[List[unicode]]
warnings.warn('LaTeXTranslator.bibitems() is deprecated.', warnings.warn('LaTeXTranslator.bibitems() is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return [] return []
@property @property
def in_container_literal_block(self): def in_container_literal_block(self):
# type: () -> int # type: () -> int
warnings.warn('LaTeXTranslator.in_container_literal_block is deprecated.', warnings.warn('LaTeXTranslator.in_container_literal_block is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return 0 return 0
@property @property
def next_section_ids(self): def next_section_ids(self):
# type: () -> Set[unicode] # type: () -> Set[unicode]
warnings.warn('LaTeXTranslator.next_section_ids is deprecated.', warnings.warn('LaTeXTranslator.next_section_ids is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return set() return set()
@property @property
def next_hyperlink_ids(self): def next_hyperlink_ids(self):
# type: () -> Dict # type: () -> Dict
warnings.warn('LaTeXTranslator.next_hyperlink_ids is deprecated.', warnings.warn('LaTeXTranslator.next_hyperlink_ids is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return {} return {}
def push_hyperlink_ids(self, figtype, ids): def push_hyperlink_ids(self, figtype, ids):
# type: (unicode, Set[unicode]) -> None # type: (unicode, Set[unicode]) -> None
warnings.warn('LaTeXTranslator.push_hyperlink_ids() is deprecated.', warnings.warn('LaTeXTranslator.push_hyperlink_ids() is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
pass pass
def pop_hyperlink_ids(self, figtype): def pop_hyperlink_ids(self, figtype):
# type: (unicode) -> Set[unicode] # type: (unicode) -> Set[unicode]
warnings.warn('LaTeXTranslator.pop_hyperlink_ids() is deprecated.', warnings.warn('LaTeXTranslator.pop_hyperlink_ids() is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return set() return set()
@property @property
def hlsettingstack(self): def hlsettingstack(self):
# type: () -> List[List[Union[unicode, int]]] # type: () -> List[List[Union[unicode, int]]]
warnings.warn('LaTeXTranslator.hlsettingstack is deprecated.', warnings.warn('LaTeXTranslator.hlsettingstack is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
return [[self.builder.config.highlight_language, sys.maxsize]] return [[self.builder.config.highlight_language, sys.maxsize]]
def check_latex_elements(self): def check_latex_elements(self):
# type: () -> None # type: () -> None
warnings.warn('check_latex_elements() is deprecated.', warnings.warn('check_latex_elements() is deprecated.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning, stacklevel=2)
for key in self.builder.config.latex_elements: for key in self.builder.config.latex_elements:
if key not in self.elements: if key not in self.elements: