comparison mercurial/commands.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 d0fc1e689227
children 7863ff383894
comparison
equal deleted inserted replaced
16851:c739227b5eea 16852:af69b2b64d6e
3216 ui.write('%s\n' % (util.wrap(h[f], textwidth, 3216 ui.write('%s\n' % (util.wrap(h[f], textwidth,
3217 initindent=' %-*s ' % (m, f), 3217 initindent=' %-*s ' % (m, f),
3218 hangindent=' ' * (m + 4)))) 3218 hangindent=' ' * (m + 4))))
3219 3219
3220 if not name: 3220 if not name:
3221 text = help.listexts(_('enabled extensions:'), extensions.enabled()) 3221 rst = help.listexts(_('enabled extensions:'), extensions.enabled())
3222 if text: 3222 if rst:
3223 ui.write("\n%s" % minirst.format(text, textwidth)) 3223 ui.write("\n%s" % minirst.format('\n'.join(rst), textwidth))
3224 3224
3225 ui.write(_("\nadditional help topics:\n\n")) 3225 ui.write(_("\nadditional help topics:\n\n"))
3226 topics = [] 3226 topics = []
3227 for names, header, doc in help.helptable: 3227 for names, header, doc in help.helptable:
3228 topics.append((sorted(names, key=len, reverse=True)[0], header)) 3228 topics.append((sorted(names, key=len, reverse=True)[0], header))
3316 def helpextcmd(name): 3316 def helpextcmd(name):
3317 cmd, ext, mod = extensions.disabledcmd(ui, name, 3317 cmd, ext, mod = extensions.disabledcmd(ui, name,
3318 ui.configbool('ui', 'strict')) 3318 ui.configbool('ui', 'strict'))
3319 doc = gettext(mod.__doc__).splitlines()[0] 3319 doc = gettext(mod.__doc__).splitlines()[0]
3320 3320
3321 msg = help.listexts(_("'%s' is provided by the following " 3321 rst = help.listexts(_("'%s' is provided by the following "
3322 "extension:") % cmd, {ext: doc}, indent=4) 3322 "extension:") % cmd, {ext: doc}, indent=4)
3323 ui.write(minirst.format(msg, textwidth)) 3323 rst.append('\n')
3324 ui.write('\n') 3324 rst.append(_('use "hg help extensions" for information on enabling '
3325 ui.write(_('use "hg help extensions" for information on enabling '
3326 'extensions\n')) 3325 'extensions\n'))
3326 ui.write(minirst.format(''.join(rst), textwidth))
3327 3327
3328 kw = opts.get('keyword') 3328 kw = opts.get('keyword')
3329 if kw: 3329 if kw:
3330 matches = help.topicmatch(kw) 3330 matches = help.topicmatch(kw)
3331 for t, title in (('topics', _('Topics')), 3331 for t, title in (('topics', _('Topics')),