summaryrefslogtreecommitdiff
path: root/sphinx/ext/autodoc.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-02-21 22:16:06 +0100
committerGeorg Brandl <georg@python.org>2010-02-21 22:16:06 +0100
commitfab92b215afa61ffa17a12919a3bd5192adba754 (patch)
tree66cd2cf175c626daa6cd90297038f4cb80effb3a /sphinx/ext/autodoc.py
parent750c3622fd66efc7980f14cc54ad719a4d2cf840 (diff)
downloadsphinx-git-fab92b215afa61ffa17a12919a3bd5192adba754.tar.gz
Added ``autodoc_default_flags`` config value, which can be used
to select default flags for all autodoc directives.
Diffstat (limited to 'sphinx/ext/autodoc.py')
-rw-r--r--sphinx/ext/autodoc.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py
index d3d19dcf5..81c3f6a44 100644
--- a/sphinx/ext/autodoc.py
+++ b/sphinx/ext/autodoc.py
@@ -1098,6 +1098,10 @@ class AutoDirective(Directive):
# a registry of type -> getattr function
_special_attrgetters = {}
+ # flags that can be given in autodoc_default_flags
+ _default_flags = set(['members', 'undoc-members', 'inherited-members',
+ 'show-inheritance'])
+
# standard docutils directive settings
has_content = True
required_arguments = 1
@@ -1120,6 +1124,14 @@ class AutoDirective(Directive):
# find out what documenter to call
objtype = self.name[4:]
doc_class = self._registry[objtype]
+ # add default flags
+ for flag in self._default_flags:
+ if flag not in doc_class.option_spec:
+ continue
+ negated = self.options.pop('no-' + flag, 'not given') is None
+ if flag in self.env.config.autodoc_default_flags and \
+ not negated:
+ self.options[flag] = None
# process the options with the selected documenter's option_spec
self.genopt = Options(assemble_option_dict(
self.options.items(), doc_class.option_spec))
@@ -1177,6 +1189,7 @@ def setup(app):
app.add_config_value('autoclass_content', 'class', True)
app.add_config_value('autodoc_member_order', 'alphabetic', True)
+ app.add_config_value('autodoc_default_flags', [], True)
app.add_event('autodoc-process-docstring')
app.add_event('autodoc-process-signature')
app.add_event('autodoc-skip-member')