class documentation

class HelpFormatter: (source)

View In Hierarchy

This class helps with formatting text-based help pages. It's usually just needed for very special internal cases, but it's also exposed so that developers can write their own fancy outputs. At present, it always writes into memory. :param indent_increment: the additional increment for each level. :param width: the width for the text. This defaults to the terminal width clamped to a maximum of 78.

Method __init__ Undocumented
Method dedent Decreases the indentation.
Method getvalue Returns the buffer contents.
Method indent Increases the indentation.
Method indentation A context manager that increases the indentation.
Method section Helpful context manager that writes a paragraph, a heading, and the indents.
Method write Writes a unicode string into the internal buffer.
Method write_dl Writes a definition list into the buffer. This is how options and commands are usually formatted.
Method write_heading Writes a heading into the buffer.
Method write_paragraph Writes a paragraph into the buffer.
Method write_text Writes re-indented text into the buffer. This rewraps and preserves paragraphs.
Method write_usage Writes a usage line into the buffer.
Instance Variable buffer Undocumented
Instance Variable current_indent Undocumented
Instance Variable indent_increment Undocumented
Instance Variable width Undocumented
def __init__(self, indent_increment=2, width=None, max_width=None): (source)

Undocumented

Parameters
indent_increment:intUndocumented
width:t.Optional[int]Undocumented
max_width:t.Optional[int]Undocumented
def dedent(self): (source)

Decreases the indentation.

def getvalue(self): (source)

Returns the buffer contents.

Returns
strUndocumented
def indent(self): (source)

Increases the indentation.

@contextmanager
def indentation(self): (source)

A context manager that increases the indentation.

Returns
t.Iterator[None]Undocumented
@contextmanager
def section(self, name): (source)

Helpful context manager that writes a paragraph, a heading, and the indents. :param name: the section name that is written as heading.

Parameters
name:strUndocumented
Returns
t.Iterator[None]Undocumented
def write(self, string): (source)

Writes a unicode string into the internal buffer.

Parameters
string:strUndocumented
def write_dl(self, rows, col_max=30, col_spacing=2): (source)

Writes a definition list into the buffer. This is how options and commands are usually formatted. :param rows: a list of two item tuples for the terms and values. :param col_max: the maximum width of the first column. :param col_spacing: the number of spaces between the first and second column.

Parameters
rows:t.Sequence[t.Tuple[str, str]]Undocumented
col_max:intUndocumented
col_spacing:intUndocumented
def write_heading(self, heading): (source)

Writes a heading into the buffer.

Parameters
heading:strUndocumented
def write_paragraph(self): (source)

Writes a paragraph into the buffer.

def write_text(self, text): (source)

Writes re-indented text into the buffer. This rewraps and preserves paragraphs.

Parameters
text:strUndocumented
def write_usage(self, prog, args='', prefix=None): (source)

Writes a usage line into the buffer. :param prog: the program name. :param args: whitespace separated list of arguments. :param prefix: The prefix for the first line. Defaults to ``"Usage: "``.

Parameters
prog:strUndocumented
args:strUndocumented
prefix:t.Optional[str]Undocumented
buffer: t.List[str] = (source)

Undocumented

current_indent: int = (source)

Undocumented

indent_increment = (source)

Undocumented

width = (source)

Undocumented