Merge "add --no-show-source option to report command"

This commit is contained in:
Jenkins 2017-03-15 20:22:38 +00:00 committed by Gerrit Code Review
commit 131ae2b55b
4 changed files with 22 additions and 3 deletions

View File

@ -0,0 +1,8 @@
---
features:
- |
Add a ``--no-show-source`` option to the report command to skip
including the note reference file names and SHA information
in comments in the output. This restores the previous format of
the output for cases where it is meant to be read by people directly,
not just converted to HTML.

View File

@ -25,7 +25,8 @@ def _indent_for_list(text, prefix=' '):
]) + '\n'
def format_report(loader, config, versions_to_include, title=None):
def format_report(loader, config, versions_to_include, title=None,
show_source=True):
report = []
if title:
report.append('=' * len(title))
@ -49,7 +50,8 @@ def format_report(loader, config, versions_to_include, title=None):
notefiles = loader[version]
for n, sha in notefiles:
if 'prelude' in file_contents[n]:
report.append('.. %s @ %s\n' % (n, sha))
if show_source:
report.append('.. %s @ %s\n' % (n, sha))
report.append(file_contents[n]['prelude'])
report.append('')
@ -65,7 +67,8 @@ def format_report(loader, config, versions_to_include, title=None):
report.append('-' * len(section_title))
report.append('')
for n, fn, sha in notes:
report.append('.. %s @ %s\n' % (fn, sha))
if show_source:
report.append('.. %s @ %s\n' % (fn, sha))
report.append('- %s' % _indent_for_list(n))
report.append('')

View File

@ -138,6 +138,13 @@ def main(argv=sys.argv[1:]):
default=None,
help='output filename, defaults to stdout',
)
do_report.add_argument(
'--no-show-source',
dest='show_source',
default=True,
action='store_false',
help='do not show the source for notes',
)
_build_query_arg_group(do_report)
do_report.set_defaults(func=report.report_cmd)

View File

@ -28,6 +28,7 @@ def report_cmd(args, conf):
conf,
versions,
title='Release Notes',
show_source=args.show_source,
)
if args.output:
with open(args.output, 'w') as f: