comparison 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
comparison
equal deleted inserted replaced
27378:c709b515218e 27379:2278870bb997
204 loaddoc('scripting')), 204 loaddoc('scripting')),
205 (['internals'], _("Technical implementation topics"), 205 (['internals'], _("Technical implementation topics"),
206 internalshelp), 206 internalshelp),
207 ]) 207 ])
208 208
209 # Maps topics with sub-topics to a list of their sub-topics.
210 subtopics = {
211 'internals': internalstable,
212 }
213
209 # Map topics to lists of callable taking the current topic help and 214 # Map topics to lists of callable taking the current topic help and
210 # returning the updated version 215 # returning the updated version
211 helphooks = {} 216 helphooks = {}
212 217
213 def addtopichook(topic, rewriter): 218 def addtopichook(topic, rewriter):
431 'and global options)\n') 436 'and global options)\n')
432 % (name and " " + name or "")) 437 % (name and " " + name or ""))
433 return rst 438 return rst
434 439
435 def helptopic(name, subtopic=None): 440 def helptopic(name, subtopic=None):
436 for names, header, doc in helptable: 441 # Look for sub-topic entry first.
437 if name in names: 442 header, doc = None, None
438 break 443 if subtopic and name in subtopics:
439 else: 444 for names, header, doc in subtopics[name]:
440 raise error.UnknownCommand(name) 445 if subtopic in names:
446 break
447
448 if not header:
449 for names, header, doc in helptable:
450 if name in names:
451 break
452 else:
453 raise error.UnknownCommand(name)
441 454
442 rst = [minirst.section(header)] 455 rst = [minirst.section(header)]
443 456
444 # description 457 # description
445 if not doc: 458 if not doc: