# Buggy code
def run(self):
    # type: () -> List[nodes.Node]
    self.bridge = DocumenterBridge(
        self.env, self.state.document.reporter, Options(), self.lineno, self.state
    )

    names = [
        x.strip().split()[0]
        for x in self.content
        if x.strip() and re.search(r"^[~a-zA-Z_]", x.strip()[0])
    ]
    items = self.get_items(names)
    nodes = self.get_table(items)

    if "toctree" in self.options:
        dirname = posixpath.dirname(self.env.docname)

        tree_prefix = self.options["toctree"].strip()
        docnames = []
        excluded = Matcher(self.config.exclude_patterns)
        for name, sig, summary, real_name in items:
            docname = posixpath.join(tree_prefix, real_name)
            docname = posixpath.normpath(posixpath.join(dirname, docname))
            if docname not in self.env.found_docs:
                if excluded(self.env.doc2path(docname, None)):
                    logger.warning(
                        __("toctree references excluded document %r"), docname
                    )
                else:
                    logger.warning(
                        __("toctree references unknown document %r"), docname
                    )
            docnames.append(docname)

        tocnode = addnodes.toctree()
        tocnode["includefiles"] = docnames
        tocnode["entries"] = [(None, docn) for docn in docnames]
        tocnode["maxdepth"] = -1
        tocnode["glob"] = None

        nodes.append(autosummary_toc("", "", tocnode))

    return nodes


# Traceback (FileNotFoundError)
Traceback (most recent call last):
File "/Users/tkomiya/work/sphinx/sphinx/cmd/build.py", line 284, in build_main
app.build(args.force_all, filenames)
File "/Users/tkomiya/work/sphinx/sphinx/application.py", line 345, in build
self.builder.build_update()
File "/Users/tkomiya/work/sphinx/sphinx/builders/init.py", line 298, in build_update
len(to_build))
File "/Users/tkomiya/work/sphinx/sphinx/builders/init.py", line 314, in build
for docname in self.env.check_dependents(self.app, updated_docnames):
File "/Users/tkomiya/work/sphinx/sphinx/environment/init.py", line 458, in check_dependents
for docnames in self.events.emit('env-get-updated', self):
File "/Users/tkomiya/work/sphinx/sphinx/events.py", line 103, in emit
results.append(callback(self.app, *args))
File "/Users/tkomiya/work/sphinx/sphinx/environment/collectors/toctree.py", line 140, in get_updated_docs
return self.assign_section_numbers(env) + self.assign_figure_numbers(env)
File "/Users/tkomiya/work/sphinx/sphinx/environment/collectors/toctree.py", line 297, in assign_figure_numbers
_walk_doc(env.config.master_doc, tuple())
File "/Users/tkomiya/work/sphinx/sphinx/environment/collectors/toctree.py", line 294, in _walk_doc
_walk_doctree(docname, doctree, secnum)
File "/Users/tkomiya/work/sphinx/sphinx/environment/collectors/toctree.py", line 274, in _walk_doctree
_walk_doctree(docname, subnode, secnum)
File "/Users/tkomiya/work/sphinx/sphinx/environment/collectors/toctree.py", line 287, in _walk_doctree
_walk_doctree(docname, subnode, secnum)
File "/Users/tkomiya/work/sphinx/sphinx/environment/collectors/toctree.py", line 281, in _walk_doctree
_walk_doc(subdocname, secnum)
File "/Users/tkomiya/work/sphinx/sphinx/environment/collectors/toctree.py", line 293, in _walk_doc
doctree = env.get_doctree(docname)
File "/Users/tkomiya/work/sphinx/sphinx/environment/init.py", line 538, in get_doctree
with open(filename, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/tkomiya/work/tmp/doc/_build/doctrees/generated/example.Base.doctree'

**Expected behavior**
Build successfully (with warning)

**Your project**
None

**Screenshots**
None

**Environment info**
- OS: Mac
- Python version: 3.7.3
- Sphinx version: 2.1.1
- Sphinx extensions: sphinx.ext.autosummary

# Fixed code
def run(self):
    # type: () -> List[nodes.Node]
    self.bridge = DocumenterBridge(
        self.env, self.state.document.reporter, Options(), self.lineno, self.state
    )

    names = [
        x.strip().split()[0]
        for x in self.content
        if x.strip() and re.search(r"^[~a-zA-Z_]", x.strip()[0])
    ]
    items = self.get_items(names)
    nodes = self.get_table(items)

    if "toctree" in self.options:
        dirname = posixpath.dirname(self.env.docname)

        tree_prefix = self.options["toctree"].strip()
        docnames = []
        excluded = Matcher(self.config.exclude_patterns)
        for name, sig, summary, real_name in items:
            docname = posixpath.join(tree_prefix, real_name)
            docname = posixpath.normpath(posixpath.join(dirname, docname))
            if docname not in self.env.found_docs:
                location = self.state_machine.get_source_and_line(self.lineno)
                if excluded(self.env.doc2path(docname, None)):
                    msg = __("autosummary references excluded document %r. Ignored.")
                else:
                    msg = __(
                        "autosummary: stub file not found %r. "
                        "Check your autosummary_generate setting."
                    )

                logger.warning(msg, real_name, location=location)
                continue

            docnames.append(docname)

        if docnames:
            tocnode = addnodes.toctree()
            tocnode["includefiles"] = docnames
            tocnode["entries"] = [(None, docn) for docn in docnames]
            tocnode["maxdepth"] = -1
            tocnode["glob"] = None

            nodes.append(autosummary_toc("", "", tocnode))

    return nodes