-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
numpy parser parameter table breaks if there is an empty line between parameters #167
Comments
Thanks for the report! I find it weird that
...would be parsed as a single Returns section. How do you intertwine prose and semantic sections? Is that not possible with Numpydoc's spec? And how should However this is just my opinion, and I'm fine with anything that matches the spec: I'm not using this docstring style after all, so those who actually use it know better 🙂 Reading again the spec at https://numpydoc.readthedocs.io/en/latest/format.html, it seems indeed that prose is not expected in-between sections, and therefore headings (and dash lines) are the true sections delimiters, not blank lines. |
Hmm... I dug a bit deeper, and it looks like sphinx does allow including extra narrative (to a degree). It seems like the rule they use to end a section (sphinx code here) is...
So maybe this could be a nice compromise? I didn't realize that numpydoc and sphinx both have parsers :/ |
Parsers, parsers everywhere! Thanks for investigating, the double blank line seems like a good compromise indeed. That's a breaking change though 🤔 |
Yeah, it's a tough spot :/. For what it's worth, I think there are libraries using sphinx in the wild that that include empty lines in their parameter tables. I haven't seen people add narrative to sections like parameters, so am in favor of breaking changes there 😬 (but if it's helpful, we could also refactor the numpy parser to be a class, and then I could subclass it as a new parser implementation somewhere?). Here's an example docstring from the pandas DataFrame docs:
numpy.array (maybe less of an issue, since empty lines are in parameter descriptions):
|
Yep second example poses no issue, since the indentation helps us determining it's still within the section (and section item). We could add an option to the numpy parser? This way, no breaking change, and users can still opt-in to be able to have blank lines in sections (while needing double blank lines to separate prose from sections or inversely. |
Describe the bug
From what I can tell, the numpydoc parser supports empty lines between parameter descriptions. e.g.
However, with griffe's numpy parser this triggers the end of the parameters table.
One possible solution
If we instead use the following rule to indicate a new section, it should be able to keep the table intact, without changing the current behavior too much.
---
)Breaking cases
Note that with this solution, these kinds of docstrings from the unit tests could be parsed differently:
Currently, these get parsed as 2 sections (a Returns and a generic Text section). However, AFAICT, the numpydoc parser just considers the "Something." to be part of the Returns section, since sections must be separated by headings.
WDYT? Happy to find the right balance of current behavior / supporting table description variations!
The text was updated successfully, but these errors were encountered: