OpenQuizz
Une application de gestion des contenus pédagogiques
HelpFormatter Class Reference
Inheritance diagram for HelpFormatter:
Collaboration diagram for HelpFormatter:

Public Member Functions

def __init__ (self, indent_increment=2, width=None, max_width=None)
 
def write (self, string)
 
def indent (self)
 
def dedent (self)
 
def write_usage (self, prog, args="", prefix="Usage: ")
 
def write_heading (self, heading)
 
def write_paragraph (self)
 
def write_text (self, text)
 
def write_dl (self, rows, col_max=30, col_spacing=2)
 
def section (self, name)
 
def indentation (self)
 
def getvalue (self)
 

Data Fields

 indent_increment
 
 width
 
 current_indent
 
 buffer
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  indent_increment = 2,
  width = None,
  max_width = None 
)

Member Function Documentation

◆ dedent()

def dedent (   self)
Decreases the indentation.

◆ getvalue()

def getvalue (   self)
Returns the buffer contents.

◆ indent()

def indent (   self)
Increases the indentation.

◆ indentation()

def indentation (   self)
A context manager that increases the indentation.

◆ section()

def section (   self,
  name 
)
Helpful context manager that writes a paragraph, a heading,
and the indents.

:param name: the section name that is written as heading.

◆ write()

def write (   self,
  string 
)
Writes a unicode string into the internal buffer.

◆ write_dl()

def write_dl (   self,
  rows,
  col_max = 30,
  col_spacing = 2 
)
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.

◆ write_heading()

def write_heading (   self,
  heading 
)
Writes a heading into the buffer.

◆ write_paragraph()

def write_paragraph (   self)
Writes a paragraph into the buffer.

◆ write_text()

def write_text (   self,
  text 
)
Writes re-indented text into the buffer.  This rewraps and
preserves paragraphs.

◆ write_usage()

def write_usage (   self,
  prog,
  args = "",
  prefix = "Usage: " 
)
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.

Field Documentation

◆ buffer

buffer

◆ current_indent

current_indent

◆ indent_increment

indent_increment

◆ width

width

The documentation for this class was generated from the following file: