Add a way to not put spaces between docstring lines when stripping \n
This commit is contained in:
parent
161c60c4f6
commit
eccd43d357
1 changed files with 10 additions and 5 deletions
|
@ -30,6 +30,7 @@ class Docstring(object):
|
|||
def docstring(s: str) -> Docstring:
|
||||
description = ""
|
||||
last_item = None
|
||||
last_item_no_space = False
|
||||
items = {} # type: typing.Dict[str, str]
|
||||
var_items = {} # type: typing.Dict[str, typing.List[str]]
|
||||
if s:
|
||||
|
@ -39,16 +40,20 @@ def docstring(s: str) -> Docstring:
|
|||
if line:
|
||||
if line[0] == ":":
|
||||
key, _, value = line[1:].partition(": ")
|
||||
last_item = key
|
||||
last_item = key.lstrip("-")
|
||||
last_item_no_space = key.startswith("-")
|
||||
|
||||
if key in var_items:
|
||||
var_items[key].append(value)
|
||||
var_items[last_item].append(value)
|
||||
elif key in items:
|
||||
var_items[key] = [items.pop(key), value]
|
||||
var_items[last_item] = [items.pop(last_item), value]
|
||||
else:
|
||||
items[key] = value
|
||||
items[last_item] = value
|
||||
else:
|
||||
if last_item:
|
||||
if last_item_no_space:
|
||||
items[last_item] += line
|
||||
else:
|
||||
items[last_item] += " %s" % line
|
||||
else:
|
||||
if description:
|
||||
|
|
Loading…
Reference in a new issue