Search the initial and parent directories for a ``conf.py`` Sphinx
    configuration file that represents the root of a Sphinx project.

    Returns
    -------
    root_dir : `pathlib.Path`
        Directory path containing a ``conf.py`` file.

    Raises
    ------
    FileNotFoundError
        Raised if a ``conf.py`` file is not found in the initial directory
        or any parents.

def _search_parents(initial_dir):
    """Search the initial and parent directories for a ``conf.py`` Sphinx
    configuration file that represents the root of a Sphinx project.

    Returns
    -------
    root_dir : `pathlib.Path`
        Directory path containing a ``conf.py`` file.

    Raises
    ------
    FileNotFoundError
        Raised if a ``conf.py`` file is not found in the initial directory
        or any parents.
    """
    root_paths = ('.', '/')
    parent = pathlib.Path(initial_dir)
    while True:
        if _has_conf_py(parent):
            return parent
        if str(parent) in root_paths:
            break
        parent = parent.parent
    msg = (
        "Cannot detect a conf.py Sphinx configuration file from {!s}. "
        "Are you inside a Sphinx documenation repository?"
    ).format(initial_dir)
    raise FileNotFoundError(msg)