Rewrap icon indicating copy to clipboard operation
Rewrap copied to clipboard

[Feature request] Disable multi-line paragraph concatenation as a setting

Open logstar opened this issue 4 years ago • 1 comments

Is it possible to add a setting to disable multi-line paragraph concatenation. Say the setting is "rewrap.concatenateMultiLineParagraph".

Python code with long docstring before rewrap (adapted from https://google.github.io/styleguide/pyguide.html#384-classes):

class SampleClass:
    """Summary of class here.

    Longer class information....
    Longer class information....

    Attributes:
        likes_spam: A boolean indicating if we really really really really really like SPAM or not.
        eggs: An integer count of the eggs we have laid. Repeat, An integer count of the eggs we have laid.
    """

    def __init__(self, likes_spam: bool = False):
        """Inits SampleClass with blah."""
        self.likes_spam = likes_spam
        self.eggs = 0

The current behavior of Rewrap v1.14.0 on VS code is the expected behavior of "rewrap.concatenateMultiLineParagraph": true. Python code after rewrapping the long docstring:

class SampleClass:
    """Summary of class here.

    Longer class information.... Longer class information....

    Attributes: likes_spam: A boolean indicating if we really really really
        really really like SPAM or not. eggs: An integer count of the eggs we
        have laid. Repeat, An integer count of the eggs we have laid.
    """

    def __init__(self, likes_spam: bool = False):
        """Inits SampleClass with blah."""
        self.likes_spam = likes_spam
        self.eggs = 0

The expected behavior of "rewrap.concatenateMultiLineParagraph": false. Python code after rewrapping the long docstring:

class SampleClass:
    """Summary of class here.

    Longer class information....
    Longer class information....

    Attributes:
        likes_spam: A boolean indicating if we really really really really
            really like SPAM or not.
        eggs: An integer count of the eggs we have laid. Repeat, An integer
            count of the eggs we have laid.
    """

    def __init__(self, likes_spam: bool = False):
        """Inits SampleClass with blah."""
        self.likes_spam = likes_spam
        self.eggs = 0

Related to https://github.com/stkb/Rewrap/issues/89.

https://github.com/google/yapf does not format docstrings or comments https://github.com/google/yapf/issues/279. Although the comments suggest using https://github.com/myint/docformatter, Python VS code extension decides not to support multiple document formatters at once https://github.com/microsoft/vscode-python/issues/1324.

logstar avatar Aug 12 '21 16:08 logstar

^bump for visibility Unfortunately since this issue is still not resolved, rewrap is basically not usable inside a python project.

tnusser avatar May 29 '24 10:05 tnusser