Patchwork [2,of,4] doc: gendoc.py creates valid output for option descriptions with newlines

login
register
mail settings
Submitter Simon Heimberg
Date Feb. 20, 2014, 5:04 p.m.
Message ID <9f1794bed2db8a443e17.1392915882@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/3722/
State Accepted
Commit 37f3be9d154190f154770aac5e38080f6a80145e
Headers show

Comments

Simon Heimberg - Feb. 20, 2014, 5:04 p.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1392884242 -3600
#      Thu Feb 20 09:17:22 2014 +0100
# Node ID 9f1794bed2db8a443e175de16871dab4ef8dda2b
# Parent  9a836a1cde06f4b54effd23c3feaf9ca0ff9e269
doc: gendoc.py creates valid output for option descriptions with newlines

gendoc.py did not handle the hanging indentation for descriptions. Work around
this by joining all in one single line (same as in minirst since previous
patch).

This problem occurred when translations of option lines were very long. Do not
bother the translators with this detail.

On a long option description, the translator continued on a new line as usual.
gendoc.py created invalid rst syntax like this:

-o, --option
    Description line 1
description line 2

The new output is:

-o, --option
    Description line 1 description line 2

The lines could theoretically become very long, but line breaking is handled
when generating the final documentation.

Patch

diff -r 9a836a1cde06 -r 9f1794bed2db doc/gendoc.py
--- a/doc/gendoc.py	Wed Feb 19 17:32:21 2014 +0100
+++ b/doc/gendoc.py	Thu Feb 20 09:17:22 2014 +0100
@@ -50,6 +50,9 @@ 
             allopts[-1] += " <%s[+]>" % optlabel
         elif (default is not None) and not isinstance(default, bool):
             allopts[-1] += " <%s>" % optlabel
+        if '\n' in desc:
+            # only remove line breaks and indentation
+            desc = ' '.join(l.lstrip() for l in desc.split('\n'))
         desc += default and _(" (default: %s)") % default or ""
         yield (", ".join(allopts), desc)