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