Mercurial > public > mercurial-scm > hg-stable
diff mercurial/help.py @ 13593:cc4721ed7a2a
help: extract items doc generation function
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sat, 12 Mar 2011 12:46:31 +0100 |
parents | af1006d2f970 |
children | 9e5407a67dea |
line wrap: on
line diff
--- a/mercurial/help.py Sat Mar 12 12:46:31 2011 +0100 +++ b/mercurial/help.py Sat Mar 12 12:46:31 2011 +0100 @@ -115,3 +115,19 @@ def addtopichook(topic, rewriter): helphooks.setdefault(topic, []).append(rewriter) + +def makeitemsdoc(topic, doc, marker, items): + """Extract docstring from the items key to function mapping, build a + .single documentation block and use it to overwrite the marker in doc + """ + entries = [] + for name in sorted(items): + text = (items[name].__doc__ or '').rstrip() + if not text: + continue + text = gettext(text) + lines = text.splitlines() + lines[1:] = [(' ' + l.strip()) for l in lines[1:]] + entries.append('\n'.join(lines)) + entries = '\n\n'.join(entries) + return doc.replace(marker, entries)