comparison mercurial/help.py @ 8938:9b8c9266c59d

commands: wrap short descriptions in 'hg help' The code for wrapping a single line of text with a hanging indent was duplicated in commands and help -- it's now moved to a new function called wrap in util. The function defaults to a line width is 78 chars, and this un-wraps some command line flag descriptions, hence the test output changes.
author Martin Geisler <mg@lazybytes.net>
date Wed, 24 Jun 2009 19:15:58 +0200
parents 6176ca261f86
children cd92a6968f70
comparison
equal deleted inserted replaced
8937:ea798e03a32e 8938:9b8c9266c59d
3 # Copyright 2006 Matt Mackall <mpm@selenic.com> 3 # Copyright 2006 Matt Mackall <mpm@selenic.com>
4 # 4 #
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2, incorporated herein by reference. 6 # GNU General Public License version 2, incorporated herein by reference.
7 7
8 import textwrap
9 from i18n import _ 8 from i18n import _
10 import extensions 9 import extensions, util
11 10
12 11
13 def moduledoc(file): 12 def moduledoc(file):
14 '''return the top-level python documentation for the given file 13 '''return the top-level python documentation for the given file
15 14
44 '''return a text listing of the given extensions''' 43 '''return a text listing of the given extensions'''
45 if not exts: 44 if not exts:
46 return '' 45 return ''
47 result = '\n%s\n\n' % header 46 result = '\n%s\n\n' % header
48 for name, desc in sorted(exts.iteritems()): 47 for name, desc in sorted(exts.iteritems()):
49 # wrap desc at 70 characters, just like the main help texts 48 desc = util.wrap(desc, maxlength + 4)
50 desc = textwrap.wrap(desc, width=78 - maxlength - 4) 49 result += ' %s %s\n' % (name.ljust(maxlength), desc)
51 pad = '\n' + ' ' * (maxlength + 4)
52 result += ' %s %s\n' % (name.ljust(maxlength),
53 pad.join(desc))
54 return result 50 return result
55 51
56 def extshelp(): 52 def extshelp():
57 doc = _(r''' 53 doc = _(r'''
58 Mercurial has the ability to add new features through the use of 54 Mercurial has the ability to add new features through the use of