From patchwork Thu Feb 20 17:04:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 4] doc: gendoc.py creates valid output for option descriptions with newlines From: Simon Heimberg X-Patchwork-Id: 3722 Message-Id: <9f1794bed2db8a443e17.1392915882@lapsi.heimberg.home> To: Mercurial-devel Date: Thu, 20 Feb 2014 18:04:42 +0100 # HG changeset patch # User Simon Heimberg # 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. 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)