Show More
@@ -6,7 +6,7 b'' | |||
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from i18n import gettext, _ |
|
9 | import itertools, os | |
|
9 | import itertools, os, textwrap | |
|
10 | 10 | import error |
|
11 | 11 | import extensions, revset, fileset, templatekw, templatefilters, filemerge |
|
12 | 12 | import encoding, util, minirst |
@@ -172,7 +172,7 b' helphooks = {}' | |||
|
172 | 172 | def addtopichook(topic, rewriter): |
|
173 | 173 | helphooks.setdefault(topic, []).append(rewriter) |
|
174 | 174 | |
|
175 | def makeitemsdoc(topic, doc, marker, items): | |
|
175 | def makeitemsdoc(topic, doc, marker, items, dedent=False): | |
|
176 | 176 | """Extract docstring from the items key to function mapping, build a |
|
177 | 177 | .single documentation block and use it to overwrite the marker in doc |
|
178 | 178 | """ |
@@ -182,20 +182,25 b' def makeitemsdoc(topic, doc, marker, ite' | |||
|
182 | 182 | if not text: |
|
183 | 183 | continue |
|
184 | 184 | text = gettext(text) |
|
185 | if dedent: | |
|
186 | text = textwrap.dedent(text) | |
|
185 | 187 | lines = text.splitlines() |
|
186 | 188 | doclines = [(lines[0])] |
|
187 | 189 | for l in lines[1:]: |
|
188 | 190 | # Stop once we find some Python doctest |
|
189 | 191 | if l.strip().startswith('>>>'): |
|
190 | 192 | break |
|
191 | doclines.append(' ' + l.strip()) | |
|
193 | if dedent: | |
|
194 | doclines.append(l.rstrip()) | |
|
195 | else: | |
|
196 | doclines.append(' ' + l.strip()) | |
|
192 | 197 | entries.append('\n'.join(doclines)) |
|
193 | 198 | entries = '\n\n'.join(entries) |
|
194 | 199 | return doc.replace(marker, entries) |
|
195 | 200 | |
|
196 | def addtopicsymbols(topic, marker, symbols): | |
|
201 | def addtopicsymbols(topic, marker, symbols, dedent=False): | |
|
197 | 202 | def add(topic, doc): |
|
198 | return makeitemsdoc(topic, doc, marker, symbols) | |
|
203 | return makeitemsdoc(topic, doc, marker, symbols, dedent=dedent) | |
|
199 | 204 | addtopichook(topic, add) |
|
200 | 205 | |
|
201 | 206 | addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols) |
@@ -203,7 +208,8 b" addtopicsymbols('merge-tools', '.. inter" | |||
|
203 | 208 | addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols) |
|
204 | 209 | addtopicsymbols('templates', '.. keywordsmarker', templatekw.dockeywords) |
|
205 | 210 | addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters) |
|
206 |
addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands |
|
|
211 | addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands, | |
|
212 | dedent=True) | |
|
207 | 213 | |
|
208 | 214 | def help_(ui, name, unknowncmd=False, full=True, **opts): |
|
209 | 215 | ''' |
General Comments 0
You need to be logged in to leave comments.
Login now