Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Remove newlines in descriptions that span multiple lines #87

Copy link
Copy link
@bkanuka

Description

@bkanuka
Issue body actions

I would like to format my docstrings to have a max line length, but these line breaks should not be present after parsing. This is the behaviour of other docstring parsers, as well as markup formats like markdown or rst. A line break should be present if there are 2 newlines.

For example:

from docstring_parser import parse

docstring = """
    short description
    
    Long description that can span multiple lines. This is test sentence 1. This is test sentence 2. I do not want a 
    line break in this sentence.

    Parameters:
        param_1: Description of param_1. This is test sentence 1. This is test sentence 2. This is test sentence 3. I
            do not want a line break in this sentence. 
    """

parsed = parse(docstring)

print("Long description:")
print(repr(parsed.long_description))

print("Parameters:")
for param in parsed.params:
    print(repr(param.description))

gives the output:

Long description:
'Long description that can span multiple lines. This is test sentence 1. This is test sentence 2. I do not want a \nline break in this sentence.'
Parameters:
'Description of param_1. This is test sentence 1. This is test sentence 2. This is test sentence 3. I\ndo not want a line break in this sentence. '

(note that I use repr to make it clear that the newlines are present)

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.