[PATCH 7 of 8 techdocs] help: pass sub-topic into help query functions
Gregory Szorc
gregory.szorc at gmail.com
Sun Dec 13 13:47:00 CST 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1450034941 28800
# Sun Dec 13 11:29:01 2015 -0800
# Node ID a1dac17af8e8022feb2125f1bf501309fbbf2805
# Parent 14773a1a68286d051a09979467bacd3b40d41114
help: pass sub-topic into help query functions
While we will likely only use this variable in helptopic(), all these
functions are called with the same arguments, so we have to be
consistent.
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -258,17 +258,17 @@ addtopicsymbols('hgweb', '.. webcommands
def help_(ui, name, unknowncmd=False, full=True, subtopic=None, **opts):
'''
Generate the help for 'name' as unformatted restructured text. If
'name' is None, describe the commands available.
'''
import commands # avoid cycle
- def helpcmd(name):
+ def helpcmd(name, subtopic=None):
try:
aliases, entry = cmdutil.findcmd(name, commands.table,
strict=unknowncmd)
except error.AmbiguousCommand as inst:
# py3k fix: except vars can't be used outside the scope of the
# except block, nor can be used inside a lambda. python issue4617
prefix = inst.args[0]
select = lambda c: c.lstrip('^').startswith(prefix)
@@ -427,17 +427,17 @@ def help_(ui, name, unknowncmd=False, fu
rst.append(_('\n(use "hg help -v -e %s" to show built-in '
'aliases and global options)\n') % name)
else:
rst.append(_('\n(use "hg help -v%s" to show built-in aliases '
'and global options)\n')
% (name and " " + name or ""))
return rst
- def helptopic(name):
+ def helptopic(name, subtopic=None):
for names, header, doc in helptable:
if name in names:
break
else:
raise error.UnknownCommand(name)
rst = [minirst.section(header)]
@@ -455,17 +455,17 @@ def help_(ui, name, unknowncmd=False, fu
try:
cmdutil.findcmd(name, commands.table)
rst.append(_('\nuse "hg help -c %s" to see help for '
'the %s command\n') % (name, name))
except error.UnknownCommand:
pass
return rst
- def helpext(name):
+ def helpext(name, subtopic=None):
try:
mod = extensions.find(name)
doc = gettext(mod.__doc__) or _('no help text available')
except KeyError:
mod = None
doc = extensions.disabledext(name)
if not doc:
raise error.UnknownCommand(name)
@@ -491,17 +491,17 @@ def help_(ui, name, unknowncmd=False, fu
ct = {}
modcmds = set([c.partition('|')[0] for c in ct])
rst.extend(helplist(modcmds.__contains__))
else:
rst.append(_('(use "hg help extensions" for information on enabling'
' extensions)\n'))
return rst
- def helpextcmd(name):
+ def helpextcmd(name, subtopic=None):
cmd, ext, mod = extensions.disabledcmd(ui, name,
ui.configbool('ui', 'strict'))
doc = gettext(mod.__doc__).splitlines()[0]
rst = listexts(_("'%s' is provided by the following "
"extension:") % cmd, {ext: doc}, indent=4,
showdeprecated=True)
rst.append('\n')
@@ -540,17 +540,17 @@ def help_(ui, name, unknowncmd=False, fu
if opts.get('extension'):
queries += [helpext]
if opts.get('command'):
queries += [helpcmd]
if not queries:
queries = (helptopic, helpcmd, helpext, helpextcmd)
for f in queries:
try:
- rst = f(name)
+ rst = f(name, subtopic)
break
except error.UnknownCommand:
pass
else:
if unknowncmd:
raise error.UnknownCommand(name)
else:
msg = _('no such help topic: %s') % name
More information about the Mercurial-devel
mailing list