def parse_freeform_docstr_examples(docstr, callname=None, modpath=None,<EOL>lineno=<NUM_LIT:1>, fpath=None, asone=True):
def doctest_from_parts(parts, num, curr_offset):<EOL><INDENT>nested = [<EOL>p.orig_lines<EOL>if p.want is None else<EOL>p.orig_lines + p.want.splitlines()<EOL>for p in parts<EOL>]<EOL>docsrc = '<STR_LIT:\n>'.join(list(it.chain.from_iterable(nested)))<EOL>docsrc = textwrap.dedent(docsrc)<EOL>example = doctest_example.DocTest(docsrc, modpath=modpath,<EOL>callname=callname, num=num,<EOL>lineno=lineno + curr_offset,<EOL>fpath=fpath)<EOL>unoffset = parts[<NUM_LIT:0>].line_offset<EOL>for p in parts:<EOL><INDENT>p.line_offset -= unoffset<EOL><DEDENT>example._parts = parts<EOL>return example<EOL><DEDENT>if DEBUG:<EOL><INDENT>print('<STR_LIT>'.format(<EOL>callname, modpath))<EOL><DEDENT>respect_google_headers = True<EOL>if respect_google_headers:  <EOL><INDENT>special_skip_patterns = [<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>]<EOL><DEDENT>else:<EOL><INDENT>special_skip_patterns = []  <EOL><DEDENT>special_skip_patterns_ = tuple([<EOL>p.lower() for p in special_skip_patterns<EOL>])<EOL>def _start_ignoring(prev):<EOL><INDENT>return (special_skip_patterns_ and<EOL>isinstance(prev, six.string_types) and<EOL>prev.strip().lower().endswith(special_skip_patterns_))<EOL><DEDENT>info = dict(callname=callname, modpath=modpath, lineno=lineno, fpath=fpath)<EOL>all_parts = list(parser.DoctestParser().parse(docstr, info))<EOL>curr_parts = []<EOL>curr_offset = <NUM_LIT:0><EOL>num = <NUM_LIT:0><EOL>prev_part = None<EOL>ignoring = False<EOL>for part in all_parts:<EOL><INDENT>if isinstance(part, six.string_types):<EOL><INDENT>if asone:<EOL><INDENT>if not curr_parts:<EOL><INDENT>curr_offset += part.count('<STR_LIT:\n>') + <NUM_LIT:1><EOL><DEDENT><DEDENT>else:  <EOL><INDENT>if curr_parts:<EOL><INDENT>example = doctest_from_parts(curr_parts, num, curr_offset)<EOL>yield example<EOL>curr_offset += sum(p.n_lines for p in curr_parts)<EOL>num += <NUM_LIT:1><EOL>curr_parts = []<EOL><DEDENT>curr_offset += part.count('<STR_LIT:\n>') + <NUM_LIT:1><EOL><DEDENT>ignoring = False<EOL><DEDENT>else:<EOL><INDENT>if ignoring or _start_ignoring(prev_part):<EOL><INDENT>ignoring = True<EOL>if asone:<EOL><INDENT>if not curr_parts:<EOL><INDENT>curr_offset += part.n_lines<EOL><DEDENT><DEDENT>else:<EOL><INDENT>curr_offset += part.n_lines<EOL><DEDENT><DEDENT>else:<EOL><INDENT>curr_parts.append(part)<EOL><DEDENT><DEDENT>prev_part = part<EOL><DEDENT>if curr_parts:<EOL><INDENT>example = doctest_from_parts(curr_parts, num, curr_offset)<EOL>yield example<EOL><DEDENT>
Finds free-form doctests in a docstring. This is similar to the original
doctests because these tests do not requires a google/numpy style header.

Some care is taken to avoid enabling tests that look like disabled google
doctests / scripts.

Args:
    asone (bool): if False doctests are broken into multiple examples
       based on spacing. (default True)

    lineno (int): the line number (starting from 1) of the docstring.
        (i.e. if you were to go to this line number in the source file
         the starting quotes of the docstr would be on this line).

Raises:
    xdoctest.exceptions.DoctestParseError: if an error occurs in parsing

CommandLine:
    python -m xdoctest.core parse_freeform_docstr_examples

Example:
    >>> from xdoctest import core
    >>> from xdoctest import utils
    >>> docstr = utils.codeblock(
        '''
        freeform
        >>> doctest
        >>> hasmultilines
        whoppie
        >>> 'butthis is the same doctest'

        >>> secondone

        Script:
            >>> 'special case, dont parse me'

        DisableDoctest:
            >>> 'special case, dont parse me'
            want

        AnythingElse:
            >>> 'general case, parse me'
            want
        ''')
    >>> examples = list(parse_freeform_docstr_examples(docstr, asone=True))
    >>> assert len(examples) == 1
    >>> examples = list(parse_freeform_docstr_examples(docstr, asone=False))
    >>> assert len(examples) == 3