docstr: Load a Sphinx extension.
code: def load_extension(self, app: Sphinx, extname: str) -> None:
      """Load a Sphinx extension."""
      if extname in app.extensions:  # already loaded
          return
      if extname in EXTENSION_BLACKLIST:
          logger.warning(
              __(
                  "the extension %r was already merged with Sphinx since "
                  "version %s; this extension is ignored."
              ),
              extname,
              EXTENSION_BLACKLIST[extname],
          )
          return
  
      # update loading context
      prefix = __("while setting up extension %s:") % extname
      with prefixed_warnings(prefix):
          try:
              mod = import_module(extname)
          except ImportError as err:
              logger.verbose(
                  __("Original exception:\n") + traceback.format_exc()
              )
              raise ExtensionError(
                  __("Could not import extension %s") % extname, err
              ) from err
  
          setup: _ExtensionSetupFunc | None = getattr(
              mod, "setup", None
          )
          if setup is None:
              logger.warning(
                  __(
                      "extension %r has no setup() function; is it really "
                      "a Sphinx extension module?"
                  ),
                  extname,
              )
              metadata: _ExtensionMetadata = {}
          else:
              try:
                  metadata = setup(app)
              except VersionRequirementError as err:
                  # add the extension name to the version required
                  raise VersionRequirementError(
                      __(
                          "The %s extension used by this project needs at least "
                          "Sphinx v%s; it therefore cannot be built with this "
                          "version."
                      )
                      % (extname, err),
                  ) from err
  
          if metadata is None:
              metadata = {}
          elif not isinstance(metadata, dict):
              logger.warning(
                  __(
                      "extension %r returned an unsupported object from "
                      "its setup() function; it should return None or a "
                      "metadata dictionary"
                  ),
                  extname,
              )
              metadata = {}
  
          app.extensions[extname] = Extension(extname, mod, **metadata)
  
imports: from __future__ import annotations
  import sys
  import traceback
  from importlib import import_module
  from types import MethodType
  from typing import TYPE_CHECKING, Any, Callable
  from sphinx.domains import Domain, Index, ObjType
  from sphinx.domains.std import GenericObject, Target
  from sphinx.errors import ExtensionError, SphinxError, VersionRequirementError
  from sphinx.extension import Extension
  from sphinx.io import create_publisher
  from sphinx.locale import __
  from sphinx.parsers import Parser
  from sphinx.roles import XRefRole
  from sphinx.util import logging
  from sphinx.util.logging import prefixed_warnings
label_desc: Use image node_id 35 for calling the SphinxComponentRegistry obj's underlying member method code with example usage: obj.load_extension(app, extname) without return types