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

Simon Heimberg simohe at besonet.ch
Thu Feb 20 11:04:42 CST 2014


# HG changeset patch
# User Simon Heimberg <simohe at 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.

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)
 


More information about the Mercurial-devel mailing list