code: def build_finished(app, exception):
      """Generate a ``sitemap.txt`` from the collected HTML page links."""
      filename = join(app.outdir, "sitemap.xml")
  
      links_iter = status_iterator(
          sorted(app.sitemap_links),
          "adding links to sitemap... ",
          "brown",
          len(app.sitemap_links),
          app.verbosity,
      )
  
      try:
          with open(filename, "w") as f:
              f.write(_header)
              for link in links_iter:
                  http_link = escape(
                      link.strip().replace("https://", "http://")
                  )
                  f.write(_item.format(link=http_link))
              f.write(_footer)
      except OSError as e:
          raise SphinxError(f"cannot write sitemap.txt, reason: {e}")
  
file_path: bokeh/src/bokeh/sphinxext/bokeh_sitemap.py
imports: from __future__ import annotations
  import logging
  from html import escape
  from os.path import join
  from sphinx.errors import SphinxError
  from sphinx.util.display import status_iterator
  from .None import PARALLEL_SAFE
label_desc: Use image node_id 2 for calling a global function with example usage: build_finished(app, exception) without return types