mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
check if autodoc_defaults are str, fix tests
This commit is contained in:
parent
dc277e0e18
commit
8d380cadc7
@ -87,7 +87,7 @@ def process_documenter_options(documenter: "Type[Documenter]", config: Config, o
|
|||||||
else:
|
else:
|
||||||
negated = options.pop('no-' + name, True) is None
|
negated = options.pop('no-' + name, True) is None
|
||||||
if name in config.autodoc_default_options and not negated:
|
if name in config.autodoc_default_options and not negated:
|
||||||
if name in options:
|
if name in options and isinstance(config.autodoc_default_options[name], str):
|
||||||
# take value from options if present or extend it
|
# take value from options if present or extend it
|
||||||
# with autodoc_default_options if necessary
|
# with autodoc_default_options if necessary
|
||||||
if name in AUTODOC_EXTENDABLE_OPTIONS:
|
if name in AUTODOC_EXTENDABLE_OPTIONS:
|
||||||
@ -97,9 +97,9 @@ def process_documenter_options(documenter: "Type[Documenter]", config: Config, o
|
|||||||
else:
|
else:
|
||||||
options[name] = config.autodoc_default_options[name]
|
options[name] = config.autodoc_default_options[name]
|
||||||
|
|
||||||
elif isinstance(options.get(name), str) and options[name].startswith('+'):
|
elif options.get(name) is not None:
|
||||||
# remove '+' from option argument if there's nothing to merge it with
|
# remove '+' from option argument if there's nothing to merge it with
|
||||||
options[name] = options[name].strip('+')
|
options[name] = options[name].lstrip('+')
|
||||||
|
|
||||||
return Options(assemble_option_dict(options.items(), documenter.option_spec))
|
return Options(assemble_option_dict(options.items(), documenter.option_spec))
|
||||||
|
|
||||||
|
@ -903,7 +903,7 @@ def test_autodoc_ignore_module_all(app):
|
|||||||
|
|
||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_noindex(app):
|
def test_autodoc_noindex(app):
|
||||||
options = {"noindex": True}
|
options = {"noindex": None}
|
||||||
actual = do_autodoc(app, 'module', 'target', options)
|
actual = do_autodoc(app, 'module', 'target', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -984,7 +984,7 @@ def test_autodoc_inner_class(app):
|
|||||||
'',
|
'',
|
||||||
]
|
]
|
||||||
|
|
||||||
options['show-inheritance'] = True
|
options['show-inheritance'] = None
|
||||||
actual = do_autodoc(app, 'class', 'target.InnerChild', options)
|
actual = do_autodoc(app, 'class', 'target.InnerChild', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -1028,7 +1028,7 @@ def test_autodoc_staticmethod(app):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_descriptor(app):
|
def test_autodoc_descriptor(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'class', 'target.descriptor.Class', options)
|
actual = do_autodoc(app, 'class', 'target.descriptor.Class', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -1056,7 +1056,7 @@ def test_autodoc_descriptor(app):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_cached_property(app):
|
def test_autodoc_cached_property(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'class', 'target.cached_property.Foo', options)
|
actual = do_autodoc(app, 'class', 'target.cached_property.Foo', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -1076,8 +1076,8 @@ def test_autodoc_member_order(app):
|
|||||||
# case member-order='bysource'
|
# case member-order='bysource'
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
'member-order': 'bysource',
|
'member-order': 'bysource',
|
||||||
"undoc-members": True,
|
"undoc-members": None,
|
||||||
'private-members': True}
|
'private-members': None}
|
||||||
actual = do_autodoc(app, 'class', 'target.Class', options)
|
actual = do_autodoc(app, 'class', 'target.Class', options)
|
||||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||||
'.. py:class:: Class(arg)',
|
'.. py:class:: Class(arg)',
|
||||||
@ -1101,8 +1101,8 @@ def test_autodoc_member_order(app):
|
|||||||
# case member-order='groupwise'
|
# case member-order='groupwise'
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
'member-order': 'groupwise',
|
'member-order': 'groupwise',
|
||||||
"undoc-members": True,
|
"undoc-members": None,
|
||||||
'private-members': True}
|
'private-members': None}
|
||||||
actual = do_autodoc(app, 'class', 'target.Class', options)
|
actual = do_autodoc(app, 'class', 'target.Class', options)
|
||||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||||
'.. py:class:: Class(arg)',
|
'.. py:class:: Class(arg)',
|
||||||
@ -1125,8 +1125,8 @@ def test_autodoc_member_order(app):
|
|||||||
|
|
||||||
# case member-order=None
|
# case member-order=None
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True,
|
"undoc-members": None,
|
||||||
'private-members': True}
|
'private-members': None}
|
||||||
actual = do_autodoc(app, 'class', 'target.Class', options)
|
actual = do_autodoc(app, 'class', 'target.Class', options)
|
||||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||||
'.. py:class:: Class(arg)',
|
'.. py:class:: Class(arg)',
|
||||||
@ -1153,7 +1153,7 @@ def test_autodoc_module_member_order(app):
|
|||||||
# case member-order='bysource'
|
# case member-order='bysource'
|
||||||
options = {"members": 'foo, Bar, baz, qux, Quux, foobar',
|
options = {"members": 'foo, Bar, baz, qux, Quux, foobar',
|
||||||
'member-order': 'bysource',
|
'member-order': 'bysource',
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'module', 'target.sort_by_all', options)
|
actual = do_autodoc(app, 'module', 'target.sort_by_all', options)
|
||||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||||
'.. py:module:: target.sort_by_all',
|
'.. py:module:: target.sort_by_all',
|
||||||
@ -1168,8 +1168,8 @@ def test_autodoc_module_member_order(app):
|
|||||||
# case member-order='bysource' and ignore-module-all
|
# case member-order='bysource' and ignore-module-all
|
||||||
options = {"members": 'foo, Bar, baz, qux, Quux, foobar',
|
options = {"members": 'foo, Bar, baz, qux, Quux, foobar',
|
||||||
'member-order': 'bysource',
|
'member-order': 'bysource',
|
||||||
"undoc-members": True,
|
"undoc-members": None,
|
||||||
"ignore-module-all": True}
|
"ignore-module-all": None}
|
||||||
actual = do_autodoc(app, 'module', 'target.sort_by_all', options)
|
actual = do_autodoc(app, 'module', 'target.sort_by_all', options)
|
||||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||||
'.. py:module:: target.sort_by_all',
|
'.. py:module:: target.sort_by_all',
|
||||||
@ -1216,7 +1216,7 @@ def test_autodoc_class_scope(app):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_class_attributes(app):
|
def test_class_attributes(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'class', 'target.AttCls', options)
|
actual = do_autodoc(app, 'class', 'target.AttCls', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -1326,7 +1326,7 @@ def test_autoattribute_instance_attributes(app):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_slots(app):
|
def test_slots(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'module', 'target.slots', options)
|
actual = do_autodoc(app, 'module', 'target.slots', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -1710,7 +1710,7 @@ def test_partialmethod_undoc_members(app):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_typed_instance_variables(app):
|
def test_autodoc_typed_instance_variables(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'module', 'target.typed_vars', options)
|
actual = do_autodoc(app, 'module', 'target.typed_vars', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -1804,8 +1804,8 @@ def test_autodoc_typed_instance_variables(app):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_typed_inherited_instance_variables(app):
|
def test_autodoc_typed_inherited_instance_variables(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True,
|
"undoc-members": None,
|
||||||
"inherited-members": True}
|
"inherited-members": None}
|
||||||
actual = do_autodoc(app, 'class', 'target.typed_vars.Derived', options)
|
actual = do_autodoc(app, 'class', 'target.typed_vars.Derived', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
|
@ -483,7 +483,7 @@ def test_mocked_module_imports(app, warning):
|
|||||||
confoverrides={'autodoc_typehints': "signature"})
|
confoverrides={'autodoc_typehints': "signature"})
|
||||||
def test_autodoc_typehints_signature(app):
|
def test_autodoc_typehints_signature(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'module', 'target.typehints', options)
|
actual = do_autodoc(app, 'module', 'target.typehints', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
@ -549,7 +549,7 @@ def test_autodoc_typehints_signature(app):
|
|||||||
confoverrides={'autodoc_typehints': "none"})
|
confoverrides={'autodoc_typehints': "none"})
|
||||||
def test_autodoc_typehints_none(app):
|
def test_autodoc_typehints_none(app):
|
||||||
options = {"members": None,
|
options = {"members": None,
|
||||||
"undoc-members": True}
|
"undoc-members": None}
|
||||||
actual = do_autodoc(app, 'module', 'target.typehints', options)
|
actual = do_autodoc(app, 'module', 'target.typehints', options)
|
||||||
assert list(actual) == [
|
assert list(actual) == [
|
||||||
'',
|
'',
|
||||||
|
Loading…
Reference in New Issue
Block a user