stkb / Rewrap

Rewrap extension for VSCode and Visual Studio
https://marketplace.visualstudio.com/items/stkb.rewrap
Other
507 stars 63 forks source link

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

Open logstar opened 3 years ago

logstar commented 3 years ago

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.

tnusser commented 4 months ago

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