mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Closes #1716: Adds "Yield" alias for "Yields" section in napoleon extension
This commit is contained in:
parent
5d30675e5b
commit
d51eeab07b
@ -148,6 +148,7 @@ class GoogleDocstring(UnicodeMixin):
|
||||
'warning': self._parse_warning_section,
|
||||
'warnings': self._parse_warning_section,
|
||||
'warns': self._parse_warns_section,
|
||||
'yield': self._parse_yields_section,
|
||||
'yields': self._parse_yields_section,
|
||||
}
|
||||
self._parse()
|
||||
@ -590,7 +591,7 @@ class GoogleDocstring(UnicodeMixin):
|
||||
return self._format_fields('Warns', self._consume_fields())
|
||||
|
||||
def _parse_yields_section(self, section):
|
||||
fields = self._consume_fields(prefer_type=True)
|
||||
fields = self._consume_returns_section()
|
||||
return self._format_fields('Yields', fields)
|
||||
|
||||
def _strip_empty(self, lines):
|
||||
|
@ -222,6 +222,33 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
Variable length argument list.
|
||||
* **\\*\\*kwargs** --
|
||||
Arbitrary keyword arguments."""
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
|
||||
Yield:
|
||||
str:Extended
|
||||
description of yielded value
|
||||
""",
|
||||
"""
|
||||
Single line summary
|
||||
|
||||
:Yields: *str* --
|
||||
Extended
|
||||
description of yielded value"""
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
|
||||
Yields:
|
||||
Extended
|
||||
description of yielded value
|
||||
""",
|
||||
"""
|
||||
Single line summary
|
||||
|
||||
:Yields: Extended
|
||||
description of yielded value"""
|
||||
)]
|
||||
|
||||
def test_docstrings(self):
|
||||
@ -424,6 +451,38 @@ class NumpyDocstringTest(BaseDocstringTest):
|
||||
Variable length argument list.
|
||||
* ****kwargs** --
|
||||
Arbitrary keyword arguments."""
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
|
||||
Yield
|
||||
-----
|
||||
str
|
||||
Extended
|
||||
description of yielded value
|
||||
""",
|
||||
"""
|
||||
Single line summary
|
||||
|
||||
:Yields: *str* --
|
||||
Extended
|
||||
description of yielded value"""
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
|
||||
Yields
|
||||
------
|
||||
str
|
||||
Extended
|
||||
description of yielded value
|
||||
""",
|
||||
"""
|
||||
Single line summary
|
||||
|
||||
:Yields: *str* --
|
||||
Extended
|
||||
description of yielded value"""
|
||||
)]
|
||||
|
||||
def test_docstrings(self):
|
||||
|
Loading…
Reference in New Issue
Block a user