Print topics which are documented commands, switching between verbose or traditional output.
(self, header: str, commands: Sequence[str], verbose: bool)
| 4389 | self.poutput() |
| 4390 | |
| 4391 | def _print_documented_command_topics(self, header: str, commands: Sequence[str], verbose: bool) -> None: |
| 4392 | """Print topics which are documented commands, switching between verbose or traditional output.""" |
| 4393 | if not commands: |
| 4394 | return |
| 4395 | |
| 4396 | if not verbose: |
| 4397 | self.print_topics(header, commands, 15, 80) |
| 4398 | return |
| 4399 | |
| 4400 | topic_table = Cmd2SimpleTable( |
| 4401 | Column("Name", no_wrap=True), |
| 4402 | Column("Description", overflow="fold"), |
| 4403 | ) |
| 4404 | |
| 4405 | # Try to get the documentation string for each command |
| 4406 | for command in commands: |
| 4407 | if (command_func := self.get_command_func(command)) is None: |
| 4408 | continue |
| 4409 | |
| 4410 | doc = command_func.__doc__ |
| 4411 | |
| 4412 | # Attempt to locate the first documentation block |
| 4413 | cmd_desc = strip_doc_annotations(doc) if doc else "" |
| 4414 | |
| 4415 | # Add this command to the table |
| 4416 | topic_table.add_row(command, cmd_desc) |
| 4417 | |
| 4418 | self.poutput( |
| 4419 | self._create_help_grid(header, topic_table), |
| 4420 | soft_wrap=False, |
| 4421 | ) |
| 4422 | self.poutput() |
| 4423 | |
| 4424 | def render_columns(self, str_list: Sequence[str] | None, display_width: int = 80) -> str: |
| 4425 | """Render a list of single-line strings as a compact set of columns. |