Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/webcommands.py @ 38224:0b932b43868f
hgweb: wrap {topics}es of help with mappinggenerator or mappinglist
The former 'topics' was a generator function, and the latter was a list of
mappings.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 04 Apr 2018 20:51:49 +0900 |
parents | 86f980a8cacf |
children | c3df415037cd |
comparison
equal
deleted
inserted
replaced
38223:86f980a8cacf | 38224:0b932b43868f |
---|---|
1396 """ | 1396 """ |
1397 from .. import commands, help as helpmod # avoid cycle | 1397 from .. import commands, help as helpmod # avoid cycle |
1398 | 1398 |
1399 topicname = web.req.qsparams.get('node') | 1399 topicname = web.req.qsparams.get('node') |
1400 if not topicname: | 1400 if not topicname: |
1401 def topics(**map): | 1401 def topics(context): |
1402 for entries, summary, _doc in helpmod.helptable: | 1402 for entries, summary, _doc in helpmod.helptable: |
1403 yield {'topic': entries[0], 'summary': summary} | 1403 yield {'topic': entries[0], 'summary': summary} |
1404 | 1404 |
1405 early, other = [], [] | 1405 early, other = [], [] |
1406 primary = lambda s: s.partition('|')[0] | 1406 primary = lambda s: s.partition('|')[0] |
1425 for c, doc in other: | 1425 for c, doc in other: |
1426 yield {'topic': c, 'summary': doc} | 1426 yield {'topic': c, 'summary': doc} |
1427 | 1427 |
1428 return web.sendtemplate( | 1428 return web.sendtemplate( |
1429 'helptopics', | 1429 'helptopics', |
1430 topics=topics, | 1430 topics=templateutil.mappinggenerator(topics), |
1431 earlycommands=earlycommands, | 1431 earlycommands=earlycommands, |
1432 othercommands=othercommands, | 1432 othercommands=othercommands, |
1433 title='Index') | 1433 title='Index') |
1434 | 1434 |
1435 # Render an index of sub-topics. | 1435 # Render an index of sub-topics. |
1442 'summary': summary, | 1442 'summary': summary, |
1443 }) | 1443 }) |
1444 | 1444 |
1445 return web.sendtemplate( | 1445 return web.sendtemplate( |
1446 'helptopics', | 1446 'helptopics', |
1447 topics=topics, | 1447 topics=templateutil.mappinglist(topics), |
1448 title=topicname, | 1448 title=topicname, |
1449 subindex=True) | 1449 subindex=True) |
1450 | 1450 |
1451 u = webutil.wsgiui.load() | 1451 u = webutil.wsgiui.load() |
1452 u.verbose = True | 1452 u.verbose = True |