Package epydoc :: Module colorize
[show private | hide private]
[frames | no frames]

Module epydoc.colorize

Functions to produce colorized HTML code for various objects. Currently, colorize defines functions to colorize regular expressions and doctest blocks.
Function Summary
string colorize_doctestblock(str)
Return the HTML code for a colorized version of a given doctest block.
string colorize_re(regexp)
Return the HTML code for a colorized version of the pattern for the given SRE regular expression.

Variable Summary
str ANY_TAG: The CSS class for colorizing "." in regular expressions.
str ASSERT_TAG: The CSS class for colorizing assertions (such as "(?=abc)") in regular expressions.
str AT_TAG: The CSS class for colorizing character locations (such as "^") in regular expressions.
str BRANCH_TAG: The CSS class for colorizing "|" in regular expressions.
str CATEGORY_TAG: The CSS class for colorizing character categories (such as r"\d")) in regular expressions.
str CHOICE_TAG: The CSS class for colorizing character choice expressions (such as "[abc]") in regular expressions.
str ESCAPE_TAG: The CSS class for colorizing escaped characters (such as r"\(") in regular expressions.
str PAREN_TAG: The CSS class for colorizing parenthases in regular expressions.
str PLUS_TAG: The CSS class for colorizing "+" and "+?" in regular expressions.
str QMRK_TAG: The CSS class for colorizing "?" and "??" in regular expressions.
str RE_TAG: The CSS class for colorizing regular expressions.
str REF_TAG: The CSS class for colorizing references (such as r"\1") in regular expressions.
str RNG_TAG: The CSS class for colorizing repeat ranges (such as "a{3,8}") in regular expressions.
str STAR_TAG: The CSS class for colorizing "*" and "*?" in regular expressions.

Function Details

colorize_doctestblock(str)

Parameters:
str - The contents of the doctest block to be colorized.
           (type=string)
Returns:
The HTML code for a colorized version of a given doctest block. In particular, this identifies spans with the following css classes:
  • py-src: The Python source code.
  • py-prompt: The ">>>" and "..." prompts.
  • py-string: Strings in the Python source code.
  • py-comment: Comments in the Python source code.
  • py-keyword: Keywords in the Python source code.
  • py-output: Python's output (lines without a prompt).
The string that is passed to colorize_doctest should already have HTML characters escaped (e.g., ">" should be encoded as ">").
           (type=string)

colorize_re(regexp)

Parameters:
regexp - The regular expression to colorize.
           (type=SRE_Pattern or string)
Returns:
The HTML code for a colorized version of the pattern for the given SRE regular expression. If colorize_re can't figure out how to colorize the regexp, then it will simply return the (uncolorized) pattern, with '&', '<', and '>' escaped as HTML entities. The colorized expression includes spans with the following css classes:
  • re: The entire regular expression.
  • re-char: Special characters (such as '.', '\('), character categories (such as '\w'), and locations (such as '\b').
  • re-op: Operators (such as '*' and '|').
  • re-group: Grouping constructs (such as '(...)').
  • re-ref References (such as '\1')

           (type=string)

Variable Details

ANY_TAG

The CSS class for colorizing "." in regular expressions.
Type:
str
Value:
're-char'                                                              

ASSERT_TAG

The CSS class for colorizing assertions (such as "(?=abc)") in regular expressions.
Type:
str
Value:
're-group'                                                             

AT_TAG

The CSS class for colorizing character locations (such as "^") in regular expressions.
Type:
str
Value:
're-char'                                                              

BRANCH_TAG

The CSS class for colorizing "|" in regular expressions.
Type:
str
Value:
're-op'                                                                

CATEGORY_TAG

The CSS class for colorizing character categories (such as r"\d")) in regular expressions.
Type:
str
Value:
're-char'                                                              

CHOICE_TAG

The CSS class for colorizing character choice expressions (such as "[abc]") in regular expressions.
Type:
str
Value:
're-group'                                                             

ESCAPE_TAG

The CSS class for colorizing escaped characters (such as r"\(") in regular expressions.
Type:
str
Value:
're-char'                                                              

PAREN_TAG

The CSS class for colorizing parenthases in regular expressions.
Type:
str
Value:
're-group'                                                             

PLUS_TAG

The CSS class for colorizing "+" and "+?" in regular expressions.
Type:
str
Value:
're-op'                                                                

QMRK_TAG

The CSS class for colorizing "?" and "??" in regular expressions.
Type:
str
Value:
're-op'                                                                

RE_TAG

The CSS class for colorizing regular expressions.
Type:
str
Value:
're'                                                                   

REF_TAG

The CSS class for colorizing references (such as r"\1") in regular expressions.
Type:
str
Value:
're-ref'                                                               

RNG_TAG

The CSS class for colorizing repeat ranges (such as "a{3,8}") in regular expressions.
Type:
str
Value:
're-op'                                                                

STAR_TAG

The CSS class for colorizing "*" and "*?" in regular expressions.
Type:
str
Value:
're-op'                                                                

Generated by Epydoc 2.1 on Sat Mar 20 17:46:18 2004 http://epydoc.sf.net