From 33b135fe9a04dbaddc82f27f21f5955cbbefac02 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 15 Mar 2017 10:58:49 -0400 Subject: [PATCH] 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 --- .../notes/no-show-source-option-ee02766b26fe53be.yaml | 8 ++++++++ reno/formatter.py | 9 ++++++--- reno/main.py | 7 +++++++ reno/report.py | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/no-show-source-option-ee02766b26fe53be.yaml diff --git a/releasenotes/notes/no-show-source-option-ee02766b26fe53be.yaml b/releasenotes/notes/no-show-source-option-ee02766b26fe53be.yaml new file mode 100644 index 0000000..7074ad3 --- /dev/null +++ b/releasenotes/notes/no-show-source-option-ee02766b26fe53be.yaml @@ -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. diff --git a/reno/formatter.py b/reno/formatter.py index b6d43ec..646d68e 100644 --- a/reno/formatter.py +++ b/reno/formatter.py @@ -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('') diff --git a/reno/main.py b/reno/main.py index 79f8589..b8e2a8d 100644 --- a/reno/main.py +++ b/reno/main.py @@ -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) diff --git a/reno/report.py b/reno/report.py index 2a59410..fc2dda0 100644 --- a/reno/report.py +++ b/reno/report.py @@ -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: