def format_single_arg(config, line_width, arg):
"""Return a list of lines that reflow the single arg and all it's comments
into a block with width at most line_width."""
if arg.comments:
comment_stream = ' '.join([comment[1:].strip()
for comment in arg.comments])
initial_indent = arg.contents + ' # '
subsequent_indent = ' ' * len(arg.contents) + ' # '
wrapper = textwrap.TextWrapper(width=line_width,
expand_tabs=True,
replace_whitespace=True,
drop_whitespace=True,
initial_indent=initial_indent,
subsequent_indent=subsequent_indent)
return wrapper.wrap(comment_stream)
else:
return [arg.contents]
评论列表
文章目录