summaryrefslogtreecommitdiffstats
path: root/subcmds/help.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/help.py')
-rw-r--r--subcmds/help.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/subcmds/help.py b/subcmds/help.py
index 9ba9e706..6a767e6f 100644
--- a/subcmds/help.py
+++ b/subcmds/help.py
@@ -14,7 +14,7 @@
14 14
15import re 15import re
16import sys 16import sys
17from formatter import AbstractFormatter, DumbWriter 17import textwrap
18 18
19from subcmds import all_commands 19from subcmds import all_commands
20from color import Coloring 20from color import Coloring
@@ -84,8 +84,7 @@ Displays detailed usage information about a command.
84 def __init__(self, gc): 84 def __init__(self, gc):
85 Coloring.__init__(self, gc, 'help') 85 Coloring.__init__(self, gc, 'help')
86 self.heading = self.printer('heading', attr='bold') 86 self.heading = self.printer('heading', attr='bold')
87 87 self._first = True
88 self.wrap = AbstractFormatter(DumbWriter())
89 88
90 def _PrintSection(self, heading, bodyAttr): 89 def _PrintSection(self, heading, bodyAttr):
91 try: 90 try:
@@ -95,7 +94,9 @@ Displays detailed usage information about a command.
95 if body == '' or body is None: 94 if body == '' or body is None:
96 return 95 return
97 96
98 self.nl() 97 if not self._first:
98 self.nl()
99 self._first = False
99 100
100 self.heading('%s%s', header_prefix, heading) 101 self.heading('%s%s', header_prefix, heading)
101 self.nl() 102 self.nl()
@@ -105,7 +106,8 @@ Displays detailed usage information about a command.
105 body = body.strip() 106 body = body.strip()
106 body = body.replace('%prog', me) 107 body = body.replace('%prog', me)
107 108
108 asciidoc_hdr = re.compile(r'^\n?#+ (.+)$') 109 # Extract the title, but skip any trailing {#anchors}.
110 asciidoc_hdr = re.compile(r'^\n?#+ ([^{]+)(\{#.+\})?$')
109 for para in body.split("\n\n"): 111 for para in body.split("\n\n"):
110 if para.startswith(' '): 112 if para.startswith(' '):
111 self.write('%s', para) 113 self.write('%s', para)
@@ -120,9 +122,12 @@ Displays detailed usage information about a command.
120 self.nl() 122 self.nl()
121 continue 123 continue
122 124
123 self.wrap.add_flowing_data(para) 125 lines = textwrap.wrap(para.replace(' ', ' '), width=80,
124 self.wrap.end_paragraph(1) 126 break_long_words=False, break_on_hyphens=False)
125 self.wrap.end_paragraph(0) 127 for line in lines:
128 self.write('%s', line)
129 self.nl()
130 self.nl()
126 131
127 out = _Out(self.client.globalConfig) 132 out = _Out(self.client.globalConfig)
128 out._PrintSection('Summary', 'helpSummary') 133 out._PrintSection('Summary', 'helpSummary')