From b69e0019e86f8ca69809f44c3093e651650d7aea Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 21 Feb 2017 13:46:08 -0500 Subject: [PATCH] Simplify the format of paragraphs There's a rather complicated bit of code used to split blocks of text into paragraphs. Replace this with something a little simpler that makes use of our paragraph-ization rather than trying to rebuild blocks of text. Change-Id: I321ba57d0f7090afec34c6207f9a42493b8a3249 --- autogenerate_config_docs/autohelp.py | 6 +++--- .../templates/autohelp.rst.j2 | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/autogenerate_config_docs/autohelp.py b/autogenerate_config_docs/autohelp.py index f7698a42..dd6a01fb 100755 --- a/autogenerate_config_docs/autohelp.py +++ b/autogenerate_config_docs/autohelp.py @@ -486,8 +486,7 @@ def write_files(package_name, options, target, output_format): helptext = helptext.replace('\n\n', '$sentinal$') helptext = helptext.replace('\n', ' ') helptext = ' '.join(helptext.split()) - # TODO(johngarbutt) space matches only the current template :( - helptext = helptext.replace('$sentinal$', '\n\n ') + helptext = helptext.split('$sentinal$') if not option.deprecated_reason: option.deprecated_reason = ( @@ -508,8 +507,9 @@ def write_files(package_name, options, target, output_format): ' restarting.')) item = (option.dest, + opt_type, _sanitize_default(option), - "(%s) %s" % (opt_type, helptext), + helptext, flags) items.append(item) diff --git a/autogenerate_config_docs/templates/autohelp.rst.j2 b/autogenerate_config_docs/templates/autohelp.rst.j2 index b2a6a415..8cd289c0 100644 --- a/autogenerate_config_docs/templates/autohelp.rst.j2 +++ b/autogenerate_config_docs/templates/autohelp.rst.j2 @@ -17,16 +17,25 @@ * - Configuration option = Default value - Description {% for group in groups %} + * - **[{{ group }}]** - {% for item in items[loop.index0] %} -{% if item[1] is equalto '' %} + +{% if item[2] is equalto '' %} * - ``{{ item[0] }}`` = {% else %} - * - ``{{ item[0] }}`` = ``{{ item[1] }}`` + * - ``{{ item[0] }}`` = ``{{ item[2] }}`` {% endif %} - - {{ item[2] }} -{% for flagname, flagdesc in item[3] %} +{% for paragraph in item[3] %} + +{% if loop.first %} + - ({{ item [1] }}) {{ paragraph }} +{% else %} + {{ paragraph }} +{% endif %} +{% endfor %} +{% for flagname, flagdesc in item[4] %} - **{{ flagname }}**