-
Notifications
You must be signed in to change notification settings - Fork 27
Fix IndexError
s when the "Examples" is the last section in a docstring
#292
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
Fix IndexError
s when the "Examples" is the last section in a docstring
#292
Conversation
Co-Authored-By: Justus Magin <[email protected]>
Co-Authored-By: Justus Magin <[email protected]>
closing/opening to restart CI |
IndexError
when the "Examples" is the last section in a docstringIndexError
s when the "Examples" is the last section in a docstring
The errors look unrelated, and I think GitHub has degraded performance at the moment – we should be fine. There is now https://www.githubstatus.com/incidents/42gtccf6dd98 |
Okay, the error is apparently on pre-commit.ci's side; we should be good to go here as the RTD build is working. |
) | ||
|
||
# Append the remainder of the docstring, if there is any | ||
if right_index < len(lines): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make sure I understand correctly, this condition will be False in the case where the example section is last and there is no emptyline after it. The check keeps jupyterlite_sphinx
from inserting an emptyline at the end in this case. If so, that sounds reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @agriyakhetarpal, thanks for fixing this.
I still can't figure out what the issue with the check release job is, but it's not related, obviously, so we can debug it as a part of the release process. |
Thanks for the review! |
This PR closes #291, it fixes an
IndexError
that occurs when processing docstrings where the Examples section is the last section in a docstring when usingsphinx.ext.napoleon
. I've added bounds checking to prevent accessing indices beyond the end of the lines list in theinsert_try_examples_directive
function.