class_docstr: Interfaces the rendering environment of jinja2 for use in Sphinx.
class_docstr_tok: ["Interfaces","the","rendering","environment","of","jinja2","for","use","in","Sphinx","."]
code: def init(
      self,
      builder: Builder,
      theme: Theme | None = None,
      dirs: list[str] | None = None,
  ) -> None:
      # create a chain of paths to search
      if theme:
          # the theme's own dir and its bases' dirs
          pathchain = theme.get_theme_dirs()
          # the loader dirs: pathchain + the parent directories for all themes
          loaderchain = pathchain + [
              path.join(p, "..") for p in pathchain
          ]
      elif dirs:
          pathchain = list(dirs)
          loaderchain = list(dirs)
      else:
          pathchain = []
          loaderchain = []
  
      # prepend explicit template paths
      self.templatepathlen = len(builder.config.templates_path)
      if builder.config.templates_path:
          cfg_templates_path = [
              path.join(builder.confdir, tp)
              for tp in builder.config.templates_path
          ]
          pathchain[0:0] = cfg_templates_path
          loaderchain[0:0] = cfg_templates_path
  
      # store it for use in newest_template_mtime
      self.pathchain = pathchain
  
      # make the paths into loaders
      self.loaders = [SphinxFileSystemLoader(x) for x in loaderchain]
  
      use_i18n = builder.app.translator is not None
      extensions = ["jinja2.ext.i18n"] if use_i18n else []
      self.environment = SandboxedEnvironment(
          loader=self, extensions=extensions
      )
      self.environment.filters["tobool"] = _tobool
      self.environment.filters["toint"] = _toint
      self.environment.filters["todim"] = _todim
      self.environment.filters["slice_index"] = _slice_index
      self.environment.globals["debug"] = pass_context(pformat)
      self.environment.globals["warning"] = warning
      self.environment.globals["accesskey"] = pass_context(accesskey)
      self.environment.globals["idgen"] = idgen
      if use_i18n:
          self.environment.install_gettext_translations(
              builder.app.translator
          )
  
imports: from __future__ import annotations
  from os import path
  from pprint import pformat
  from typing import TYPE_CHECKING, Any, Callable
  from jinja2 import BaseLoader, FileSystemLoader, TemplateNotFound
  from jinja2.sandbox import SandboxedEnvironment
  from jinja2.utils import open_if_exists
  from sphinx.application import TemplateBridge
  from sphinx.util import logging
  from sphinx.util.osutil import mtimes_of_files
label_desc: Use image node_id 1 for calling the BuiltinTemplateLoader obj's underlying member method code with example usage: obj.init(builder, theme, dirs) without return types