Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-02-04 16:24:52 +0300
committerGitHub <noreply@github.com>2021-02-04 16:24:52 +0300
commit0d50b97fa3f36fa2adc9b429adb845b859e1ddd4 (patch)
tree0a84edd68c1917c49cfa5add939653b691ebaf49 /sphinx/ext
parent9ed3219ea4458955d86d99d7f098006cfed7f972 (diff)
parentfd6587d5e9426e1169f4c7ff4b502d00782864b0 (diff)
Merge pull request #8297 from pbudzyns/exclude-members-fix
Local autodoc options override or extend autodoc_default_options.
Diffstat (limited to 'sphinx/ext')
-rw-r--r--sphinx/ext/autodoc/directive.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py
index b4c5fd28d..c932c6f9f 100644
--- a/sphinx/ext/autodoc/directive.py
+++ b/sphinx/ext/autodoc/directive.py
@@ -37,6 +37,9 @@ AUTODOC_DEFAULT_OPTIONS = ['members', 'undoc-members', 'inherited-members',
'ignore-module-all', 'exclude-members', 'member-order',
'imported-members']
+AUTODOC_EXTENDABLE_OPTIONS = ['members', 'private-members', 'special-members',
+ 'exclude-members']
+
class DummyOptionSpec(dict):
"""An option_spec allows any options."""
@@ -90,7 +93,19 @@ def process_documenter_options(documenter: "Type[Documenter]", config: Config, o
else:
negated = options.pop('no-' + name, True) is None
if name in config.autodoc_default_options and not negated:
- options[name] = config.autodoc_default_options[name]
+ if name in options and isinstance(config.autodoc_default_options[name], str):
+ # take value from options if present or extend it
+ # with autodoc_default_options if necessary
+ if name in AUTODOC_EXTENDABLE_OPTIONS:
+ if options[name] is not None and options[name].startswith('+'):
+ options[name] = ','.join([config.autodoc_default_options[name],
+ options[name][1:]])
+ else:
+ options[name] = config.autodoc_default_options[name]
+
+ elif options.get(name) is not None:
+ # remove '+' from option argument if there's nothing to merge it with
+ options[name] = options[name].lstrip('+')
return Options(assemble_option_dict(options.items(), documenter.option_spec))