mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
autodoc_typehints_description_target: Rename returnvalue_and_documented_params to documented_params
This commit is contained in:
parent
f731bf1999
commit
fd42063725
@ -626,15 +626,15 @@ There are also config values that you can set:
|
||||
When set to ``"documented"``, types will only be documented for a parameter
|
||||
or a return value that is already documented by the docstring.
|
||||
|
||||
With ``"returnvalue_and_documented_params"``, parameter types will only be
|
||||
annotated if the parameter is documented in the docstring. The return type is
|
||||
always annotated (except if it is ``None``).
|
||||
With ``"documented_params"``, parameter types will only be annotated if the
|
||||
parameter is documented in the docstring. The return type is always
|
||||
annotated (except if it is ``None``).
|
||||
|
||||
.. versionadded:: 4.0
|
||||
|
||||
.. versionadded:: 4.4
|
||||
.. versionadded:: 5.0
|
||||
|
||||
New option ``'returnvalue_and_documented_params'`` is added.
|
||||
New option ``'documented_params'`` is added.
|
||||
|
||||
.. confval:: autodoc_type_aliases
|
||||
|
||||
|
@ -2882,7 +2882,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
|
||||
app.add_config_value('autodoc_typehints', "signature", True,
|
||||
ENUM("signature", "description", "none", "both"))
|
||||
app.add_config_value('autodoc_typehints_description_target', 'all', True,
|
||||
ENUM('all', 'documented', 'returnvalue_and_documented_params'))
|
||||
ENUM('all', 'documented', 'documented_params'))
|
||||
app.add_config_value('autodoc_type_aliases', {}, True)
|
||||
app.add_config_value('autodoc_typehints_format', "short", 'env',
|
||||
ENUM("fully-qualified", "short"))
|
||||
|
@ -60,8 +60,7 @@ def merge_typehints(app: Sphinx, domain: str, objtype: str, contentnode: Element
|
||||
for field_list in field_lists:
|
||||
if app.config.autodoc_typehints_description_target == "all":
|
||||
modify_field_list(field_list, annotations[fullname])
|
||||
elif (app.config.autodoc_typehints_description_target ==
|
||||
"returnvalue_and_documented_params"):
|
||||
elif app.config.autodoc_typehints_description_target == "documented_params":
|
||||
augment_descriptions_with_types(
|
||||
field_list, annotations[fullname], force_rtype=True
|
||||
)
|
||||
|
@ -894,7 +894,7 @@ def test_autodoc_typehints_description_no_undoc(app):
|
||||
|
||||
@pytest.mark.sphinx('text', testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints': "description",
|
||||
'autodoc_typehints_description_target': 'returnvalue_and_documented_params'})
|
||||
'autodoc_typehints_description_target': 'documented_params'})
|
||||
def test_autodoc_typehints_description_no_undoc_doc_rtype(app):
|
||||
# No :type: will be injected for `incr`, which does not have a description
|
||||
# for its parameters or its return, just :rtype: will be injected due to
|
||||
@ -1010,7 +1010,7 @@ def test_autodoc_typehints_description_with_documented_init_no_undoc(app):
|
||||
|
||||
@pytest.mark.sphinx('text', testroot='ext-autodoc',
|
||||
confoverrides={'autodoc_typehints': "description",
|
||||
'autodoc_typehints_description_target': 'returnvalue_and_documented_params'})
|
||||
'autodoc_typehints_description_target': 'documented_params'})
|
||||
def test_autodoc_typehints_description_with_documented_init_no_undoc_doc_rtype(app):
|
||||
# see test_autodoc_typehints_description_with_documented_init_no_undoc
|
||||
# returnvalue_and_documented_params should not change class or method
|
||||
|
Loading…
Reference in New Issue
Block a user