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

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.

Change-Id: Ie284b8a8e60d5a5f958d229c5972e8d9bf697d44
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2017-03-15 10:58:49 -04:00
parent f6dbe94907
commit 33b135fe9a
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: