Package nltk :: Package test :: Module doctest_driver :: Class MyDocTestParser
[hide private]
[frames] | no frames]

Class MyDocTestParser

source code

doctest.DocTestParser --+
                        |
                       MyDocTestParser

Instance Methods [hide private]
 
parse(self, string, name='<string>')
Divide the given string into examples and intervening text, and return them as a list of alternating Examples and strings.
source code
 
get_examples(self, string, name='<string>')
Extract all doctest examples from the given string, and return them as a list of Example objects.
source code

Inherited from doctest.DocTestParser: get_doctest

Inherited from doctest.DocTestParser (private): _IS_BLANK_OR_COMMENT, _check_prefix, _check_prompt_blank, _find_options, _min_indent, _parse_example

Class Variables [hide private]
  PYLISTING_RE = re.compile(r'(?mx)(^\.\. *pylisting:: ?\S*\n(?:...
  PYLISTING_EX = re.compile(r'(?mx)(?:^[^ ].*\n(?: *\n| +.*\n)*)')
  DOCTEST_OPTION_RE = re.compile(r'(?mx)^ *:\w+:.*\n(.*\S.*)*')

Inherited from doctest.DocTestParser (private): _EXAMPLE_RE, _EXCEPTION_RE, _INDENT_RE, _OPTION_DIRECTIVE_RE

Method Details [hide private]

parse(self, string, name='<string>')

source code 
Divide the given string into examples and intervening text, and return them as a list of alternating Examples and strings. Line numbers for the Examples are 0-based. The optional argument name is a name identifying this string, and is only used for error messages.
Overrides: doctest.DocTestParser.parse
(inherited documentation)

get_examples(self, string, name='<string>')

source code 

Extract all doctest examples from the given string, and return them as a list of Example objects. Line numbers are 0-based, because it's most common in doctests that nothing interesting appears on the same line as opening triple-quote, and so the first interesting line is called "line 1" then.

The optional argument name is a name identifying this string, and is only used for error messages.

Overrides: doctest.DocTestParser.get_examples
(inherited documentation)

Class Variable Details [hide private]

PYLISTING_RE

Value:
re.compile(r'(?mx)(^\.\. *pylisting:: ?\S*\n(?: *\n| +.*\n)*)')