From 212baa9740b31f766fddd5143a4e3dbc553f3a91 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 4 Feb 2018 15:11:14 +0900 Subject: [PATCH] Fix #4538: autodoc: ``sphinx.ext.autodoc.Options`` has been moved --- CHANGES | 1 + sphinx/ext/autodoc/__init__.py | 12 ++++++++++++ sphinx/ext/autodoc/directive.py | 12 +----------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index b463bb81f..77de1c2c8 100644 --- a/CHANGES +++ b/CHANGES @@ -18,6 +18,7 @@ Bugs fixed * #4019: inheritance_diagram AttributeError stoping make process * #4531: autosummary: methods are not treated as attributes +* #4538: autodoc: ``sphinx.ext.autodoc.Options`` has been moved Testing -------- diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 6fa4093ed..0f7231f7a 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -226,6 +226,18 @@ def between(marker, what=None, keepempty=False, exclude=False): return process +# This class is used only in ``sphinx.ext.autodoc.directive``, +# But we define this class here to keep compatibility (see #4538) +class Options(dict): + """A dict/attribute hybrid that returns None on nonexisting keys.""" + def __getattr__(self, name): + # type: (unicode) -> Any + try: + return self[name.replace('_', '-')] + except KeyError: + return None + + class Documenter(object): """ A Documenter knows how to autodocument a single object type. When diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py index 6de6e5517..2a7c6b65a 100644 --- a/sphinx/ext/autodoc/directive.py +++ b/sphinx/ext/autodoc/directive.py @@ -12,7 +12,7 @@ from docutils.parsers.rst import Directive from docutils.statemachine import ViewList from docutils.utils import assemble_option_dict -from sphinx.ext.autodoc import get_documenters +from sphinx.ext.autodoc import Options, get_documenters from sphinx.util import logging from sphinx.util.docutils import switch_source_input from sphinx.util.nodes import nested_parse_with_titles @@ -43,16 +43,6 @@ class DummyOptionSpec(object): return lambda x: x -class Options(dict): - """A dict/attribute hybrid that returns None on nonexisting keys.""" - def __getattr__(self, name): - # type: (unicode) -> Any - try: - return self[name.replace('_', '-')] - except KeyError: - return None - - class DocumenterBridge(object): """A parameters container for Documenters."""