def format_description(content, width=70, indent=8, indent_first=False):
"""Format documentation description"""
# TODO: document, test, and use
lines = content.splitlines()
def format_line(line):
if line.startswith('-'):
return textwrap.indent(textwrap.fill(line, width - indent - 2),
(indent + 2) * ' ')[2:]
else:
return textwrap.indent(textwrap.fill(line, width - indent),
indent * ' ')
result = '\n'.join(format_line(line) for line in lines if line)
if not indent_first:
result = result.lstrip()
return result
评论列表
文章目录