-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Cryptic error message from failing to parse invalid rst docstrings #302
Comments
I was able to trace this back to this commit: 7b2f213 / #300 and find a little simpler reproduction. It has to do with this does not work and errors with above error.. def f() -> None:
"""
abc
1. abc
"""
... however if you add a def f() -> None:
"""
abc
1. abc
:returns: abc
"""
... also this does not error, but results in broken docs def f() -> None:
"""
abc
1. abc
"""
... For some reason
I hope this helps. |
@hoodmane can you take a look? |
Sure, will do. |
our sphinx doc build also started to fail with this error (Open-EO/openeo-python-client#366)
This apparently happens with |
The problem does not even seem to require a syntax error in the rst. The root cause is that the docutils rst parser does not add line numbers to definition nodes, only to the definition_list children sigh. I wish docutils had documentation. |
Problem
A cryptic error message is raised by
process_docstring
failing to parse arst
docstring within Python code.Example of invalid docstrings:
The issue is the indented part after the colon with the numbers.
What I expected
The issue of invalid
rst
is of course an user error and it is of course great thatsphinx-autodoc-typehints
finds these invalid portions but the error report should clarify where the error occurs and possibly why. Otherwise it is difficult for the user to understand what is wrong.Further info
I managed to debug the issue myself by running
sphinx-build
with the verbose flags (-vvv
). The issue is further exacerbated by the fact that the sphinx log can contain additional logging outputs between the exception reporting and the log that displays which part of the codesphinx
is currently processing. See the log as a gist here: https://gist.github.com/nialov/e92dcf8aa43c9108b31c37df28725188. At the very start, theemitting event
parts tell where the parsing is currently occurring. After it a number of irrelevant warnings are raised, which I have mostly deleted to keep the log cleaner, and then the exception is printed out. The exception itself contains no useful information, only that the functionprocess_docstring
failed somewhere in the documentation. The log without the verbosity flags-vvv
is much more cryptic as only the end exception is outputted.The text was updated successfully, but these errors were encountered: