# Buggy code
def process_generate_options(app):
    # type: (Sphinx) -> None
    genfiles = app.config.autosummary_generate

    if genfiles and not hasattr(genfiles, "__len__"):
        env = app.builder.env
        genfiles = [
            env.doc2path(x, base=None)
            for x in env.found_docs
            if os.path.isfile(env.doc2path(x))
        ]

    if not genfiles:
        return

    from sphinx.ext.autosummary.generate import generate_autosummary_docs

    ext = list(app.config.source_suffix)
    genfiles = [
        genfile + (not genfile.endswith(tuple(ext)) and ext[0] or "")
        for genfile in genfiles
    ]

    suffix = get_rst_suffix(app)
    if suffix is None:
        logger.warning(
            __(
                "autosummary generats .rst files internally. "
                "But your source_suffix does not contain .rst. Skipped."
            )
        )
        return

    imported_members = app.config.autosummary_imported_members
    with mock(app.config.autosummary_mock_imports):
        generate_autosummary_docs(
            genfiles,
            builder=app.builder,
            suffix=suffix,
            base_path=app.srcdir,
            app=app,
            imported_members=imported_members,
        )


# Traceback (FileNotFoundError)
# Loaded extensions:
Traceback (most recent call last):
File "/Users/tkomiya/work/sphinx/sphinx/cmd/build.py", line 283, in build_main
args.tags, args.verbosity, args.jobs, args.keep_going)
File "/Users/tkomiya/work/sphinx/sphinx/application.py", line 268, in __init__
self._init_builder()
File "/Users/tkomiya/work/sphinx/sphinx/application.py", line 329, in _init_builder
self.events.emit('builder-inited')
File "/Users/tkomiya/work/sphinx/sphinx/events.py", line 103, in emit
results.append(callback(self.app, *args))
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/__init__.py", line 758, in process_generate_options
app=app, imported_members=imported_members)
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 168, in generate_autosummary_docs
items = find_autosummary_in_files(sources)
File "/Users/tkomiya/work/sphinx/sphinx/ext/autosummary/generate.py", line 279, in find_autosummary_in_files
with open(filename, encoding='utf-8', errors='ignore') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/tkomiya/work/tmp/doc/foo.rst'

# Fixed code
def process_generate_options(app):
    # type: (Sphinx) -> None
    genfiles = app.config.autosummary_generate

    if genfiles is True:
        env = app.builder.env
        genfiles = [
            env.doc2path(x, base=None)
            for x in env.found_docs
            if os.path.isfile(env.doc2path(x))
        ]
    else:
        ext = list(app.config.source_suffix)
        genfiles = [
            genfile + (not genfile.endswith(tuple(ext)) and ext[0] or "")
            for genfile in genfiles
        ]

        for entry in genfiles[:]:
            if not path.isfile(path.join(app.srcdir, entry)):
                logger.warning(__("autosummary_generate: file not found: %s"), entry)
                genfiles.remove(entry)

    if not genfiles:
        return

    suffix = get_rst_suffix(app)
    if suffix is None:
        logger.warning(
            __(
                "autosummary generats .rst files internally. "
                "But your source_suffix does not contain .rst. Skipped."
            )
        )
        return

    from sphinx.ext.autosummary.generate import generate_autosummary_docs

    imported_members = app.config.autosummary_imported_members
    with mock(app.config.autosummary_mock_imports):
        generate_autosummary_docs(
            genfiles,
            builder=app.builder,
            suffix=suffix,
            base_path=app.srcdir,
            app=app,
            imported_members=imported_members,
        )