Skip to content
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

Docformatter can break an RST cross-reference #124

Closed
mhsmith opened this issue Oct 21, 2022 · 4 comments · Fixed by #155
Closed

Docformatter can break an RST cross-reference #124

mhsmith opened this issue Oct 21, 2022 · 4 comments · Fixed by #155
Labels
C: style Relates to docstring format style (e.g., Google, NumPy, Sphinx) P: bug PEP 257 violation or existing functionality that doesn't work as documented
Milestone

Comments

@mhsmith
Copy link

mhsmith commented Oct 21, 2022

I see there are some existing issues about Sphinx and RST (e.g. #68, #60, #78, #61), but I don't see one mentioning this specific problem.

Docformatter version 1.5.0.

Input:

    def quadratic_curve_to(self, cpx, cpy, x, y):
        """Constructs and returns a :class:`QuadraticCurveTo <QuadraticCurveTo>`.

        Second line
        """

First pass (still OK):

    def quadratic_curve_to(self, cpx, cpy, x, y):
        """Constructs and returns a :class:`QuadraticCurveTo
        <QuadraticCurveTo>`.

        Second line
        """

Second pass (broken):

    def quadratic_curve_to(self, cpx, cpy, x, y):
        """Constructs and returns a :class:`QuadraticCurveTo.

        <QuadraticCurveTo>`.

        Second line
        """
@github-actions github-actions bot added the fresh This is a new issue label Oct 21, 2022
@weibullguy weibullguy added S: duplicate Closed as a duplicate issue or PR 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) V: patch Bumps the patch version and removed fresh This is a new issue S: duplicate Closed as a duplicate issue or PR labels Nov 7, 2022
@kdeldycke
Copy link

I can confirm the issue, which not affect rST cross-references, but virtually any space-separated rST directive.

See for example this Python code:

def setup():
    """Register ``..click:example::`` and ``.. click:run::`` directives, augmented with ANSI coloring."""
    pass

Which is formatted with a split in the middle of a double-backticked sequence:

--- before/./rst-docstring.py
+++ after/./rst-docstring.py
@@ -1,3 +1,6 @@
 def setup():
-    """Register ``..click:example::`` and ``.. click:run::`` directives, augmented with ANSI coloring."""
+    """Register ``..click:example::`` and ``..
+
+    click:run::`` directives, augmented with ANSI coloring.
+    """
     pass

These results have been produced with the latest development version of docformatter (d369613 at the time of writing).

@kdeldycke
Copy link

This issue might be related to #79, in which a double invokation of docformatter produces an extra blank line of a long line, like in the result above.

@kdeldycke
Copy link

There's probably some inspiration on how to handle this in the recent PR that fixed URL wrapping (#115).

You can see there a special case for URLs using an rST syntax (.. a link: https://example.com/index.html): 9c18ed4#diff-9a6d834c8022d3c6f558a340e5f2c78bab7adb15a880272d63f8b5d16d646a7cR938-R943

@weibullguy weibullguy modified the milestone: v1.6.0 Dec 16, 2022
@weibullguy weibullguy removed this from the v1.6.0 milestone Jan 8, 2023
@weibullguy weibullguy removed the V: patch Bumps the patch version label Jan 19, 2023
@weibullguy weibullguy added this to the v2.0.0 milestone Jan 19, 2023
@fmigneault
Copy link

I'm forced to pin docformatter==1.5.0 because of this new bug in 1.5.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: style Relates to docstring format style (e.g., Google, NumPy, Sphinx) P: bug PEP 257 violation or existing functionality that doesn't work as documented
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants