##// END OF EJS Templates
help: format all output using RST...
Olav Reinert -
r16854:d71ada5a default
parent child Browse files
Show More
@@ -3097,16 +3097,18 b' def help_(ui, name=None, unknowncmd=Fals'
3097 3097 # except block, nor can be used inside a lambda. python issue4617
3098 3098 prefix = inst.args[0]
3099 3099 select = lambda c: c.lstrip('^').startswith(prefix)
3100 helplist(select)
3101 return
3100 rst = helplist(select)
3101 return rst
3102
3103 rst = []
3102 3104
3103 3105 # check if it's an invalid alias and display its error if it is
3104 3106 if getattr(entry[0], 'badalias', False):
3105 3107 if not unknowncmd:
3108 ui.pushbuffer()
3106 3109 entry[0](ui)
3107 return
3108
3109 rst = []
3110 rst.append(ui.popbuffer())
3111 return rst
3110 3112
3111 3113 # synopsis
3112 3114 if len(entry) > 2:
@@ -3165,10 +3167,7 b' def help_(ui, name=None, unknowncmd=Fals'
3165 3167 elif not ui.quiet:
3166 3168 rst.append(_('\nuse "hg -v help %s" to show more info\n')
3167 3169 % name)
3168
3169 keep = ui.verbose and ['verbose'] or []
3170 formatted, pruned = minirst.format(''.join(rst), textwidth, keep=keep)
3171 ui.write(formatted)
3170 return rst
3172 3171
3173 3172
3174 3173 def helplist(select=None):
@@ -3201,11 +3200,12 b' def help_(ui, name=None, unknowncmd=Fals'
3201 3200 h[f] = doc.splitlines()[0].rstrip()
3202 3201 cmds[f] = c.lstrip("^")
3203 3202
3203 rst = []
3204 3204 if not h:
3205 ui.status(_('no commands defined\n'))
3206 return
3207
3208 rst = []
3205 if not ui.quiet:
3206 rst.append(_('no commands defined\n'))
3207 return rst
3208
3209 3209 if not ui.quiet:
3210 3210 rst.append(header)
3211 3211 fns = sorted(h)
@@ -3253,7 +3253,7 b' def help_(ui, name=None, unknowncmd=Fals'
3253 3253 rst.append('\n%s\n' % title)
3254 3254 if options:
3255 3255 rst.append('\n%s\n' % help.optrst(options, ui.verbose))
3256 ui.write(minirst.format(''.join(rst), textwidth))
3256 return rst
3257 3257
3258 3258 def helptopic(name):
3259 3259 for names, header, doc in help.helptable:
@@ -3275,7 +3275,7 b' def help_(ui, name=None, unknowncmd=Fals'
3275 3275 'the %s command\n') % (name, name))
3276 3276 except error.UnknownCommand:
3277 3277 pass
3278 ui.write(minirst.format(''.join(rst), textwidth))
3278 return rst
3279 3279
3280 3280 def helpext(name):
3281 3281 try:
@@ -3291,10 +3291,10 b' def help_(ui, name=None, unknowncmd=Fals'
3291 3291 head, tail = doc, ""
3292 3292 else:
3293 3293 head, tail = doc.split('\n', 1)
3294 ui.write(_('%s extension - %s\n\n') % (name.split('.')[-1], head))
3294 rst = [_('%s extension - %s\n\n') % (name.split('.')[-1], head)]
3295 3295 if tail:
3296 ui.write(minirst.format(tail, textwidth))
3297 ui.status('\n')
3296 rst.extend(tail.splitlines(True))
3297 rst.append('\n')
3298 3298
3299 3299 if mod:
3300 3300 try:
@@ -3302,10 +3302,11 b' def help_(ui, name=None, unknowncmd=Fals'
3302 3302 except AttributeError:
3303 3303 ct = {}
3304 3304 modcmds = set([c.split('|', 1)[0] for c in ct])
3305 helplist(modcmds.__contains__)
3305 rst.extend(helplist(modcmds.__contains__))
3306 3306 else:
3307 ui.write(_('use "hg help extensions" for information on enabling '
3307 rst.append(_('use "hg help extensions" for information on enabling '
3308 3308 'extensions\n'))
3309 return rst
3309 3310
3310 3311 def helpextcmd(name):
3311 3312 cmd, ext, mod = extensions.disabledcmd(ui, name,
@@ -3317,8 +3318,10 b' def help_(ui, name=None, unknowncmd=Fals'
3317 3318 rst.append('\n')
3318 3319 rst.append(_('use "hg help extensions" for information on enabling '
3319 3320 'extensions\n'))
3320 ui.write(minirst.format(''.join(rst), textwidth))
3321
3321 return rst
3322
3323
3324 rst = []
3322 3325 kw = opts.get('keyword')
3323 3326 if kw:
3324 3327 matches = help.topicmatch(kw)
@@ -3327,12 +3330,9 b' def help_(ui, name=None, unknowncmd=Fals'
3327 3330 ('extensions', _('Extensions')),
3328 3331 ('extensioncommands', _('Extension Commands'))):
3329 3332 if matches[t]:
3330 ui.write('%s:\n\n' % title)
3331 rst = ''.join(minirst.maketable(matches[t], 1))
3332 ui.write(minirst.format(rst))
3333 return
3334
3335 if name and name != 'shortlist':
3333 rst.append('%s:\n\n' % title)
3334 rst.extend(minirst.maketable(matches[t], 1))
3335 elif name and name != 'shortlist':
3336 3336 i = None
3337 3337 if unknowncmd:
3338 3338 queries = (helpextcmd,)
@@ -3344,7 +3344,7 b' def help_(ui, name=None, unknowncmd=Fals'
3344 3344 queries = (helptopic, helpcmd, helpext, helpextcmd)
3345 3345 for f in queries:
3346 3346 try:
3347 f(name)
3347 rst = f(name)
3348 3348 i = None
3349 3349 break
3350 3350 except error.UnknownCommand, inst:
@@ -3353,9 +3353,13 b' def help_(ui, name=None, unknowncmd=Fals'
3353 3353 raise i
3354 3354 else:
3355 3355 # program name
3356 ui.status(_("Mercurial Distributed SCM\n"))
3357 ui.status('\n')
3358 helplist()
3356 if not ui.quiet:
3357 rst = [_("Mercurial Distributed SCM\n"), '\n']
3358 rst.extend(helplist())
3359
3360 keep = ui.verbose and ['verbose'] or []
3361 formatted, pruned = minirst.format(''.join(rst), textwidth, keep=keep)
3362 ui.write(formatted)
3359 3363
3360 3364
3361 3365 @command('identify|id',
@@ -6,7 +6,8 b' Create configuration'
6 6 help record (no record)
7 7
8 8 $ hg help record
9 record extension - commands to interactively select changes for commit/qrefresh
9 record extension - commands to interactively select changes for
10 commit/qrefresh
10 11
11 12 use "hg help extensions" for information on enabling extensions
12 13
General Comments 0
You need to be logged in to leave comments. Login now