From 43c6ba77c93af6b07da3f4c06c05ce414360d5e9 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 18 Jul 2018 09:58:10 +0100 Subject: [PATCH] sphinxext: Handle multi-line group descriptions While multi-line help texts for opts were already handled properly, the same was not true of groups. Close this gap, allowing us to resolve the FIXME in the process. Change-Id: Ic564dbff983205134386ba5b7047d6d811c60ef1 Signed-off-by: Stephen Finucane --- oslo_config/sphinxext.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/oslo_config/sphinxext.py b/oslo_config/sphinxext.py index d9f256a0..74a15ef9 100644 --- a/oslo_config/sphinxext.py +++ b/oslo_config/sphinxext.py @@ -202,7 +202,8 @@ def _format_group(namespace, group_name, group_obj): yield '' if group_obj and group_obj.help: - yield _indent(group_obj.help.rstrip()) + for line in group_obj.help.strip().splitlines(): + yield _indent(line.rstrip()) yield '' @@ -304,19 +305,10 @@ class ShowOptionsDirective(rst.Directive): result = ViewList() source_name = self.state.document.current_source - offset = 0 for count, line in enumerate(_format_option_help( namespaces, split_namespaces)): - # FIXME(stephenfin): Some lines emitted are actually multiple - # lines. This throws off our counter, which is rather annoying. - # We handle this here but we should really handle it higher up. - parts = line.split('\n') - if len(parts) > 1: - offset += len(parts) - 1 - - for part in parts: - result.append(part, source_name, count + offset) - LOG.debug(' '.join(['%5d' % (count + offset), part])) + result.append(line, source_name, count) + LOG.debug(' '.join(['%5d' % (count), line])) node = nodes.section() node.document = self.state.document