##// 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 entry[0](ui)
3106 entry[0](ui)
3107 return
3107 return
3108
3108
3109 rst = ""
3109 rst = []
3110
3110
3111 # synopsis
3111 # synopsis
3112 if len(entry) > 2:
3112 if len(entry) > 2:
3113 if entry[2].startswith('hg'):
3113 if entry[2].startswith('hg'):
3114 rst += "%s\n" % entry[2]
3114 rst.append("%s\n" % entry[2])
3115 else:
3115 else:
3116 rst += 'hg %s %s\n' % (aliases[0], entry[2])
3116 rst.append('hg %s %s\n' % (aliases[0], entry[2]))
3117 else:
3117 else:
3118 rst += 'hg %s\n' % aliases[0]
3118 rst.append('hg %s\n' % aliases[0])
3119
3120 # aliases
3119 # aliases
3121 if full and not ui.quiet and len(aliases) > 1:
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 # description
3124 # description
3125 doc = gettext(entry[0].__doc__)
3125 doc = gettext(entry[0].__doc__)
@@ -3130,9 +3130,12 b' def help_(ui, name=None, unknowncmd=Fals'
3130 doc = _('shell alias for::\n\n %s') % entry[0].definition[1:]
3130 doc = _('shell alias for::\n\n %s') % entry[0].definition[1:]
3131 else:
3131 else:
3132 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
3132 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
3133 doc = doc.splitlines(True)
3133 if ui.quiet or not full:
3134 if ui.quiet or not full:
3134 doc = doc.splitlines()[0]
3135 rst.append(doc[0])
3135 rst += "\n" + doc + "\n"
3136 else:
3137 rst.extend(doc)
3138 rst.append('\n')
3136
3139
3137 # check if this command shadows a non-trivial (multi-line)
3140 # check if this command shadows a non-trivial (multi-line)
3138 # extension help text
3141 # extension help text
@@ -3142,33 +3145,30 b' def help_(ui, name=None, unknowncmd=Fals'
3142 if '\n' in doc.strip():
3145 if '\n' in doc.strip():
3143 msg = _('use "hg help -e %s" to show help for '
3146 msg = _('use "hg help -e %s" to show help for '
3144 'the %s extension') % (name, name)
3147 'the %s extension') % (name, name)
3145 rst += '\n%s\n' % msg
3148 rst.append('\n%s\n' % msg)
3146 except KeyError:
3149 except KeyError:
3147 pass
3150 pass
3148
3151
3149 # options
3152 # options
3150 if not ui.quiet and entry[1]:
3153 if not ui.quiet and entry[1]:
3151 rst += '\n'
3154 rst.append('\n%s\n\n' % _("options:"))
3152 rst += _("options:")
3155 rst.append(help.optrst(entry[1], ui.verbose))
3153 rst += '\n\n'
3154 rst += help.optrst(entry[1], ui.verbose)
3155
3156
3156 if ui.verbose:
3157 if ui.verbose:
3157 rst += '\n'
3158 rst.append('\n%s\n\n' % _("global options:"))
3158 rst += _("global options:")
3159 rst.append(help.optrst(globalopts, ui.verbose))
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)
3165
3160
3166 if not ui.verbose:
3161 if not ui.verbose:
3167 if not full:
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 % name)
3164 % name)
3170 elif not ui.quiet:
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 def helplist(select=None):
3174 def helplist(select=None):
General Comments 0
You need to be logged in to leave comments. Login now