diff mercurial/help.py @ 8889:9be824115ee8

help: wrap extension descriptions
author Martin Geisler <mg@lazybytes.net>
date Mon, 22 Jun 2009 00:02:31 +0200
parents a3a936a2fe46
children ef59f4634a15
line wrap: on
line diff
--- a/mercurial/help.py	Sun Jun 21 23:17:05 2009 +0200
+++ b/mercurial/help.py	Mon Jun 22 00:02:31 2009 +0200
@@ -5,6 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2, incorporated herein by reference.
 
+import textwrap
 from i18n import _
 import extensions
 
@@ -45,7 +46,11 @@
         return ''
     result = '\n%s\n\n' % header
     for name, desc in sorted(exts.iteritems()):
-        result += ' %s   %s\n' % (name.ljust(maxlength), desc)
+        # wrap desc at 70 characters, just like the main help texts
+        desc = textwrap.wrap(desc, width=70 - maxlength - 4)
+        pad = '\n' + ' ' * (maxlength + 4)
+        result += ' %s   %s\n' % (name.ljust(maxlength),
+                                  pad.join(desc))
     return result
 
 def extshelp():