code: def add_crossref_type(
      self,
      directivename: str,
      rolename: str,
      indextemplate: str = "",
      ref_nodeclass: type[TextElement] | None = None,
      objname: str = "",
      override: bool = False,
  ) -> None:
      logger.debug(
          "[app] adding crossref type: %r",
          (
              directivename,
              rolename,
              indextemplate,
              ref_nodeclass,
              objname,
          ),
      )
  
      # create a subclass of Target as the new directive
      directive = type(
          directivename,
          (Target, object),
          {"indextemplate": indextemplate},
      )
  
      self.add_directive_to_domain("std", directivename, directive)
      self.add_role_to_domain(
          "std", rolename, XRefRole(innernodeclass=ref_nodeclass)
      )
  
      object_types = self.domain_object_types.setdefault("std", {})
      if directivename in object_types and not override:
          raise ExtensionError(
              __("The %r crossref_type is already registered")
              % directivename
          )
      object_types[directivename] = ObjType(
          objname or directivename, rolename
      )
  
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 12 for calling the SphinxComponentRegistry obj's underlying member method code with example usage: obj.add_crossref_type(directivename, rolename, indextemplate, ref_nodeclass, objname, override) without return types