| 223 | self.items = [] |
| 224 | |
| 225 | def format_help(self): |
| 226 | # format the indented section |
| 227 | if self.parent is not None: |
| 228 | self.formatter._indent() |
| 229 | join = self.formatter._join_parts |
| 230 | for func, args in self.items: |
| 231 | func(*args) |
| 232 | item_help = join([func(*args) for func, args in self.items]) |
| 233 | if self.parent is not None: |
| 234 | self.formatter._dedent() |
| 235 | |
| 236 | # return nothing if the section was empty |
| 237 | if not item_help: |
| 238 | return '' |
| 239 | |
| 240 | # add the heading if the section was non-empty |
| 241 | if self.heading is not SUPPRESS and self.heading is not None: |
| 242 | current_indent = self.formatter._current_indent |
| 243 | heading = '%*s%s:\n' % (current_indent, '', self.heading) |
| 244 | else: |
| 245 | heading = '' |
| 246 | |
| 247 | # join the section-initial newline, the heading and the help |
| 248 | return join(['\n', heading, item_help, '\n']) |
| 249 | |
| 250 | def _add_item(self, func, args): |
| 251 | self._current_section.items.append((func, args)) |