Show More
@@ -1483,18 +1483,10 b' def help_(ui, name=None, with_version=Fa' | |||||
1483 | else: |
|
1483 | else: | |
1484 | ui.write(' %-*s %s\n' % (m, f, h[f])) |
|
1484 | ui.write(' %-*s %s\n' % (m, f, h[f])) | |
1485 |
|
1485 | |||
1486 | exts = list(extensions.extensions()) |
|
1486 | if name != 'shortlist': | |
1487 | if exts and name != 'shortlist': |
|
1487 | exts, maxlength = help.enabledextensions() | |
1488 |
ui.write(_(' |
|
1488 | ui.write(help.extensionslisting(_('enabled extensions:'), | |
1489 | maxlength = 0 |
|
1489 | exts, maxlength)) | |
1490 | exthelps = [] |
|
|||
1491 | for ename, ext in exts: |
|
|||
1492 | doc = (gettext(ext.__doc__) or _('(no help text available)')) |
|
|||
1493 | ename = ename.split('.')[-1] |
|
|||
1494 | maxlength = max(len(ename), maxlength) |
|
|||
1495 | exthelps.append((ename, doc.splitlines(0)[0].strip())) |
|
|||
1496 | for ename, text in exthelps: |
|
|||
1497 | ui.write(_(' %s %s\n') % (ename.ljust(maxlength), text)) |
|
|||
1498 |
|
1490 | |||
1499 | if not ui.quiet: |
|
1491 | if not ui.quiet: | |
1500 | addglobalopts(True) |
|
1492 | addglobalopts(True) |
@@ -98,6 +98,33 b' def additionalextensions():' | |||||
98 |
|
98 | |||
99 | return exts, maxlength |
|
99 | return exts, maxlength | |
100 |
|
100 | |||
|
101 | def enabledextensions(): | |||
|
102 | '''Return the list of enabled extensions, and max name length''' | |||
|
103 | enabled = list(extensions.extensions()) | |||
|
104 | exts = {} | |||
|
105 | maxlength = 0 | |||
|
106 | ||||
|
107 | if enabled: | |||
|
108 | exthelps = [] | |||
|
109 | for ename, ext in enabled: | |||
|
110 | doc = (gettext(ext.__doc__) or _('(no help text available)')) | |||
|
111 | ename = ename.split('.')[-1] | |||
|
112 | maxlength = max(len(ename), maxlength) | |||
|
113 | exts[ename] = doc.splitlines(0)[0].strip() | |||
|
114 | ||||
|
115 | return exts, maxlength | |||
|
116 | ||||
|
117 | def extensionslisting(header, exts, maxlength): | |||
|
118 | '''Return a text listing of the given extensions''' | |||
|
119 | result = '' | |||
|
120 | ||||
|
121 | if exts: | |||
|
122 | result += '\n%s\n\n' % header | |||
|
123 | for name, desc in sorted(exts.iteritems()): | |||
|
124 | result += ' %s %s\n' % (name.ljust(maxlength), desc) | |||
|
125 | ||||
|
126 | return result | |||
|
127 | ||||
101 | def topicextensions(): |
|
128 | def topicextensions(): | |
102 | doc = _(r''' |
|
129 | doc = _(r''' | |
103 | Mercurial has an extension mechanism for adding new features. |
|
130 | Mercurial has an extension mechanism for adding new features. | |
@@ -109,11 +136,11 b' def topicextensions():' | |||||
109 | foo = |
|
136 | foo = | |
110 | ''') |
|
137 | ''') | |
111 |
|
138 | |||
|
139 | exts, maxlength = enabledextensions() | |||
|
140 | doc += extensionslisting(_('enabled extensions:'), exts, maxlength) | |||
|
141 | ||||
112 | exts, maxlength = additionalextensions() |
|
142 | exts, maxlength = additionalextensions() | |
113 | if exts: |
|
143 | doc += extensionslisting(_('non-enabled extensions:'), exts, maxlength) | |
114 | doc += _('\nnon-enabled extensions:\n\n') |
|
|||
115 | for name, desc in sorted(exts.iteritems()): |
|
|||
116 | doc += ' %s %s\n' % (name.ljust(maxlength), desc) |
|
|||
117 |
|
144 | |||
118 | return doc |
|
145 | return doc | |
119 |
|
146 |
General Comments 0
You need to be logged in to leave comments.
Login now