Show More
@@ -3089,56 +3089,6 b' def help_(ui, name=None, unknowncmd=Fals' | |||||
3089 |
|
3089 | |||
3090 | textwidth = min(ui.termwidth(), 80) - 2 |
|
3090 | textwidth = min(ui.termwidth(), 80) - 2 | |
3091 |
|
3091 | |||
3092 | def optrst(options, verbose): |
|
|||
3093 | data = [] |
|
|||
3094 | multioccur = False |
|
|||
3095 | for option in options: |
|
|||
3096 | if len(option) == 5: |
|
|||
3097 | shortopt, longopt, default, desc, optlabel = option |
|
|||
3098 | else: |
|
|||
3099 | shortopt, longopt, default, desc = option |
|
|||
3100 | optlabel = _("VALUE") # default label |
|
|||
3101 |
|
||||
3102 | if _("DEPRECATED") in desc and not verbose: |
|
|||
3103 | continue |
|
|||
3104 |
|
||||
3105 | so = '' |
|
|||
3106 | if shortopt: |
|
|||
3107 | so = '-' + shortopt |
|
|||
3108 | lo = '--' + longopt |
|
|||
3109 | if default: |
|
|||
3110 | desc += _(" (default: %s)") % default |
|
|||
3111 |
|
||||
3112 | if isinstance(default, list): |
|
|||
3113 | lo += " %s [+]" % optlabel |
|
|||
3114 | multioccur = True |
|
|||
3115 | elif (default is not None) and not isinstance(default, bool): |
|
|||
3116 | lo += " %s" % optlabel |
|
|||
3117 |
|
||||
3118 | data.append((so, lo, desc)) |
|
|||
3119 |
|
||||
3120 | rst = minirst.maketable(data, 1) |
|
|||
3121 |
|
||||
3122 | if multioccur: |
|
|||
3123 | rst += _("\n[+] marked option can be specified multiple times\n") |
|
|||
3124 |
|
||||
3125 | return rst |
|
|||
3126 |
|
||||
3127 | # list all option lists |
|
|||
3128 | def opttext(optlist, width, verbose): |
|
|||
3129 | rst = '' |
|
|||
3130 | if not optlist: |
|
|||
3131 | return '' |
|
|||
3132 |
|
||||
3133 | for title, options in optlist: |
|
|||
3134 | rst += '\n%s\n' % title |
|
|||
3135 | if options: |
|
|||
3136 | rst += "\n" |
|
|||
3137 | rst += optrst(options, verbose) |
|
|||
3138 | rst += '\n' |
|
|||
3139 |
|
||||
3140 | return '\n' + minirst.format(rst, width) |
|
|||
3141 |
|
||||
3142 | def addglobalopts(optlist, aliases): |
|
3092 | def addglobalopts(optlist, aliases): | |
3143 | if ui.quiet: |
|
3093 | if ui.quiet: | |
3144 | return [] |
|
3094 | return [] | |
@@ -3223,13 +3173,13 b' def help_(ui, name=None, unknowncmd=Fals' | |||||
3223 | rst += '\n' |
|
3173 | rst += '\n' | |
3224 | rst += _("options:") |
|
3174 | rst += _("options:") | |
3225 | rst += '\n\n' |
|
3175 | rst += '\n\n' | |
3226 | rst += optrst(entry[1], ui.verbose) |
|
3176 | rst += help.optrst(entry[1], ui.verbose) | |
3227 |
|
3177 | |||
3228 | if ui.verbose: |
|
3178 | if ui.verbose: | |
3229 | rst += '\n' |
|
3179 | rst += '\n' | |
3230 | rst += _("global options:") |
|
3180 | rst += _("global options:") | |
3231 | rst += '\n\n' |
|
3181 | rst += '\n\n' | |
3232 | rst += optrst(globalopts, ui.verbose) |
|
3182 | rst += help.optrst(globalopts, ui.verbose) | |
3233 |
|
3183 | |||
3234 | keep = ui.verbose and ['verbose'] or [] |
|
3184 | keep = ui.verbose and ['verbose'] or [] | |
3235 | formatted, pruned = minirst.format(rst, textwidth, keep=keep) |
|
3185 | formatted, pruned = minirst.format(rst, textwidth, keep=keep) | |
@@ -3304,7 +3254,7 b' def help_(ui, name=None, unknowncmd=Fals' | |||||
3304 |
|
3254 | |||
3305 | optlist = [] |
|
3255 | optlist = [] | |
3306 | addglobalopts(optlist, True) |
|
3256 | addglobalopts(optlist, True) | |
3307 | ui.write(opttext(optlist, textwidth, ui.verbose)) |
|
3257 | ui.write(help.opttext(optlist, textwidth, ui.verbose)) | |
3308 |
|
3258 | |||
3309 | def helptopic(name): |
|
3259 | def helptopic(name): | |
3310 | for names, header, doc in help.helptable: |
|
3260 | for names, header, doc in help.helptable: |
@@ -8,7 +8,7 b'' | |||||
8 | from i18n import gettext, _ |
|
8 | from i18n import gettext, _ | |
9 | import itertools, sys, os |
|
9 | import itertools, sys, os | |
10 | import extensions, revset, fileset, templatekw, templatefilters, filemerge |
|
10 | import extensions, revset, fileset, templatekw, templatefilters, filemerge | |
11 | import encoding, util |
|
11 | import encoding, util, minirst | |
12 |
|
12 | |||
13 | def listexts(header, exts, indent=1): |
|
13 | def listexts(header, exts, indent=1): | |
14 | '''return a text listing of the given extensions''' |
|
14 | '''return a text listing of the given extensions''' | |
@@ -27,6 +27,56 b' def extshelp():' | |||||
27 | doc += listexts(_('disabled extensions:'), extensions.disabled()) |
|
27 | doc += listexts(_('disabled extensions:'), extensions.disabled()) | |
28 | return doc |
|
28 | return doc | |
29 |
|
29 | |||
|
30 | def optrst(options, verbose): | |||
|
31 | data = [] | |||
|
32 | multioccur = False | |||
|
33 | for option in options: | |||
|
34 | if len(option) == 5: | |||
|
35 | shortopt, longopt, default, desc, optlabel = option | |||
|
36 | else: | |||
|
37 | shortopt, longopt, default, desc = option | |||
|
38 | optlabel = _("VALUE") # default label | |||
|
39 | ||||
|
40 | if _("DEPRECATED") in desc and not verbose: | |||
|
41 | continue | |||
|
42 | ||||
|
43 | so = '' | |||
|
44 | if shortopt: | |||
|
45 | so = '-' + shortopt | |||
|
46 | lo = '--' + longopt | |||
|
47 | if default: | |||
|
48 | desc += _(" (default: %s)") % default | |||
|
49 | ||||
|
50 | if isinstance(default, list): | |||
|
51 | lo += " %s [+]" % optlabel | |||
|
52 | multioccur = True | |||
|
53 | elif (default is not None) and not isinstance(default, bool): | |||
|
54 | lo += " %s" % optlabel | |||
|
55 | ||||
|
56 | data.append((so, lo, desc)) | |||
|
57 | ||||
|
58 | rst = minirst.maketable(data, 1) | |||
|
59 | ||||
|
60 | if multioccur: | |||
|
61 | rst += _("\n[+] marked option can be specified multiple times\n") | |||
|
62 | ||||
|
63 | return rst | |||
|
64 | ||||
|
65 | # list all option lists | |||
|
66 | def opttext(optlist, width, verbose): | |||
|
67 | rst = '' | |||
|
68 | if not optlist: | |||
|
69 | return '' | |||
|
70 | ||||
|
71 | for title, options in optlist: | |||
|
72 | rst += '\n%s\n' % title | |||
|
73 | if options: | |||
|
74 | rst += "\n" | |||
|
75 | rst += optrst(options, verbose) | |||
|
76 | rst += '\n' | |||
|
77 | ||||
|
78 | return '\n' + minirst.format(rst, width) | |||
|
79 | ||||
30 | def topicmatch(kw): |
|
80 | def topicmatch(kw): | |
31 | """Return help topics matching kw. |
|
81 | """Return help topics matching kw. | |
32 |
|
82 |
General Comments 0
You need to be logged in to leave comments.
Login now