Package epydoc :: Package markup :: Module doctest
[hide private]
[frames] | no frames]

Module doctest

source code

Syntax highlighting for doctest blocks. This module defines two functions, doctest_to_html() and doctest_to_latex(), which can be used to perform syntax highlighting on doctest blocks. It also defines the more general colorize_doctest(), which could be used to do syntac highlighting on doctest blocks with other output formats. (Both doctest_to_html() and doctest_to_latex() are defined using colorize_doctest().)

Classes [hide private]
  DoctestColorizer
An abstract base class for performing syntax highlighting on doctest blocks and other bits of Python code.
  XMLDoctestColorizer
A subclass of DoctestColorizer that generates XML-like output.
  HTMLDoctestColorizer
A subclass of DoctestColorizer that generates HTML output.
  LaTeXDoctestColorizer
A subclass of DoctestColorizer that generates LaTeX output.
Functions [hide private]
 
doctest_to_html(s)
Perform syntax highlighting on the given doctest string, and return the resulting HTML code.
source code
call graph 
 
doctest_to_latex(s)
Perform syntax highlighting on the given doctest string, and return the resulting LaTeX code.
source code
Function Details [hide private]

doctest_to_html(s)

source code 
call graph 
Perform syntax highlighting on the given doctest string, and return the resulting HTML code. This code consists of a <pre> block with class=py-doctest. Syntax highlighting is performed using the following css classes:
  • py-prompt -- the Python PS1 prompt (>>>)
  • py-more -- the Python PS2 prompt (...)
  • py-keyword -- a Python keyword (for, if, etc.)
  • py-builtin -- a Python builtin name (abs, dir, etc.)
  • py-string -- a string literal
  • py-comment -- a comment
  • py-except -- an exception traceback (up to the next >>>)
  • py-output -- the output from a doctest block.
  • py-defname -- the name of a function or class defined by a def or class statement.

doctest_to_latex(s)

source code 
Perform syntax highlighting on the given doctest string, and return the resulting LaTeX code. This code consists of an alltt environment. Syntax highlighting is performed using the following new latex commands, which must be defined externally:
  • \pysrcprompt -- the Python PS1 prompt (>>>)
  • \pysrcmore -- the Python PS2 prompt (...)
  • \pysrckeyword -- a Python keyword (for, if, etc.)
  • \pysrcbuiltin -- a Python builtin name (abs, dir, etc.)
  • \pysrcstring -- a string literal
  • \pysrccomment -- a comment
  • \pysrcexcept -- an exception traceback (up to the next >>>)
  • \pysrcoutput -- the output from a doctest block.
  • \pysrcdefname -- the name of a function or class defined by a def or class statement.