summaryrefslogtreecommitdiff
path: root/sphinx/util/compat.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2018-02-17 23:26:28 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2018-02-17 23:26:28 +0900
commita9ecb190a7d9f778509ef3185fb1c938f6e65cbd (patch)
tree345b93ddd9ace7639bb03aff2b67164a1470c3f3 /sphinx/util/compat.py
parent95381b38898500b6667414c055942e44b4ce80b7 (diff)
downloadsphinx-git-a9ecb190a7d9f778509ef3185fb1c938f6e65cbd.tar.gz
autosummary: Fix compatibility of get_documenter() API (refs: #4366)
Diffstat (limited to 'sphinx/util/compat.py')
-rw-r--r--sphinx/util/compat.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/sphinx/util/compat.py b/sphinx/util/compat.py
new file mode 100644
index 000000000..f25e43315
--- /dev/null
+++ b/sphinx/util/compat.py
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+"""
+ sphinx.util.compat
+ ~~~~~~~~~~~~~~~~~~
+
+ modules for backward compatibility
+
+ :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import sys
+
+
+if False:
+ # For type annotation
+ from typing import Any, Dict # NOQA
+ from sphinx.application import Sphinx # NOQA
+
+
+def register_application_for_autosummary(app):
+ # type: (Sphinx) -> None
+ """Register application object to autosummary module.
+
+ Since Sphinx-1.7, documenters and attrgetters are registered into
+ applicaiton object. As a result, the arguments of
+ ``get_documenter()`` has been changed. To keep compatibility,
+ this handler registers application object to the module.
+ """
+ if 'sphinx.ext.autosummary' in sys.modules:
+ from sphinx.ext import autosummary
+ autosummary._app = app
+
+
+def setup(app):
+ # type: (Sphinx) -> Dict[unicode, Any]
+ app.connect('builder-inited', register_application_for_autosummary)
+
+ return {
+ 'version': 'builtin',
+ 'parallel_read_safe': True,
+ 'parallel_write_safe': True,
+ }