You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rrwalton opened this issue
Jul 3, 2023
· 2 comments
· Fixed by #248
Labels
C: styleRelates to docstring format style (e.g., Google, NumPy, Sphinx)P: bugPEP 257 violation or existing functionality that doesn't work as documentedU: mediumA relatively medium urgency issue
> docformatter --version
docformatter 1.7.3
> cat test.py
def f(a: int) -> None:
"""Some f.
:param a: Some param.
:raises my.package.MyReallySrsError: Bad things happened.
"""
return None
> docformatter test.py --diff
--- before/test.py
+++ after/test.py
@@ -1,6 +1,7 @@
def f(a: int) -> None:
"""Some f.
- :param a: Some param.
- :raises my.package.MyReallySrsError: Bad things happened.
+
+ :param a: Some param. :raises my.package.MyReallySrsError: Bad
+ things happened.
"""
return None
It seems as though the field name isn't recognised as a field name if it contains a . character. My understanding is that its valid for a sphinx style field name to contain a .; I think the SPHINX_REGEX pattern might be incorrect?
weibullguy
added
P: bug
PEP 257 violation or existing functionality that doesn't work as documented
C: style
Relates to docstring format style (e.g., Google, NumPy, Sphinx)
and removed
fresh
This is a new issue
labels
Jul 3, 2023
If the field name could be any characters, with a special case of 'colons followed by white-space' being backslash-escaped, then I think the regexp probably needs some more work than in my suggested fix. I'm not really a regex whizz, but there's possibly an incantation that'll capture all the cases?
It might also need to handle strings like: :raises `my.package.Error`: Raised when :py:obj:`my.package.RobustObject` sees something it doesn't like.
Although I'm not sure how much the sphinx cross-referencing stuff is in scope for this tool, because it's not really anything to do with pep257.
C: styleRelates to docstring format style (e.g., Google, NumPy, Sphinx)P: bugPEP 257 violation or existing functionality that doesn't work as documentedU: mediumA relatively medium urgency issue
Running the following:
It seems as though the field name isn't recognised as a field name if it contains a
.
character. My understanding is that its valid for a sphinx style field name to contain a.
; I think theSPHINX_REGEX
pattern might be incorrect?docformatter/src/docformatter/syntax.py
Line 62 in b54a22c
If I change this regex pattern to
SPHINX_REGEX = r":[a-zA-Z0-9_\-(). ]*:"
then I do get a correctly formatted docstring.The text was updated successfully, but these errors were encountered: