Return the available styles as pretty-printed string.
(cls)
| 2440 | |
| 2441 | @classmethod |
| 2442 | def pprint_styles(cls): |
| 2443 | """Return the available styles as pretty-printed string.""" |
| 2444 | table = [('Class', 'Name', 'Parameters'), |
| 2445 | *[(cls.__name__, |
| 2446 | # Add backquotes, as - and | have special meaning in reST. |
| 2447 | f'``{name}``', |
| 2448 | # [1:-1] drops the surrounding parentheses. |
| 2449 | str(inspect.signature(cls))[1:-1] or 'None') |
| 2450 | for name, cls in cls._style_list.items()]] |
| 2451 | # Convert to rst table. |
| 2452 | col_len = [max(len(cell) for cell in column) for column in zip(*table)] |
| 2453 | table_formatstr = ' '.join('=' * cl for cl in col_len) |
| 2454 | rst_table = '\n'.join([ |
| 2455 | '', |
| 2456 | table_formatstr, |
| 2457 | ' '.join(cell.ljust(cl) for cell, cl in zip(table[0], col_len)), |
| 2458 | table_formatstr, |
| 2459 | *[' '.join(cell.ljust(cl) for cell, cl in zip(row, col_len)) |
| 2460 | for row in table[1:]], |
| 2461 | table_formatstr, |
| 2462 | ]) |
| 2463 | return textwrap.indent(rst_table, prefix=' ' * 4) |
| 2464 | |
| 2465 | @classmethod |
| 2466 | @_api.deprecated( |
no test coverage detected