diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-12-13 11:36:03 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-12-13 11:36:03 +0900 |
commit | 2df0bb8d03d05fe7052315438382d49014e3dcf9 (patch) | |
tree | 5d7c143c29fdf0f605b9748390a9ffcb0eef0a5b /sphinx/util/compat.py | |
parent | 92a9c653f7230ce33df66549fe61cf64bb80559b (diff) | |
download | sphinx-git-2df0bb8d03d05fe7052315438382d49014e3dcf9.tar.gz |
``sphinx.util.compat.Directive`` class is now deprecated.
Diffstat (limited to 'sphinx/util/compat.py')
-rw-r--r-- | sphinx/util/compat.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sphinx/util/compat.py b/sphinx/util/compat.py index 0af65cbe3..73b68f5a2 100644 --- a/sphinx/util/compat.py +++ b/sphinx/util/compat.py @@ -10,12 +10,17 @@ """ from __future__ import absolute_import +import sys import warnings from docutils import nodes from docutils.parsers.rst import Directive # noqa +from docutils.parsers.rst import Directive # noqa from docutils import __version__ as _du_version + +from sphinx.deprecation import RemovedInSphinx17Warning + docutils_version = tuple(int(x) for x in _du_version.split('.')[:2]) @@ -38,3 +43,25 @@ def make_admonition(node_class, name, arguments, options, content, lineno, admonition_node['classes'] += classes state.nested_parse(content, content_offset, admonition_node) return [admonition_node] + + +class _DeprecationWrapper(object): + def __init__(self, mod, deprecated): + # type: (Any, Dict) -> None + self._mod = mod + self._deprecated = deprecated + + def __getattr__(self, attr): + if attr in self._deprecated: + warnings.warn("sphinx.util.compat.%s is deprecated and will be " + "removed in Sphinx 1.7, please use the standard " + "library version instead." % attr, + RemovedInSphinx17Warning, stacklevel=2) + return self._deprecated[attr] + return getattr(self._mod, attr) + + +sys.modules[__name__] = _DeprecationWrapper(sys.modules[__name__], dict( # type: ignore + docutils_version = docutils_version, + Directive = Directive, +)) |