Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
13592:ad2ee188f4a5 | 13593:cc4721ed7a2a |
---|---|
113 helphooks = { | 113 helphooks = { |
114 } | 114 } |
115 | 115 |
116 def addtopichook(topic, rewriter): | 116 def addtopichook(topic, rewriter): |
117 helphooks.setdefault(topic, []).append(rewriter) | 117 helphooks.setdefault(topic, []).append(rewriter) |
118 | |
119 def makeitemsdoc(topic, doc, marker, items): | |
120 """Extract docstring from the items key to function mapping, build a | |
121 .single documentation block and use it to overwrite the marker in doc | |
122 """ | |
123 entries = [] | |
124 for name in sorted(items): | |
125 text = (items[name].__doc__ or '').rstrip() | |
126 if not text: | |
127 continue | |
128 text = gettext(text) | |
129 lines = text.splitlines() | |
130 lines[1:] = [(' ' + l.strip()) for l in lines[1:]] | |
131 entries.append('\n'.join(lines)) | |
132 entries = '\n\n'.join(entries) | |
133 return doc.replace(marker, entries) |