-
Notifications
You must be signed in to change notification settings - Fork 72
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
Incorrect handling of cvar, ivar and vartype tags in sphynx-style #271
Comments
@pedropaulofb notice the warning in the Sphinx docs about the info field lists, for reference:
docformatter should be formatting the fields correctly. |
@electric-coder, thank you for your answer and interest in helping me. As you can see in the examples I sent, at least to me this is not happening. Am I missing any config or is there something else I can try? |
@pedropaulofb I'm using docformatter version 1.7.2 (check your version with I'm also using standard configurations to wrap in accordance with the python-black code style, so in my [tool.docformatter]
black = true
wrap-descriptions = 88
wrap-summaries = 88 For me docformatter is wrapping the lines correctly, after I run it on your example I get: def my_method(a, b):
"""Abstract base class representing a generic element within an OntoUML model.
:ivar id: A unique identifier for the element, automatically generated upon
instantiation.
:vartype id: str
:ivar created: Timestamp when the element was created, defaults to the current time.
:vartype created: datetime
:ivar modified: Timestamp when the element was last modified, can be None if not
modified.
:vartype modified: Optional[datetime]
:ivar in_project: List of projects this element is part of. Direct modification is
restricted.
:vartype in_project: list[Project]
"""
some_text = 1 So this result is correct. I think there was a bug in a previous docformatter version that's been resolved and might cause the problems you are describing, try updating to a more recent version or setting the |
Dear @electric-coder , thank you for your help! I have the following [tool.docformatter]
black = true
wrap-descriptions = 120
wrap-summaries = 120 My tests were performed in this file. Indeed, when I used version 1.7.2, I got the expected results. When using version 1.7.5 the results were the ones I reported (i.e., the wrong ones). So I also tested versions 1.7.3 (got correct results) and 1.7.4 (got wrong results). Hence, we can conclude that it is a bug introduced in versions >= 1.7.4. Could you please reproduce the test yourself? |
@pedropaulofb I'm not a docformatter maintainer, just a user. I'm sure your tests are correct so I'll excuse myself from the extra work of installing an additional venv to reproduce them. I think this issue is likely the same as #264 |
@electric-coder , It was not a problem! Thank you very much! |
Hey, this change seems to have introduce the problem described here and #264: The obvious solution would be to add all other fields mentioned in https://www.sphinx-doc.org/en/master/usage/domains/python.html#info-field-lists to the regex. But is also the "correct" or most elegant one 🤔 |
Ok, I gave it a try: #295 |
I would like to use cvar, ivar and vartype of the sphyx docstring syntax, however, docformatter is incorrectly handling them.
Expected:
Result:
Is there a workaround to solve this issue?
The text was updated successfully, but these errors were encountered: