Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/webcommands.py @ 27582:8f8f3b13252d
hgweb: support rendering a sub-topic
If the requested topic contains a "." we assume a sub-topic is
requested and display it.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 30 Dec 2015 17:15:10 -0700 |
parents | 3aa6a8135557 |
children | 964ad57eff30 |
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py Wed Dec 30 17:34:51 2015 -0700 +++ b/mercurial/hgweb/webcommands.py Wed Dec 30 17:15:10 2015 -0700 @@ -1271,8 +1271,20 @@ u = webutil.wsgiui() u.verbose = True + + # Render a page from a sub-topic. + if '.' in topicname: + # TODO implement support for rendering sections, like + # `hg help` works. + topic, subtopic = topicname.split('.', 1) + if topic not in helpmod.subtopics: + raise ErrorResponse(HTTP_NOT_FOUND) + else: + topic = topicname + subtopic = None + try: - doc = helpmod.help_(u, topicname) + doc = helpmod.help_(u, topic, subtopic=subtopic) except error.UnknownCommand: raise ErrorResponse(HTTP_NOT_FOUND) return tmpl('help', topic=topicname, doc=doc)