##// END OF EJS Templates
help: format command help using RST
Olav Reinert -
r16818:d0fc1e68 default
parent child Browse files
Show More
@@ -3106,20 +3106,20 b' def help_(ui, name=None, unknowncmd=Fals'
3106 3106 entry[0](ui)
3107 3107 return
3108 3108
3109 rst = ""
3109 rst = []
3110 3110
3111 3111 # synopsis
3112 3112 if len(entry) > 2:
3113 3113 if entry[2].startswith('hg'):
3114 rst += "%s\n" % entry[2]
3114 rst.append("%s\n" % entry[2])
3115 3115 else:
3116 rst += 'hg %s %s\n' % (aliases[0], entry[2])
3116 rst.append('hg %s %s\n' % (aliases[0], entry[2]))
3117 3117 else:
3118 rst += 'hg %s\n' % aliases[0]
3119
3118 rst.append('hg %s\n' % aliases[0])
3120 3119 # aliases
3121 3120 if full and not ui.quiet and len(aliases) > 1:
3122 rst += _("\naliases: %s\n") % ', '.join(aliases[1:])
3121 rst.append(_("\naliases: %s\n") % ', '.join(aliases[1:]))
3122 rst.append('\n')
3123 3123
3124 3124 # description
3125 3125 doc = gettext(entry[0].__doc__)
@@ -3130,9 +3130,12 b' def help_(ui, name=None, unknowncmd=Fals'
3130 3130 doc = _('shell alias for::\n\n %s') % entry[0].definition[1:]
3131 3131 else:
3132 3132 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
3133 doc = doc.splitlines(True)
3133 3134 if ui.quiet or not full:
3134 doc = doc.splitlines()[0]
3135 rst += "\n" + doc + "\n"
3135 rst.append(doc[0])
3136 else:
3137 rst.extend(doc)
3138 rst.append('\n')
3136 3139
3137 3140 # check if this command shadows a non-trivial (multi-line)
3138 3141 # extension help text
@@ -3142,33 +3145,30 b' def help_(ui, name=None, unknowncmd=Fals'
3142 3145 if '\n' in doc.strip():
3143 3146 msg = _('use "hg help -e %s" to show help for '
3144 3147 'the %s extension') % (name, name)
3145 rst += '\n%s\n' % msg
3148 rst.append('\n%s\n' % msg)
3146 3149 except KeyError:
3147 3150 pass
3148 3151
3149 3152 # options
3150 3153 if not ui.quiet and entry[1]:
3151 rst += '\n'
3152 rst += _("options:")
3153 rst += '\n\n'
3154 rst += help.optrst(entry[1], ui.verbose)
3154 rst.append('\n%s\n\n' % _("options:"))
3155 rst.append(help.optrst(entry[1], ui.verbose))
3155 3156
3156 3157 if ui.verbose:
3157 rst += '\n'
3158 rst += _("global options:")
3159 rst += '\n\n'
3160 rst += help.optrst(globalopts, ui.verbose)
3161
3162 keep = ui.verbose and ['verbose'] or []
3163 formatted, pruned = minirst.format(rst, textwidth, keep=keep)
3164 ui.write(formatted)
3158 rst.append('\n%s\n\n' % _("global options:"))
3159 rst.append(help.optrst(globalopts, ui.verbose))
3165 3160
3166 3161 if not ui.verbose:
3167 3162 if not full:
3168 ui.write(_('\nuse "hg help %s" to show the full help text\n')
3163 rst.append(_('\nuse "hg help %s" to show the full help text\n')
3169 3164 % name)
3170 3165 elif not ui.quiet:
3171 ui.write(_('\nuse "hg -v help %s" to show more info\n') % name)
3166 rst.append(_('\nuse "hg -v help %s" to show more info\n')
3167 % name)
3168
3169 keep = ui.verbose and ['verbose'] or []
3170 formatted, pruned = minirst.format(''.join(rst), textwidth, keep=keep)
3171 ui.write(formatted)
3172 3172
3173 3173
3174 3174 def helplist(select=None):
General Comments 0
You need to be logged in to leave comments. Login now