Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering of exceptions by napoleon. #4046

Merged
merged 2 commits into from
Sep 23, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Sep 6, 2017

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.

attn @RobRuana xpost #3735
Feel free to reuse code in this PR if you want to make a configurable version as discussed in #3735.


Subject: See above

Feature or Bugfix

  • Feature(ish)

Purpose

  • See above

Detail

  • See above

Relates


(looks like the type linter does not like certain constructs, meh :-()

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.
Copy link
Contributor

@RobRuana RobRuana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! This looks fantastic! +1

@RobRuana RobRuana merged commit dbb7c38 into sphinx-doc:master Sep 23, 2018
@RobRuana
Copy link
Contributor

Only a year late!

@anntzer anntzer deleted the napoleon-exceptions branch September 23, 2018 12:45
@anntzer
Copy link
Contributor Author

anntzer commented Sep 23, 2018

Better late than never :p

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants