diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-02-04 16:24:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-04 16:24:52 +0300 |
commit | 0d50b97fa3f36fa2adc9b429adb845b859e1ddd4 (patch) | |
tree | 0a84edd68c1917c49cfa5add939653b691ebaf49 /sphinx/ext | |
parent | 9ed3219ea4458955d86d99d7f098006cfed7f972 (diff) | |
parent | fd6587d5e9426e1169f4c7ff4b502d00782864b0 (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.py | 17 |
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)) |