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