Show More
@@ -2782,7 +2782,7 b' def help_(ui, name=None, unknowncmd=Fals' | |||||
2782 | doc = doc.splitlines()[0] |
|
2782 | doc = doc.splitlines()[0] | |
2783 | keep = ui.verbose and ['verbose'] or [] |
|
2783 | keep = ui.verbose and ['verbose'] or [] | |
2784 | formatted, pruned = minirst.format(doc, textwidth, keep=keep) |
|
2784 | formatted, pruned = minirst.format(doc, textwidth, keep=keep) | |
2785 |
ui.write("\n%s |
|
2785 | ui.write("\n%s" % formatted) | |
2786 | if pruned: |
|
2786 | if pruned: | |
2787 | ui.write(_('\nuse "hg -v help %s" to show verbose help\n') % name) |
|
2787 | ui.write(_('\nuse "hg -v help %s" to show verbose help\n') % name) | |
2788 |
|
2788 | |||
@@ -2862,7 +2862,7 b' def help_(ui, name=None, unknowncmd=Fals' | |||||
2862 | doc = doc() |
|
2862 | doc = doc() | |
2863 |
|
2863 | |||
2864 | ui.write("%s\n\n" % header) |
|
2864 | ui.write("%s\n\n" % header) | |
2865 |
ui.write("%s |
|
2865 | ui.write("%s" % minirst.format(doc, textwidth, indent=4)) | |
2866 | try: |
|
2866 | try: | |
2867 | cmdutil.findcmd(name, table) |
|
2867 | cmdutil.findcmd(name, table) | |
2868 | ui.write(_('\nuse "hg help -c %s" to see help for ' |
|
2868 | ui.write(_('\nuse "hg help -c %s" to see help for ' | |
@@ -2887,7 +2887,7 b' def help_(ui, name=None, unknowncmd=Fals' | |||||
2887 | ui.write(_('%s extension - %s\n\n') % (name.split('.')[-1], head)) |
|
2887 | ui.write(_('%s extension - %s\n\n') % (name.split('.')[-1], head)) | |
2888 | if tail: |
|
2888 | if tail: | |
2889 | ui.write(minirst.format(tail, textwidth)) |
|
2889 | ui.write(minirst.format(tail, textwidth)) | |
2890 |
ui.status('\n |
|
2890 | ui.status('\n') | |
2891 |
|
2891 | |||
2892 | if mod: |
|
2892 | if mod: | |
2893 | try: |
|
2893 | try: | |
@@ -2907,7 +2907,7 b' def help_(ui, name=None, unknowncmd=Fals' | |||||
2907 | msg = help.listexts(_("'%s' is provided by the following " |
|
2907 | msg = help.listexts(_("'%s' is provided by the following " | |
2908 | "extension:") % cmd, {ext: doc}, indent=4) |
|
2908 | "extension:") % cmd, {ext: doc}, indent=4) | |
2909 | ui.write(minirst.format(msg, textwidth)) |
|
2909 | ui.write(minirst.format(msg, textwidth)) | |
2910 |
ui.write('\n |
|
2910 | ui.write('\n') | |
2911 | ui.write(_('use "hg help extensions" for information on enabling ' |
|
2911 | ui.write(_('use "hg help extensions" for information on enabling ' | |
2912 | 'extensions\n')) |
|
2912 | 'extensions\n')) | |
2913 |
|
2913 | |||
@@ -2946,7 +2946,7 b' def help_(ui, name=None, unknowncmd=Fals' | |||||
2946 | if name != 'shortlist': |
|
2946 | if name != 'shortlist': | |
2947 | text = help.listexts(_('enabled extensions:'), extensions.enabled()) |
|
2947 | text = help.listexts(_('enabled extensions:'), extensions.enabled()) | |
2948 | if text: |
|
2948 | if text: | |
2949 |
ui.write("\n%s |
|
2949 | ui.write("\n%s" % minirst.format(text, textwidth)) | |
2950 |
|
2950 | |||
2951 | if not name: |
|
2951 | if not name: | |
2952 | ui.write(_("\nadditional help topics:\n\n")) |
|
2952 | ui.write(_("\nadditional help topics:\n\n")) |
@@ -398,7 +398,7 b' def formatoption(block, width):' | |||||
398 | hanging = block['optstrwidth'] |
|
398 | hanging = block['optstrwidth'] | |
399 | initindent = '%s%s ' % (block['optstr'], ' ' * ((hanging - colwidth))) |
|
399 | initindent = '%s%s ' % (block['optstr'], ' ' * ((hanging - colwidth))) | |
400 | hangindent = ' ' * (encoding.colwidth(initindent) + 1) |
|
400 | hangindent = ' ' * (encoding.colwidth(initindent) + 1) | |
401 | return ' %s' % (util.wrap(desc, usablewidth, |
|
401 | return ' %s\n' % (util.wrap(desc, usablewidth, | |
402 | initindent=initindent, |
|
402 | initindent=initindent, | |
403 | hangindent=hangindent)) |
|
403 | hangindent=hangindent)) | |
404 |
|
404 | |||
@@ -413,17 +413,18 b' def formatblock(block, width):' | |||||
413 |
|
413 | |||
414 | defindent = indent + hang * ' ' |
|
414 | defindent = indent + hang * ' ' | |
415 | text = ' '.join(map(str.strip, block['lines'])) |
|
415 | text = ' '.join(map(str.strip, block['lines'])) | |
416 |
return '%s\n%s' % (indent + admonition, |
|
416 | return '%s\n%s\n' % (indent + admonition, | |
|
417 | util.wrap(text, width=width, | |||
417 |
|
|
418 | initindent=defindent, | |
418 |
|
|
419 | hangindent=defindent)) | |
419 | if block['type'] == 'margin': |
|
420 | if block['type'] == 'margin': | |
420 | return '' |
|
421 | return '\n' | |
421 | if block['type'] == 'literal': |
|
422 | if block['type'] == 'literal': | |
422 | indent += ' ' |
|
423 | indent += ' ' | |
423 | return indent + ('\n' + indent).join(block['lines']) |
|
424 | return indent + ('\n' + indent).join(block['lines']) + '\n' | |
424 | if block['type'] == 'section': |
|
425 | if block['type'] == 'section': | |
425 | underline = encoding.colwidth(block['lines'][0]) * block['underline'] |
|
426 | underline = encoding.colwidth(block['lines'][0]) * block['underline'] | |
426 | return "%s%s\n%s%s" % (indent, block['lines'][0],indent, underline) |
|
427 | return "%s%s\n%s%s\n" % (indent, block['lines'][0],indent, underline) | |
427 | if block['type'] == 'table': |
|
428 | if block['type'] == 'table': | |
428 | table = block['table'] |
|
429 | table = block['table'] | |
429 | # compute column widths |
|
430 | # compute column widths | |
@@ -447,7 +448,7 b' def formatblock(block, width):' | |||||
447 | hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip()) |
|
448 | hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip()) | |
448 | defindent = indent + hang * ' ' |
|
449 | defindent = indent + hang * ' ' | |
449 | text = ' '.join(map(str.strip, block['lines'][1:])) |
|
450 | text = ' '.join(map(str.strip, block['lines'][1:])) | |
450 | return '%s\n%s' % (term, util.wrap(text, width=width, |
|
451 | return '%s\n%s\n' % (term, util.wrap(text, width=width, | |
451 | initindent=defindent, |
|
452 | initindent=defindent, | |
452 | hangindent=defindent)) |
|
453 | hangindent=defindent)) | |
453 | subindent = indent |
|
454 | subindent = indent | |
@@ -481,7 +482,7 b' def formatblock(block, width):' | |||||
481 | text = ' '.join(map(str.strip, block['lines'])) |
|
482 | text = ' '.join(map(str.strip, block['lines'])) | |
482 | return util.wrap(text, width=width, |
|
483 | return util.wrap(text, width=width, | |
483 | initindent=indent, |
|
484 | initindent=indent, | |
484 | hangindent=subindent) |
|
485 | hangindent=subindent) + '\n' | |
485 |
|
486 | |||
486 | def parse(text, indent=0, keep=None): |
|
487 | def parse(text, indent=0, keep=None): | |
487 | """Parse text into a list of blocks""" |
|
488 | """Parse text into a list of blocks""" | |
@@ -504,13 +505,13 b' def parse(text, indent=0, keep=None):' | |||||
504 | return blocks, pruned |
|
505 | return blocks, pruned | |
505 |
|
506 | |||
506 | def formatblocks(blocks, width): |
|
507 | def formatblocks(blocks, width): | |
507 |
text = ' |
|
508 | text = ''.join(formatblock(b, width) for b in blocks) | |
508 | return text |
|
509 | return text | |
509 |
|
510 | |||
510 | def format(text, width, indent=0, keep=None): |
|
511 | def format(text, width, indent=0, keep=None): | |
511 | """Parse and format the text according to width.""" |
|
512 | """Parse and format the text according to width.""" | |
512 | blocks, pruned = parse(text, indent, keep or []) |
|
513 | blocks, pruned = parse(text, indent, keep or []) | |
513 |
text = ' |
|
514 | text = ''.join(formatblock(b, width) for b in blocks) | |
514 | if keep is None: |
|
515 | if keep is None: | |
515 | return text |
|
516 | return text | |
516 | else: |
|
517 | else: |
@@ -6,6 +6,7 b' This is some text in the first paragraph' | |||||
6 | containing random whitespace. |
|
6 | containing random whitespace. | |
7 |
|
7 | |||
8 | The third and final paragraph. |
|
8 | The third and final paragraph. | |
|
9 | ||||
9 | ---------------------------------------------------------------------- |
|
10 | ---------------------------------------------------------------------- | |
10 |
|
11 | |||
11 | paragraphs formatted to fit within 30 characters: |
|
12 | paragraphs formatted to fit within 30 characters: | |
@@ -19,6 +20,7 b' paragraph.' | |||||
19 | whitespace. |
|
20 | whitespace. | |
20 |
|
21 | |||
21 | The third and final paragraph. |
|
22 | The third and final paragraph. | |
|
23 | ||||
22 | ---------------------------------------------------------------------- |
|
24 | ---------------------------------------------------------------------- | |
23 |
|
25 | |||
24 | definitions formatted to fit within 60 characters: |
|
26 | definitions formatted to fit within 60 characters: | |
@@ -33,6 +35,7 b' Another Term' | |||||
33 |
|
35 | |||
34 | A Nested/Indented Term |
|
36 | A Nested/Indented Term | |
35 | Definition. |
|
37 | Definition. | |
|
38 | ||||
36 | ---------------------------------------------------------------------- |
|
39 | ---------------------------------------------------------------------- | |
37 |
|
40 | |||
38 | definitions formatted to fit within 30 characters: |
|
41 | definitions formatted to fit within 30 characters: | |
@@ -52,6 +55,7 b' Another Term' | |||||
52 |
|
55 | |||
53 | A Nested/Indented Term |
|
56 | A Nested/Indented Term | |
54 | Definition. |
|
57 | Definition. | |
|
58 | ||||
55 | ---------------------------------------------------------------------- |
|
59 | ---------------------------------------------------------------------- | |
56 |
|
60 | |||
57 | literals formatted to fit within 60 characters: |
|
61 | literals formatted to fit within 60 characters: | |
@@ -72,6 +76,7 b' space-double-colon.' | |||||
72 | This literal block is started with '::', |
|
76 | This literal block is started with '::', | |
73 | the so-called expanded form. The paragraph |
|
77 | the so-called expanded form. The paragraph | |
74 | with '::' disappears in the final output. |
|
78 | with '::' disappears in the final output. | |
|
79 | ||||
75 | ---------------------------------------------------------------------- |
|
80 | ---------------------------------------------------------------------- | |
76 |
|
81 | |||
77 | literals formatted to fit within 30 characters: |
|
82 | literals formatted to fit within 30 characters: | |
@@ -94,6 +99,7 b' with space-double-colon.' | |||||
94 | This literal block is started with '::', |
|
99 | This literal block is started with '::', | |
95 | the so-called expanded form. The paragraph |
|
100 | the so-called expanded form. The paragraph | |
96 | with '::' disappears in the final output. |
|
101 | with '::' disappears in the final output. | |
|
102 | ||||
97 | ---------------------------------------------------------------------- |
|
103 | ---------------------------------------------------------------------- | |
98 |
|
104 | |||
99 | lists formatted to fit within 60 characters: |
|
105 | lists formatted to fit within 60 characters: | |
@@ -129,6 +135,7 b' Line blocks are also a form of list:' | |||||
129 |
|
135 | |||
130 | This is the first line. The line continues here. |
|
136 | This is the first line. The line continues here. | |
131 | This is the second line. |
|
137 | This is the second line. | |
|
138 | ||||
132 | ---------------------------------------------------------------------- |
|
139 | ---------------------------------------------------------------------- | |
133 |
|
140 | |||
134 | lists formatted to fit within 30 characters: |
|
141 | lists formatted to fit within 30 characters: | |
@@ -173,6 +180,7 b' list:' | |||||
173 | This is the first line. The |
|
180 | This is the first line. The | |
174 | line continues here. |
|
181 | line continues here. | |
175 | This is the second line. |
|
182 | This is the second line. | |
|
183 | ||||
176 | ---------------------------------------------------------------------- |
|
184 | ---------------------------------------------------------------------- | |
177 |
|
185 | |||
178 | options formatted to fit within 60 characters: |
|
186 | options formatted to fit within 60 characters: | |
@@ -200,6 +208,7 b' two-space marker after the option. It is' | |||||
200 | paragraph: |
|
208 | paragraph: | |
201 |
|
209 | |||
202 | --foo bar baz |
|
210 | --foo bar baz | |
|
211 | ||||
203 | ---------------------------------------------------------------------- |
|
212 | ---------------------------------------------------------------------- | |
204 |
|
213 | |||
205 | options formatted to fit within 30 characters: |
|
214 | options formatted to fit within 30 characters: | |
@@ -272,6 +281,7 b' option. It is treated as a' | |||||
272 | normal paragraph: |
|
281 | normal paragraph: | |
273 |
|
282 | |||
274 | --foo bar baz |
|
283 | --foo bar baz | |
|
284 | ||||
275 | ---------------------------------------------------------------------- |
|
285 | ---------------------------------------------------------------------- | |
276 |
|
286 | |||
277 | fields formatted to fit within 60 characters: |
|
287 | fields formatted to fit within 60 characters: | |
@@ -286,6 +296,7 b' small The larger key below trigger' | |||||
286 | here. |
|
296 | here. | |
287 | much too large |
|
297 | much too large | |
288 | This key is big enough to get its own line. |
|
298 | This key is big enough to get its own line. | |
|
299 | ||||
289 | ---------------------------------------------------------------------- |
|
300 | ---------------------------------------------------------------------- | |
290 |
|
301 | |||
291 | fields formatted to fit within 30 characters: |
|
302 | fields formatted to fit within 30 characters: | |
@@ -305,11 +316,13 b' much too large' | |||||
305 | This key is big |
|
316 | This key is big | |
306 | enough to get its |
|
317 | enough to get its | |
307 | own line. |
|
318 | own line. | |
|
319 | ||||
308 | ---------------------------------------------------------------------- |
|
320 | ---------------------------------------------------------------------- | |
309 |
|
321 | |||
310 | containers (normal) formatted to fit within 60 characters: |
|
322 | containers (normal) formatted to fit within 60 characters: | |
311 | ---------------------------------------------------------------------- |
|
323 | ---------------------------------------------------------------------- | |
312 | Normal output. |
|
324 | Normal output. | |
|
325 | ||||
313 | ---------------------------------------------------------------------- |
|
326 | ---------------------------------------------------------------------- | |
314 |
|
327 | |||
315 | containers (verbose) formatted to fit within 60 characters: |
|
328 | containers (verbose) formatted to fit within 60 characters: | |
@@ -317,6 +330,7 b' containers (verbose) formatted to fit wi' | |||||
317 | Normal output. |
|
330 | Normal output. | |
318 |
|
331 | |||
319 | Verbose output. |
|
332 | Verbose output. | |
|
333 | ||||
320 | ---------------------------------------------------------------------- |
|
334 | ---------------------------------------------------------------------- | |
321 | ['debug', 'debug'] |
|
335 | ['debug', 'debug'] | |
322 | ---------------------------------------------------------------------- |
|
336 | ---------------------------------------------------------------------- | |
@@ -326,6 +340,7 b' containers (debug) formatted to fit with' | |||||
326 | Normal output. |
|
340 | Normal output. | |
327 |
|
341 | |||
328 | Initial debug output. |
|
342 | Initial debug output. | |
|
343 | ||||
329 | ---------------------------------------------------------------------- |
|
344 | ---------------------------------------------------------------------- | |
330 | ['verbose'] |
|
345 | ['verbose'] | |
331 | ---------------------------------------------------------------------- |
|
346 | ---------------------------------------------------------------------- | |
@@ -339,6 +354,7 b' Initial debug output.' | |||||
339 | Verbose output. |
|
354 | Verbose output. | |
340 |
|
355 | |||
341 | Debug output. |
|
356 | Debug output. | |
|
357 | ||||
342 | ---------------------------------------------------------------------- |
|
358 | ---------------------------------------------------------------------- | |
343 | [] |
|
359 | [] | |
344 | ---------------------------------------------------------------------- |
|
360 | ---------------------------------------------------------------------- | |
@@ -346,6 +362,7 b' Debug output.' | |||||
346 | roles formatted to fit within 60 characters: |
|
362 | roles formatted to fit within 60 characters: | |
347 | ---------------------------------------------------------------------- |
|
363 | ---------------------------------------------------------------------- | |
348 | Please see "hg add". |
|
364 | Please see "hg add". | |
|
365 | ||||
349 | ---------------------------------------------------------------------- |
|
366 | ---------------------------------------------------------------------- | |
350 |
|
367 | |||
351 | sections formatted to fit within 20 characters: |
|
368 | sections formatted to fit within 20 characters: | |
@@ -361,6 +378,7 b' Subsection' | |||||
361 |
|
378 | |||
362 | Markup: "foo" and "hg help" |
|
379 | Markup: "foo" and "hg help" | |
363 | --------------------------- |
|
380 | --------------------------- | |
|
381 | ||||
364 | ---------------------------------------------------------------------- |
|
382 | ---------------------------------------------------------------------- | |
365 |
|
383 | |||
366 | admonitions formatted to fit within 30 characters: |
|
384 | admonitions formatted to fit within 30 characters: | |
@@ -377,6 +395,7 b' Note:' | |||||
377 |
|
395 | |||
378 | !Danger! |
|
396 | !Danger! | |
379 | This is danger |
|
397 | This is danger | |
|
398 | ||||
380 | ---------------------------------------------------------------------- |
|
399 | ---------------------------------------------------------------------- | |
381 |
|
400 | |||
382 | comments formatted to fit within 30 characters: |
|
401 | comments formatted to fit within 30 characters: | |
@@ -386,6 +405,7 b' Some text.' | |||||
386 | Some indented text. |
|
405 | Some indented text. | |
387 |
|
406 | |||
388 | Empty comment above |
|
407 | Empty comment above | |
|
408 | ||||
389 | ---------------------------------------------------------------------- |
|
409 | ---------------------------------------------------------------------- | |
390 |
|
410 | |||
391 | === === ======================================== |
|
411 | === === ======================================== |
General Comments 0
You need to be logged in to leave comments.
Login now