redundant '+' has no effect

This commit is contained in:
pbudzyns 2021-01-25 16:07:18 +01:00
parent 381e30c23b
commit ac5079ed85
2 changed files with 14 additions and 0 deletions

View File

@ -93,9 +93,14 @@ def process_documenter_options(documenter: "Type[Documenter]", config: Config, o
if options[name] is not None and options[name].startswith('+'):
options[name] = ','.join([config.autodoc_default_options[name],
options[name][1:]])
print(options[name])
else:
options[name] = config.autodoc_default_options[name]
elif isinstance(options.get(name), str) and options[name].startswith('+'):
# remove '+' from option argument if there's nothing to merge it with
options[name] = options[name][1:]
return Options(assemble_option_dict(options.items(), documenter.option_spec))

View File

@ -627,6 +627,15 @@ def test_autodoc_exclude_members(app):
'.. py:class:: Base()',
]
# + has no effect when autodoc_default_options are not present
options = {"members": None,
"exclude-members": "+inheritedmeth,inheritedstaticmeth"}
actual = do_autodoc(app, 'class', 'target.inheritance.Base', options)
assert list(filter(lambda l: '::' in l, actual)) == [
'.. py:class:: Base()',
' .. py:method:: Base.inheritedclassmeth()'
]
# exclude-members overrides autodoc_default_options
options = {"members": None,
"exclude-members": "inheritedmeth"}