diff options
| author | Antony Lee <anntzer.lee@gmail.com> | 2018-09-23 14:31:27 +0200 |
|---|---|---|
| committer | Rob Ruana <robruana@magfest.org> | 2018-09-23 08:31:27 -0400 |
| commit | dbb7c382206fed66b43b32dfd8e48dba0ac562b8 (patch) | |
| tree | e30df3e23449325acaf931701aa70af84a0f887e /tests/test_ext_napoleon_docstring.py | |
| parent | f5616139e833db5e948a868ba3f1025e2e7499a0 (diff) | |
| download | sphinx-git-dbb7c382206fed66b43b32dfd8e48dba0ac562b8.tar.gz | |
Rendering of exceptions by napoleon. (#4046)
This lets napoleon render exceptions using the standard info field
syntax
```
:raises FooException: Some condition.
```
rather than the nonstandard
```
:raises: :exc:`FooException` -- Some condition.
```
Note that the previous approach was more forgiving if an explanatory
text was given in the Raises section without an actual exception class:
```
Raises
------
If something occurs.
```
would be rendered as
```
:raises: *If something occurs*
```
which is OK-ish but is now rendered as
```
:raises If something occurs.:
```
which is somewhat more nonsensical.
However neither the Google style guide nor numpydoc actually support
this form (they always have both the type and the description) so I
think the change is reasonable.
Diffstat (limited to 'tests/test_ext_napoleon_docstring.py')
| -rw-r--r-- | tests/test_ext_napoleon_docstring.py | 71 |
1 files changed, 32 insertions, 39 deletions
diff --git a/tests/test_ext_napoleon_docstring.py b/tests/test_ext_napoleon_docstring.py index a4d127d0d..e299a5879 100644 --- a/tests/test_ext_napoleon_docstring.py +++ b/tests/test_ext_napoleon_docstring.py @@ -452,8 +452,8 @@ Raises: """, """ Example Function -:raises: * :exc:`RuntimeError` -- A setting wasn't specified, or was invalid. - * :exc:`ValueError` -- Something something value error. +:raises RuntimeError: A setting wasn't specified, or was invalid. +:raises ValueError: Something something value error. """), ################################ (""" @@ -465,7 +465,7 @@ Raises: """, """ Example Function -:raises: :exc:`InvalidDimensionsError` +:raises InvalidDimensionsError: """), ################################ (""" @@ -477,7 +477,7 @@ Raises: """, """ Example Function -:raises: Invalid Dimensions Error +:raises Invalid Dimensions Error: """), ################################ (""" @@ -489,7 +489,7 @@ Raises: """, """ Example Function -:raises: *Invalid Dimensions Error* -- With description +:raises Invalid Dimensions Error: With description """), ################################ (""" @@ -501,7 +501,7 @@ Raises: """, """ Example Function -:raises: :exc:`InvalidDimensionsError` -- If the dimensions couldn't be parsed. +:raises InvalidDimensionsError: If the dimensions couldn't be parsed. """), ################################ (""" @@ -513,7 +513,7 @@ Raises: """, """ Example Function -:raises: *Invalid Dimensions Error* -- If the dimensions couldn't be parsed. +:raises Invalid Dimensions Error: If the dimensions couldn't be parsed. """), ################################ (""" @@ -525,7 +525,7 @@ Raises: """, """ Example Function -:raises: If the dimensions couldn't be parsed. +:raises If the dimensions couldn't be parsed.: """), ################################ (""" @@ -537,7 +537,7 @@ Raises: """, """ Example Function -:raises: :class:`exc.InvalidDimensionsError` +:raises exc.InvalidDimensionsError: """), ################################ (""" @@ -549,8 +549,7 @@ Raises: """, """ Example Function -:raises: :class:`exc.InvalidDimensionsError` -- If the dimensions couldn't """ - """be parsed. +:raises exc.InvalidDimensionsError: If the dimensions couldn't be parsed. """), ################################ (""" @@ -563,9 +562,8 @@ Raises: """, """ Example Function -:raises: :class:`exc.InvalidDimensionsError` -- If the dimensions couldn't """ - """be parsed, - then a :class:`exc.InvalidDimensionsError` will be raised. +:raises exc.InvalidDimensionsError: If the dimensions couldn't be parsed, + then a :class:`exc.InvalidDimensionsError` will be raised. """), ################################ (""" @@ -578,9 +576,8 @@ Raises: """, """ Example Function -:raises: * :class:`exc.InvalidDimensionsError` -- If the dimensions """ - """couldn't be parsed. - * :class:`exc.InvalidArgumentsError` -- If the arguments are invalid. +:raises exc.InvalidDimensionsError: If the dimensions couldn't be parsed. +:raises exc.InvalidArgumentsError: If the arguments are invalid. """), ################################ (""" @@ -593,8 +590,8 @@ Raises: """, """ Example Function -:raises: * :class:`exc.InvalidDimensionsError` - * :class:`exc.InvalidArgumentsError` +:raises exc.InvalidDimensionsError: +:raises exc.InvalidArgumentsError: """)] for docstring, expected in docstrings: actual = str(GoogleDocstring(docstring)) @@ -1346,8 +1343,8 @@ Raises """, """ Example Function -:raises: * :exc:`RuntimeError` -- A setting wasn't specified, or was invalid. - * :exc:`ValueError` -- Something something value error. +:raises RuntimeError: A setting wasn't specified, or was invalid. +:raises ValueError: Something something value error. """), ################################ (""" @@ -1360,7 +1357,7 @@ InvalidDimensionsError """, """ Example Function -:raises: :exc:`InvalidDimensionsError` +:raises InvalidDimensionsError: """), ################################ (""" @@ -1373,7 +1370,7 @@ Invalid Dimensions Error """, """ Example Function -:raises: Invalid Dimensions Error +:raises Invalid Dimensions Error: """), ################################ (""" @@ -1387,7 +1384,7 @@ Invalid Dimensions Error """, """ Example Function -:raises: *Invalid Dimensions Error* -- With description +:raises Invalid Dimensions Error: With description """), ################################ (""" @@ -1401,7 +1398,7 @@ InvalidDimensionsError """, """ Example Function -:raises: :exc:`InvalidDimensionsError` -- If the dimensions couldn't be parsed. +:raises InvalidDimensionsError: If the dimensions couldn't be parsed. """), ################################ (""" @@ -1415,7 +1412,7 @@ Invalid Dimensions Error """, """ Example Function -:raises: *Invalid Dimensions Error* -- If the dimensions couldn't be parsed. +:raises Invalid Dimensions Error: If the dimensions couldn't be parsed. """), ################################ (""" @@ -1428,7 +1425,7 @@ If the dimensions couldn't be parsed. """, """ Example Function -:raises: If the dimensions couldn't be parsed. +:raises If the dimensions couldn't be parsed.: """), ################################ (""" @@ -1441,7 +1438,7 @@ Raises """, """ Example Function -:raises: :class:`exc.InvalidDimensionsError` +:raises exc.InvalidDimensionsError: """), ################################ (""" @@ -1455,8 +1452,7 @@ Raises """, """ Example Function -:raises: :class:`exc.InvalidDimensionsError` -- If the dimensions couldn't """ - """be parsed. +:raises exc.InvalidDimensionsError: If the dimensions couldn't be parsed. """), ################################ (""" @@ -1471,9 +1467,8 @@ Raises """, """ Example Function -:raises: :class:`exc.InvalidDimensionsError` -- If the dimensions couldn't """ - """be parsed, - then a :class:`exc.InvalidDimensionsError` will be raised. +:raises exc.InvalidDimensionsError: If the dimensions couldn't be parsed, + then a :class:`exc.InvalidDimensionsError` will be raised. """), ################################ (""" @@ -1489,10 +1484,8 @@ Raises """, """ Example Function -:raises: * :class:`exc.InvalidDimensionsError` -- If the dimensions """ - """couldn't be parsed. - * :class:`exc.InvalidArgumentsError` -- If the arguments """ - """are invalid. +:raises exc.InvalidDimensionsError: If the dimensions couldn't be parsed. +:raises exc.InvalidArgumentsError: If the arguments are invalid. """), ################################ (""" @@ -1506,8 +1499,8 @@ Raises """, """ Example Function -:raises: * :class:`exc.InvalidDimensionsError` - * :class:`exc.InvalidArgumentsError` +:raises exc.InvalidDimensionsError: +:raises exc.InvalidArgumentsError: """)] for docstring, expected in docstrings: config = Config() |
