Mercurial > hg-stable
changeset 27377:d1c998d7b103
help: pass subtopic into help()
Now that we have multiple directories where help topics can live,
we need a mechanism to access them. We already use "." to
separate topic from section. So it seems logical to also use "." to
denote the sub-directory of a topic.
This patch teaches the help command to parse out the possible
sub-topic and pass it to the help system.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 13 Dec 2015 11:04:45 -0800 |
parents | fc810d950278 |
children | c709b515218e |
files | mercurial/commands.py mercurial/help.py |
diffstat | 2 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Sun Dec 13 10:35:03 2015 -0800 +++ b/mercurial/commands.py Sun Dec 13 11:04:45 2015 -0800 @@ -4367,11 +4367,16 @@ keep.append(sys.platform.lower()) section = None + subtopic = None if name and '.' in name: name, section = name.split('.', 1) section = section.lower() - - text = help.help_(ui, name, **opts) + if '.' in section: + subtopic, section = section.split('.', 1) + else: + subtopic = section + + text = help.help_(ui, name, subtopic=subtopic, **opts) formatted, pruned = minirst.format(text, textwidth, keep=keep, section=section)
--- a/mercurial/help.py Sun Dec 13 10:35:03 2015 -0800 +++ b/mercurial/help.py Sun Dec 13 11:04:45 2015 -0800 @@ -255,7 +255,7 @@ addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands, dedent=True) -def help_(ui, name, unknowncmd=False, full=True, **opts): +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.