jenkins-bot merged this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[IMPR] Provide a dynamic option help string offset

Currently the help string option offset is fixed to 16 spaces but this
does not fit for all help strings. Provide a dynamic offset.

Change-Id: Iaf7d8b16bc15e0c0a55ad6bd3a1a38a21ababc16
---
M docs/conf.py
1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index 4d067db..267a93e 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -19,6 +19,7 @@

import os
from os.path import abspath, dirname, join
+import re
import sys

# If extensions (or modules to document with autodoc) are in another directory,
@@ -268,6 +269,8 @@

if not name.startswith('scripts.'):
return
+
+ length = 0
for index, line in enumerate(lines):
if line == '&params;':
lines[index] = ('This script supports use of '
@@ -280,7 +283,7 @@
elif name == 'scripts.login' and '*' in line:
# Escape star wildcard in scripts/login.py
lines[index] = line.replace('*', '\\*')
- elif (line.endswith(':') and not line.strip().startswith(':') and
+ elif (line.endswith(':') and not line.lstrip().startswith(':') and
'Traceback (most recent call last)' not in line):
# Initiate code block except pagegenerator arguments follows
for afterline in lines[index + 1:]:
@@ -291,12 +294,20 @@
else:
lines[index] = line + ':'
break
+
if line.startswith('-'):
# Indent options
+ match = re.match(r'-[^ ]+? +', line)
+ if match:
+ length = len(match.group(0))
lines[index] = ' ' + line
- elif line.startswith(' '):
- # Indent description of options (as options are indented)
- lines[index] = line.replace(' ', ' ')
+ elif length and line.startswith(' ' * length):
+ # Indent descriptions of options (as options are indented)
+ lines[index] = ' ' + line
+ elif line != '':
+ # Reset length
+ length = 0
+
if '|' in line:
# Escape vertical bars
lines[index] = line.replace('|', '\\|')

To view, visit change 426861. To unsubscribe, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaf7d8b16bc15e0c0a55ad6bd3a1a38a21ababc16
Gerrit-Change-Number: 426861
Gerrit-PatchSet: 8
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot <>