PyCQA/docformatter

Docstrings containing backticks are not formatted

paduszyk opened this issue ยท 1 comments

Hi! โœ‹๐Ÿป

The package is great! Thanks a lot for contributing! ๐Ÿฅ‡

I have been using it for while and recently noticed that the tool ignores the docstrings containing "backticks" (the ones used e.g. to markup inline code in GitHub markdown).

My configuration (pyproject.toml) is:

[tool.docformatter]
black = true
blank = true
close-quotes-on-newline = true
make-summary-multi-line = true
recursive = true
pre-summary-newline = true

Sample code:

def foo(bar):
    """Return `foo` using `bar`. Description."""

is not formatted (neither via CLI nor pre-commit hook). If I replace backticks to single quotation marks, everything works as expected, namely I get the following diff.:

--- before/./test.py
+++ after/./test.py
@@ -12,4 +12,9 @@
 
 
 def foo(bar):
-    """Return 'foo' using 'bar'. Description."""
+    """
+    Return 'foo' using 'bar'.
+
+    Description.
+
+    """

Any ideas? Thanks! ๐Ÿค

I have

% docformatter --version
docformatter 1.7.5

The fix appears to apply only to the first line and not to the description lines that follow, e.g.

% cat foo.py
def f():
    """
    Here is a sufficiently long docstring first line with a ``word`` wrapped in backticks which will be wrapped as expected.

    Here is a sufficiently long docstring description with a ``word`` wrapped in backticks which will not be wrapped as expected.
    """
    pass
% docformatter foo.py
% cat foo.py
def f():
    """
    Here is a sufficiently long docstring first line with a ``word`` wrapped in backticks which will
    be wrapped as expected.

    Here is a sufficiently long docstring description with a ``word`` wrapped in backticks which will not be wrapped as expected.
    """
    pass

Is this intended / am I doing it wrong?

Here's my config block in pyproject.toml:

[tool.docformatter]
black = true
in-place = true
make-summary-multi-line = true
pre-summary-newline = true
recursive = true
wrap-descriptions = 100
wrap-summaries = 100

Thanks in advance for any guidance, and thanks in general for this great tool!