jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/426861 )
Change subject: [IMPR] Provide a dynamic option help string offset ......................................................................
[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(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
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 == '¶ms;': 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('|', '\|')
pywikibot-commits@lists.wikimedia.org