diff options
| author | Shawn O. Pearce <sop@google.com> | 2009-04-21 08:01:17 -0700 |
|---|---|---|
| committer | Shawn O. Pearce <sop@google.com> | 2009-04-21 08:28:06 -0700 |
| commit | 938d608c9c47401fbdb60f3188c718e2f2569bd0 (patch) | |
| tree | d4b617e189c187ffbc44d8c4add9047c418118e4 /subcmds/help.py | |
| parent | d63bbf44dc22994ad3cdd73cf852f3d91d87b3f8 (diff) | |
| download | git-repo-938d608c9c47401fbdb60f3188c718e2f2569bd0.tar.gz | |
Support a level 2 heading in help description text
The level 2 headings (denoted by ~) indent the heading two spaces,
but continue to use the bold formatter to offset them from the
other surrounding text.
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'subcmds/help.py')
| -rw-r--r-- | subcmds/help.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/subcmds/help.py b/subcmds/help.py index fafceadb..c5979fd6 100644 --- a/subcmds/help.py +++ b/subcmds/help.py | |||
| @@ -107,7 +107,7 @@ See 'repo help --all' for a complete list of recognized commands. | |||
| 107 | body = body.strip() | 107 | body = body.strip() |
| 108 | body = body.replace('%prog', me) | 108 | body = body.replace('%prog', me) |
| 109 | 109 | ||
| 110 | asciidoc_hdr = re.compile(r'^\n?([^\n]{1,})\n(={2,}|-{2,})$') | 110 | asciidoc_hdr = re.compile(r'^\n?([^\n]{1,})\n([=~-]{2,})$') |
| 111 | for para in body.split("\n\n"): | 111 | for para in body.split("\n\n"): |
| 112 | if para.startswith(' '): | 112 | if para.startswith(' '): |
| 113 | self.write('%s', para) | 113 | self.write('%s', para) |
| @@ -117,9 +117,19 @@ See 'repo help --all' for a complete list of recognized commands. | |||
| 117 | 117 | ||
| 118 | m = asciidoc_hdr.match(para) | 118 | m = asciidoc_hdr.match(para) |
| 119 | if m: | 119 | if m: |
| 120 | self.heading('%s', m.group(1)) | 120 | title = m.group(1) |
| 121 | type = m.group(2) | ||
| 122 | if type[0] in ('=', '-'): | ||
| 123 | p = self.heading | ||
| 124 | else: | ||
| 125 | def _p(fmt, *args): | ||
| 126 | self.write(' ') | ||
| 127 | self.heading(fmt, *args) | ||
| 128 | p = _p | ||
| 129 | |||
| 130 | p('%s', title) | ||
| 121 | self.nl() | 131 | self.nl() |
| 122 | self.heading('%s', ''.ljust(len(m.group(1)),'-')) | 132 | p('%s', ''.ljust(len(title),type[0])) |
| 123 | self.nl() | 133 | self.nl() |
| 124 | continue | 134 | continue |
| 125 | 135 | ||
