support multi-line notes and notes with complex formatting

Change-Id: Iedfe043ef3a166b075871f55148468ccebe94ea6
This commit is contained in:
Doug Hellmann 2015-10-01 21:48:21 +00:00
parent ba231d06d6
commit 64763db3f6
2 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1,13 @@
---
features:
- |
Support note entries that span multiple lines using
preformatted syntax in YAML by prefixing the
list entry with ``|``.
For example::
- |
This entry has two paragraphs.
This is the second.

View File

@ -28,6 +28,18 @@ _SECTION_ORDER = [
]
def _indent_for_list(text, prefix=' '):
"""Indent some text to make it work as a list entry.
Indent all lines except the first with the prefix.
"""
lines = text.splitlines()
return '\n'.join([lines[0]] + [
prefix + l
for l in lines[1:]
]) + '\n'
def format_report(reporoot, scanner_output, versions_to_include, title=None):
report = []
if title:
@ -71,7 +83,7 @@ def format_report(reporoot, scanner_output, versions_to_include, title=None):
report.append('-' * len(section_title))
report.append('')
for n in notes:
report.append('- %s' % n)
report.append('- %s' % _indent_for_list(n))
report.append('')
return '\n'.join(report)