##// END OF EJS Templates
help: pass commands module by argument...
Yuya Nishihara -
r32567:1b90036f default
parent child Browse files
Show More
@@ -11,6 +11,7 b' import difflib'
11 11 import errno
12 12 import os
13 13 import re
14 import sys
14 15
15 16 from .i18n import _
16 17 from .node import (
@@ -2745,7 +2746,8 b' def help_(ui, name=None, **opts):'
2745 2746 if ui.verbose:
2746 2747 keep.append('verbose')
2747 2748
2748 formatted = help.formattedhelp(ui, name, keep=keep, **opts)
2749 commands = sys.modules[__name__]
2750 formatted = help.formattedhelp(ui, commands, name, keep=keep, **opts)
2749 2751 ui.pager('help')
2750 2752 ui.write(formatted)
2751 2753
@@ -333,7 +333,8 b' def _callcatch(ui, func):'
333 333 try:
334 334 # check if the command is in a disabled extension
335 335 # (but don't check for extensions themselves)
336 formatted = help.formattedhelp(ui, inst.args[0], unknowncmd=True)
336 formatted = help.formattedhelp(ui, commands, inst.args[0],
337 unknowncmd=True)
337 338 ui.warn(nocmdmsg)
338 339 ui.write(formatted)
339 340 except (error.UnknownCommand, error.Abort):
@@ -114,7 +114,7 b' def filtercmd(ui, cmd, kw, doc):'
114 114 return True
115 115 return False
116 116
117 def topicmatch(ui, kw):
117 def topicmatch(ui, commands, kw):
118 118 """Return help topics matching kw.
119 119
120 120 Returns {'section': [(name, summary), ...], ...} where section is
@@ -134,7 +134,6 b' def topicmatch(ui, kw):'
134 134 or lowercontains(header)
135 135 or (callable(doc) and lowercontains(doc(ui)))):
136 136 results['topics'].append((names[0], header))
137 from . import commands # avoid cycle
138 137 for cmd, entry in commands.table.iteritems():
139 138 if len(entry) == 3:
140 139 summary = entry[2]
@@ -299,13 +298,13 b" addtopicsymbols('templates', '.. functio"
299 298 addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands,
300 299 dedent=True)
301 300
302 def help_(ui, name, unknowncmd=False, full=True, subtopic=None, **opts):
301 def help_(ui, commands, name, unknowncmd=False, full=True, subtopic=None,
302 **opts):
303 303 '''
304 304 Generate the help for 'name' as unformatted restructured text. If
305 305 'name' is None, describe the commands available.
306 306 '''
307 307
308 from . import commands # avoid cycle
309 308 opts = pycompat.byteskwargs(opts)
310 309
311 310 def helpcmd(name, subtopic=None):
@@ -569,7 +568,7 b' def help_(ui, name, unknowncmd=False, fu'
569 568 rst = []
570 569 kw = opts.get('keyword')
571 570 if kw or name is None and any(opts[o] for o in opts):
572 matches = topicmatch(ui, name or '')
571 matches = topicmatch(ui, commands, name or '')
573 572 helpareas = []
574 573 if opts.get('extension'):
575 574 helpareas += [('extensions', _('Extensions'))]
@@ -620,7 +619,8 b' def help_(ui, name, unknowncmd=False, fu'
620 619
621 620 return ''.join(rst)
622 621
623 def formattedhelp(ui, name, keep=None, unknowncmd=False, full=True, **opts):
622 def formattedhelp(ui, commands, name, keep=None, unknowncmd=False, full=True,
623 **opts):
624 624 """get help for a given topic (as a dotted name) as rendered rst
625 625
626 626 Either returns the rendered help text or raises an exception.
@@ -646,7 +646,7 b' def formattedhelp(ui, name, keep=None, u'
646 646 termwidth = ui.termwidth() - 2
647 647 if textwidth <= 0 or termwidth < textwidth:
648 648 textwidth = termwidth
649 text = help_(ui, name,
649 text = help_(ui, commands, name,
650 650 subtopic=subtopic, unknowncmd=unknowncmd, full=full, **opts)
651 651
652 652 formatted, pruned = minirst.format(text, textwidth, keep=keep,
@@ -1374,7 +1374,7 b' def help(web, req, tmpl):'
1374 1374 subtopic = None
1375 1375
1376 1376 try:
1377 doc = helpmod.help_(u, topic, subtopic=subtopic)
1377 doc = helpmod.help_(u, commands, topic, subtopic=subtopic)
1378 1378 except error.UnknownCommand:
1379 1379 raise ErrorResponse(HTTP_NOT_FOUND)
1380 1380 return tmpl('help', topic=topicname, doc=doc)
General Comments 0
You need to be logged in to leave comments. Login now