'Implements an enhanced version of the doctest module from py.test
(specifically, as enabled by the --doctest-modules option) which
supports skipping all doctests in a specific docstring by way of a
special ``__doctest_skip__`` module-level variable.  It can also skip
tests that have special requirements by way of
``__doctest_requires__``.
``__doctest_skip__`` should be a list of functions, classes, or class
methods whose docstrings should be ignored when collecting doctests.
This also supports wildcard patterns.  For example, to run doctests in
a class\'s docstring, but skip all doctests in its modules use, at the
module level::
__doctest_skip__ = [\'ClassName.*\']
You may also use the string ``\'.\'`` in ``__doctest_skip__`` to refer
to the module itself, in case its module-level docstring contains
doctests.
``__doctest_requires__`` should be a dictionary mapping wildcard
patterns (in the same format as ``__doctest_skip__``) to a list of one
or more modules that should be *importable* in order for the tests to
run.  For example, if some tests require the scipy module to work they
will be skipped unless ``import scipy`` is possible.  It is also
possible to use a tuple of wildcard patterns as a key in this dict::
__doctest_requires__ = {(\'func1\', \'func2\'): [\'scipy\']}'

def pytest_collect_file(self, path, parent):

    for ignore_path in self._ignore_paths:
        if (ignore_path.common(path) == ignore_path):
            return None
    if (path.ext == u'.py'):
        if (path.basename == u'conf.py'):
            return None
        return self._doctest_module_item_cls(path, parent)
    elif (self._run_rst_doctests and (path.ext == u'.rst')):
        parts = str(path).split(os.path.sep)
        if (path.basename.startswith(u'_') or any((x.startswith(u'_') for x in parts)) or any(((x == u'api') for x in parts))):
            return None
        return self._doctest_textfile_item_cls(path, parent)
