code: def generate(
      d: dict,
      overwrite: bool = True,
      silent: bool = False,
      templatedir: str | None = None,
  ) -> None:
      """Generate project based on values in *d*."""
      template = QuickstartRenderer(templatedir or "")
  
      if "mastertoctree" not in d:
          d["mastertoctree"] = ""
      if "mastertocmaxdepth" not in d:
          d["mastertocmaxdepth"] = 2
  
      d["root_doc"] = d["master"]
      d["now"] = time.asctime()
      d["project_underline"] = column_width(d["project"]) * "="
      d.setdefault("extensions", [])
      d["copyright"] = time.strftime("%Y") + ", " + d["author"]
  
      d["path"] = os.path.abspath(d["path"])
      ensuredir(d["path"])
  
      srcdir = path.join(d["path"], "source") if d["sep"] else d["path"]
  
      ensuredir(srcdir)
      if d["sep"]:
          builddir = path.join(d["path"], "build")
          d["exclude_patterns"] = ""
      else:
          builddir = path.join(srcdir, d["dot"] + "build")
          exclude_patterns = map(
              repr,
              [
                  d["dot"] + "build",
                  "Thumbs.db",
                  ".DS_Store",
              ],
          )
          d["exclude_patterns"] = ", ".join(exclude_patterns)
      ensuredir(builddir)
      ensuredir(path.join(srcdir, d["dot"] + "templates"))
      ensuredir(path.join(srcdir, d["dot"] + "static"))
  
      def write_file(
          fpath: str, content: str, newline: str | None = None
      ) -> None:
          if overwrite or not path.isfile(fpath):
              if "quiet" not in d:
                  print(__("Creating file %s.") % fpath)
              with open(
                  fpath, "w", encoding="utf-8", newline=newline
              ) as f:
                  f.write(content)
          else:
              if "quiet" not in d:
                  print(__("File %s already exists, skipping.") % fpath)
  
      conf_path = (
          os.path.join(templatedir, "conf.py_t")
          if templatedir
          else None
      )
      if not conf_path or not path.isfile(conf_path):
          conf_path = os.path.join(
              package_dir, "templates", "quickstart", "conf.py_t"
          )
      with open(conf_path, encoding="utf-8") as f:
          conf_text = f.read()
  
      write_file(
          path.join(srcdir, "conf.py"),
          template.render_string(conf_text, d),
      )
  
      masterfile = path.join(srcdir, d["master"] + d["suffix"])
      if template._has_custom_template("quickstart/master_doc.rst_t"):
          msg = (
              "A custom template `master_doc.rst_t` found. It has been renamed to "
              "`root_doc.rst_t`.  Please rename it on your project too."
          )
          print(colorize("red", msg))
          write_file(
              masterfile,
              template.render("quickstart/master_doc.rst_t", d),
          )
      else:
          write_file(
              masterfile,
              template.render("quickstart/root_doc.rst_t", d),
          )
  
      if d.get("make_mode"):
          makefile_template = "quickstart/Makefile.new_t"
          batchfile_template = "quickstart/make.bat.new_t"
      else:
          # xref RemovedInSphinx80Warning
          msg = "Support for '--no-use-make-mode' will be removed in Sphinx 8."
          print(colorize("red", msg))
          makefile_template = "quickstart/Makefile_t"
          batchfile_template = "quickstart/make.bat_t"
  
      if d["makefile"] is True:
          d["rsrcdir"] = "source" if d["sep"] else "."
          d["rbuilddir"] = "build" if d["sep"] else d["dot"] + "build"
          # use binary mode, to avoid writing \r\n on Windows
          write_file(
              path.join(d["path"], "Makefile"),
              template.render(makefile_template, d),
              "\n",
          )
  
      if d["batchfile"] is True:
          d["rsrcdir"] = "source" if d["sep"] else "."
          d["rbuilddir"] = "build" if d["sep"] else d["dot"] + "build"
          write_file(
              path.join(d["path"], "make.bat"),
              template.render(batchfile_template, d),
              "\r\n",
          )
  
      if silent:
          return
      print()
      print(
          bold(
              __(
                  "Finished: An initial directory structure has been created."
              )
          )
      )
      print()
      print(
          __(
              "You should now populate your master file %s and create other documentation\n"
              "source files. "
          )
          % masterfile,
          end="",
      )
      if d["makefile"] or d["batchfile"]:
          print(
              __(
                  "Use the Makefile to build the docs, like so:\n"
                  "   make builder"
              )
          )
      else:
          print(
              __(
                  "Use the sphinx-build command to build the docs, like so:\n"
                  "   sphinx-build -b builder %s %s"
              )
              % (srcdir, builddir)
          )
      print(
          __(
              'where "builder" is one of the supported builders, '
              "e.g. html, latex or linkcheck."
          )
      )
      print()
      if not d.get("make_mode"):
          # xref RemovedInSphinx80Warning
          msg = "Support for '--no-use-make-mode' will be removed in Sphinx 8."
          print(colorize("red", msg))
  
imports: from __future__ import annotations
  import argparse
  import locale
  import os
  import sys
  import time
  from os import path
  from typing import TYPE_CHECKING, Any, Callable
  from docutils.utils import column_width
  import sphinx.locale
  from sphinx import __display_version__, package_dir
  from sphinx.locale import __
  from sphinx.util.console import bold, color_terminal, colorize, nocolor, red
  from sphinx.util.osutil import ensuredir
  from sphinx.util.template import SphinxRenderer
label_desc: Use image node_id 12 for calling a global function with example usage: generate(d, overwrite, silent, templatedir) without return types