An abstract base class for performing syntax highlighting on doctest
blocks and other bits of Python code. Subclasses should provide
definitions for:
|
|
PREFIX = None
A string that is added to the beginning of the strings returned by colorize_codeblock and colorize_doctest.
|
|
|
SUFFIX = None
A string that is added to the end of the strings returned by colorize_codeblock and colorize_doctest.
|
|
|
_KEYWORDS = ['and', 'del', 'for', 'is', 'raiseassert', 'elif',...
A list of the names of all Python keywords.
|
|
|
_BUILTINS = ['clear', 'copy', 'fromkeys', 'get', 'has_key', 'i...
A list of all Python builtins.
|
|
|
_KEYWORD_GRP = '\\band\\b|\\bdel\\b|\\bfor\\b|\\bis\\b|\\brais...
A regexp group that matches keywords.
|
|
|
_BUILTIN_GRP = '(?<!\\.)(?:\\bclear\\b|\\bcopy\\b|\\bfromkeys\...
A regexp group that matches Python builtins.
|
|
|
_STRING_GRP = '("""("""|.*?((?!").)"""))|("("|.*?((?!").)"))|(...
A regexp group that matches Python strings.
|
|
|
_COMMENT_GRP = '(#.*?$)'
A regexp group that matches Python comments.
|
|
|
_PROMPT1_GRP = '^[ \\t]*>>>(?:[ \\t]|$)'
A regexp group that matches Python ">>>" prompts.
|
|
|
_PROMPT2_GRP = '^[ \\t]*\\.\\.\\.(?:[ \\t]|$)'
A regexp group that matches Python "..." prompts.
|
|
|
_DEFINE_GRP = '\\b(?:def|class)[ \\t]+\\w+'
A regexp group that matches function and class definitions.
|
|
|
PROMPT_RE = re.compile(r'(?ms)(^[ \t]*>>>(?:[ \t]|$)|[ \t]*\.\...
A regexp that matches Python prompts
|
|
|
PROMPT2_RE = re.compile(r'(?ms)(^[ \t]*\.\.\.(?:[ \t]|$))')
A regexp that matches Python "..." prompts.
|
|
|
EXCEPT_RE = re.compile(r'(?ms)^[ \t]*Traceback \(most recent c...
A regexp that matches doctest exception blocks.
|
|
|
DOCTEST_DIRECTIVE_RE = re.compile(r'#[ \t]*doctest:.*')
A regexp that matches doctest directives.
|
|
|
DOCTEST_RE = re.compile(r'(?ms)(.*?)((?P<STRING>("""("""|.*?((...
A regexp that matches all of the regions of a doctest block that
should be colored.
|
|
|
DOCTEST_EXAMPLE_RE = re.compile(r'(?mx)(?P<source>(?:^(?P<inde...
This regular expression is used to find doctest examples in a string.
|
|
|
_BI = 'values'
|
|
|
_KW = 'as'
|