Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
27581:3aa6a8135557 | 27582:8f8f3b13252d |
---|---|
1269 return tmpl('helptopics', topics=topics, title=topicname, | 1269 return tmpl('helptopics', topics=topics, title=topicname, |
1270 subindex=True) | 1270 subindex=True) |
1271 | 1271 |
1272 u = webutil.wsgiui() | 1272 u = webutil.wsgiui() |
1273 u.verbose = True | 1273 u.verbose = True |
1274 | |
1275 # Render a page from a sub-topic. | |
1276 if '.' in topicname: | |
1277 # TODO implement support for rendering sections, like | |
1278 # `hg help` works. | |
1279 topic, subtopic = topicname.split('.', 1) | |
1280 if topic not in helpmod.subtopics: | |
1281 raise ErrorResponse(HTTP_NOT_FOUND) | |
1282 else: | |
1283 topic = topicname | |
1284 subtopic = None | |
1285 | |
1274 try: | 1286 try: |
1275 doc = helpmod.help_(u, topicname) | 1287 doc = helpmod.help_(u, topic, subtopic=subtopic) |
1276 except error.UnknownCommand: | 1288 except error.UnknownCommand: |
1277 raise ErrorResponse(HTTP_NOT_FOUND) | 1289 raise ErrorResponse(HTTP_NOT_FOUND) |
1278 return tmpl('help', topic=topicname, doc=doc) | 1290 return tmpl('help', topic=topicname, doc=doc) |
1279 | 1291 |
1280 # tell hggettext to extract docstrings from these functions: | 1292 # tell hggettext to extract docstrings from these functions: |