-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
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)
svlandeg and minhduc0711
Metadata
Metadata
Assignees
Labels
No labels