From 26545b7a09374447ab84d6f8fa2d33010c0a1d78 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 6 Dec 2017 10:00:03 +0000 Subject: [PATCH] sphinxext: Don't sometimes emit trailing newlines Change-Id: I28f82538ef9098c2e5fd2e288302c654422a55e6 --- oslo_config/sphinxext.py | 14 +++++++------- oslo_config/tests/test_sphinxext.py | 16 ---------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/oslo_config/sphinxext.py b/oslo_config/sphinxext.py index bfd359b8..eb04da53 100644 --- a/oslo_config/sphinxext.py +++ b/oslo_config/sphinxext.py @@ -49,7 +49,6 @@ def _list_table(headers, data, title='', columns=None): yield ' - * %s' % row[0] for r in row[1:]: yield ' * %s' % r - yield '' def _indent(text, n=2): @@ -152,7 +151,6 @@ def _format_group(app, namespace, group_name, group_obj, opt_list): 'by the majority of users, and might have a significant', 6) yield _indent( 'effect on stability and/or performance.', 6) - yield '' try: help_text = opt.help % {'default': 'the value above'} @@ -162,22 +160,23 @@ def _format_group(app, namespace, group_name, group_obj, opt_list): # invalid formatting characters help_text = opt.help if help_text: - yield _indent(help_text) yield '' + yield _indent(help_text) # We don't bother outputting this if not using new-style choices with # inline descriptions if getattr(opt.type, 'choices', None) and not all( x is None for x in opt.type.choices.values()): - yield _indent('.. rubric:: Possible values') yield '' + yield _indent('.. rubric:: Possible values') for choice in opt.type.choices: + yield '' yield _indent(_get_choice_text(choice)) yield _indent(_indent( opt.type.choices[choice] or '')) - yield '' if opt.deprecated_opts: + yield '' for line in _list_table( ['Group', 'Name'], ((d.group or group_name, @@ -185,7 +184,9 @@ def _format_group(app, namespace, group_name, group_obj, opt_list): for d in opt.deprecated_opts), title='Deprecated Variations'): yield _indent(line) + if opt.deprecated_for_removal: + yield '' yield _indent('.. warning::') if opt.deprecated_since: yield _indent(' This option is deprecated for removal ' @@ -194,10 +195,9 @@ def _format_group(app, namespace, group_name, group_obj, opt_list): yield _indent(' This option is deprecated for removal.') yield _indent(' Its value may be silently ignored ') yield _indent(' in the future.') - yield '' if opt.deprecated_reason: + yield '' yield _indent(' :Reason: ' + opt.deprecated_reason) - yield '' yield '' diff --git a/oslo_config/tests/test_sphinxext.py b/oslo_config/tests/test_sphinxext.py index aee69e1d..b1f4410d 100644 --- a/oslo_config/tests/test_sphinxext.py +++ b/oslo_config/tests/test_sphinxext.py @@ -42,7 +42,6 @@ class FormatGroupTest(base.BaseTestCase): :Default: ```` this appears in the default group - ''').lstrip(), results) def test_with_default_value(self): @@ -66,7 +65,6 @@ class FormatGroupTest(base.BaseTestCase): :Default: ``this is the default`` this appears in the default group - ''').lstrip(), results) def test_with_min(self): @@ -88,7 +86,6 @@ class FormatGroupTest(base.BaseTestCase): :Type: integer :Default: ```` :Minimum Value: 1 - ''').lstrip(), results) def test_with_min_0(self): @@ -110,7 +107,6 @@ class FormatGroupTest(base.BaseTestCase): :Type: integer :Default: ```` :Minimum Value: 0 - ''').lstrip(), results) def test_with_max(self): @@ -132,7 +128,6 @@ class FormatGroupTest(base.BaseTestCase): :Type: integer :Default: ```` :Maximum Value: 1 - ''').lstrip(), results) def test_with_max_0(self): @@ -154,7 +149,6 @@ class FormatGroupTest(base.BaseTestCase): :Type: integer :Default: ```` :Maximum Value: 0 - ''').lstrip(), results) def test_with_choices(self): @@ -176,7 +170,6 @@ class FormatGroupTest(base.BaseTestCase): :Type: string :Default: ```` :Valid Values: a, b, c, , '' - ''').lstrip(), results) def test_with_choices_with_descriptions(self): @@ -221,7 +214,6 @@ class FormatGroupTest(base.BaseTestCase): '' - ''').lstrip(), results) def test_group_obj_without_help(self): @@ -240,7 +232,6 @@ class FormatGroupTest(base.BaseTestCase): :Type: string :Default: ```` - ''').lstrip(), results) def test_group_obj_with_help(self): @@ -261,7 +252,6 @@ class FormatGroupTest(base.BaseTestCase): :Type: string :Default: ```` - ''').lstrip(), results) def test_deprecated_opts_without_deprecated_group(self): @@ -291,7 +281,6 @@ class FormatGroupTest(base.BaseTestCase): * Name - * DEFAULT * deprecated_name - ''').lstrip(), results) def test_deprecated_opts_with_deprecated_group(self): @@ -322,7 +311,6 @@ class FormatGroupTest(base.BaseTestCase): * Name - * deprecated_group * deprecated_name - ''').lstrip(), results) def test_deprecated_for_removal(self): @@ -362,7 +350,6 @@ class FormatGroupTest(base.BaseTestCase): :Type: integer :Default: ```` :Mutable: This option can be changed without restarting. - ''').lstrip(), results) def test_not_mutable(self): @@ -383,7 +370,6 @@ class FormatGroupTest(base.BaseTestCase): :Type: integer :Default: ```` - ''').lstrip(), results) def test_advanced(self): @@ -407,7 +393,6 @@ class FormatGroupTest(base.BaseTestCase): :Advanced Option: Intended for advanced users and not used by the majority of users, and might have a significant effect on stability and/or performance. - ''').lstrip(), results) def test_not_advanced(self): @@ -428,7 +413,6 @@ class FormatGroupTest(base.BaseTestCase): :Type: string :Default: ```` - ''').lstrip(), results)