Mercurial > hg
diff mercurial/help.py @ 27379:2278870bb997
help: support loading sub-topics
If a sub-topic/section is requested and the main topic corresponds to
a topic with sub-topics, we now look for and return content for a
sub-topic if found.
With this patch, `hg help internals.X` now works. hgweb does not yet
render sub-topics, however.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 13 Dec 2015 11:19:55 -0800 |
parents | c709b515218e |
children | dfab0afde928 |
line wrap: on
line diff
--- a/mercurial/help.py Sun Dec 13 11:29:01 2015 -0800 +++ b/mercurial/help.py Sun Dec 13 11:19:55 2015 -0800 @@ -206,6 +206,11 @@ internalshelp), ]) +# Maps topics with sub-topics to a list of their sub-topics. +subtopics = { + 'internals': internalstable, +} + # Map topics to lists of callable taking the current topic help and # returning the updated version helphooks = {} @@ -433,11 +438,19 @@ return rst def helptopic(name, subtopic=None): - for names, header, doc in helptable: - if name in names: - break - else: - raise error.UnknownCommand(name) + # Look for sub-topic entry first. + header, doc = None, None + if subtopic and name in subtopics: + for names, header, doc in subtopics[name]: + if subtopic in names: + break + + if not header: + for names, header, doc in helptable: + if name in names: + break + else: + raise error.UnknownCommand(name) rst = [minirst.section(header)]