from pathlib import Path


def find_source_dir_from_file(filepath: Path):
    """Find the source directory of the Sphinx project."""
    conf_file = Path("conf.py")
    source_dir = filepath.parent
    root = Path("/")
    while source_dir != root:
        path = source_dir / conf_file
        if path.exists():
            return source_dir
        source_dir = source_dir.parent
    return None