diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2017-12-16 23:43:08 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2017-12-17 02:13:09 +0900 |
commit | cac965cf77cb69d7807df566bcaa62d31cafd143 (patch) | |
tree | 949042ebb1335258e99ca96011f38f272b08676e /sphinx/ext/autodoc/directive.py | |
parent | 832914423e84067f3cf764bcb84e20ade00f02af (diff) | |
download | sphinx-git-cac965cf77cb69d7807df566bcaa62d31cafd143.tar.gz |
autodoc: refactor option_spec of autodirectives
Diffstat (limited to 'sphinx/ext/autodoc/directive.py')
-rw-r--r-- | sphinx/ext/autodoc/directive.py | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py index 9be273982..f348e105a 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 AutoDirective, AutodocReporter, identity +from sphinx.ext.autodoc import AutoDirective, AutodocReporter from sphinx.util import logging from sphinx.util.nodes import nested_parse_with_titles @@ -33,26 +33,12 @@ AUTODOC_DEFAULT_OPTIONS = ['members', 'undoc-members', 'inherited-members', 'show-inheritance', 'private-members', 'special-members'] -class DefDict(dict): - """A dict that returns a default on nonexisting keys.""" - def __init__(self, default): - # type: (Any) -> None - dict.__init__(self) - self.default = default +class DummyOptionSpec(object): + """An option_spec allows any options.""" def __getitem__(self, key): # type: (Any) -> Any - try: - return dict.__getitem__(self, key) - except KeyError: - return self.default - - def __bool__(self): - # type: () -> bool - # docutils check "if option_spec" - return True - - __nonzero__ = __bool__ # for python2 compatibility + return lambda x: x class Options(dict): @@ -123,7 +109,7 @@ class AutodocDirective(Directive): It invokes a Documenter on running. After the processing, it parses and returns the generated content by Documenter. """ - option_spec = DefDict(identity) + option_spec = DummyOptionSpec() has_content = True required_arguments = 1 optional_arguments = 0 |