class_docstr: Builds target formats from the reST sources.
class_docstr_tok: ["Builds","target","formats","from","the","reST","sources","."]
docstr: Write the doctree to a file.
code: def write_doctree(
      self,
      docname: str,
      doctree: nodes.document,
      *,
      _cache: bool = True,
  ) -> None:
      """Write the doctree to a file."""
      # make it picklable
      doctree.reporter = None  # type: ignore[assignment]
      doctree.transformer = None  # type: ignore[assignment]
  
      # Create a copy of settings object before modification because it is
      # shared with other documents.
      doctree.settings = doctree.settings.copy()
      doctree.settings.warning_stream = None
      doctree.settings.env = None
      doctree.settings.record_dependencies = None  # type: ignore[assignment]
  
      doctree_filename = path.join(
          self.doctreedir, docname + ".doctree"
      )
      ensuredir(path.dirname(doctree_filename))
      with open(doctree_filename, "wb") as f:
          pickle.dump(doctree, f, pickle.HIGHEST_PROTOCOL)
  
      # When Sphinx is running in parallel mode, ``write_doctree()`` is invoked
      # in the context of a process worker, and thus it does not make sense to
      # pickle the doctree and send it to the main process
      if _cache:
          self.env._write_doc_doctree_cache[docname] = doctree
  
imports: from __future__ import annotations
  import codecs
  import pickle
  import time
  from os import path
  from typing import TYPE_CHECKING, Any
  from docutils import nodes
  from docutils.utils import DependencyList
  from sphinx.environment import CONFIG_CHANGED_REASON, CONFIG_OK, BuildEnvironment
  from sphinx.environment.adapters.asset import ImageAdapter
  from sphinx.errors import SphinxError
  from sphinx.locale import __
  from sphinx.util import UnicodeDecodeErrorHandler, get_filetype, import_object, logging, rst
  from sphinx.util.build_phase import BuildPhase
  from sphinx.util.console import bold
  from sphinx.util.display import progress_message, status_iterator
  from sphinx.util.docutils import sphinx_domains
  from sphinx.util.i18n import CatalogInfo, CatalogRepository, docname_to_domain
  from sphinx.util.osutil import SEP, ensuredir, relative_uri, relpath
  from sphinx.util.parallel import ParallelTasks, SerialTasks, make_chunks, parallel_available
  from sphinx import directives
  from sphinx import roles
label_desc: Use image node_id 23 for calling the Builder obj's underlying member method code with example usage: obj.write_doctree(docname, doctree) without return types