comparison mercurial/help.py @ 16852:af69b2b64d6e

help: format extension lists using RST This change is a move towards generating all help text as a list of strings marked up with RST.
author Olav Reinert <seroton10@gmail.com>
date Sat, 02 Jun 2012 11:22:33 +0200
parents 4594729c61ee
children 57a5ac98f9b7
comparison
equal deleted inserted replaced
16851:c739227b5eea 16852:af69b2b64d6e
10 import extensions, revset, fileset, templatekw, templatefilters, filemerge 10 import extensions, revset, fileset, templatekw, templatefilters, filemerge
11 import encoding, util, minirst 11 import encoding, util, minirst
12 12
13 def listexts(header, exts, indent=1): 13 def listexts(header, exts, indent=1):
14 '''return a text listing of the given extensions''' 14 '''return a text listing of the given extensions'''
15 if not exts: 15 rst = []
16 return '' 16 if exts:
17 maxlength = max(len(e) for e in exts) 17 rst.append('\n%s\n\n' % header)
18 result = '\n%s\n\n' % header 18 for name, desc in sorted(exts.iteritems()):
19 for name, desc in sorted(exts.iteritems()): 19 rst.append('%s:%s: %s\n' % (' ' * indent, name, desc))
20 result += '%s%-*s %s\n' % (' ' * indent, maxlength + 2, 20 return rst
21 ':%s:' % name, desc)
22 return result
23 21
24 def extshelp(): 22 def extshelp():
25 doc = loaddoc('extensions')() 23 rst = loaddoc('extensions')().splitlines(True)
26 doc += listexts(_('enabled extensions:'), extensions.enabled()) 24 rst.extend(listexts(_('enabled extensions:'), extensions.enabled()))
27 doc += listexts(_('disabled extensions:'), extensions.disabled()) 25 rst.extend(listexts(_('disabled extensions:'), extensions.disabled()))
26 doc = ''.join(rst)
28 return doc 27 return doc
29 28
30 def optrst(options, verbose): 29 def optrst(options, verbose):
31 data = [] 30 data = []
32 multioccur = False 31 multioccur = False