code: def _setup_autodoc(app):
      from sphinx.ext import autodoc
      from sphinx.ext import autosummary
      from sphinx.util import typing
      from sphinx.locale import _
  
      #
  
      class ClassDocumenterMixin:
          def __init__(self, *args, **kwargs):
              super().__init__(*args, **kwargs)
              if self.config.autodoc_class_signature == "separated":
                  members = self.options.members
                  special_members = self.options.special_members
                  if special_members is not None:
                      for name in ("__new__", "__init__"):
                          if name in members:
                              members.remove(name)
                          if name in special_members:
                              special_members.remove(name)
  
      class ClassDocumenter(
          ClassDocumenterMixin,
          autodoc.ClassDocumenter,
      ):
          pass
  
      class ExceptionDocumenter(
          ClassDocumenterMixin,
          autodoc.ExceptionDocumenter,
      ):
          pass
  
      app.add_autodocumenter(ClassDocumenter, override=True)
      app.add_autodocumenter(ExceptionDocumenter, override=True)
  
      #
  
      def istypealias(obj):
          if isinstance(obj, type):
              return True
          return obj in (typing.Any,)
  
      class TypeDocumenter(autodoc.DataDocumenter):
          objtype = "type"
          directivetype = "data"
          priority = autodoc.ClassDocumenter.priority + 1
  
          @classmethod
          def can_document_member(
              cls, member, membername, isattr, parent
          ):
              return (
                  isinstance(parent, autodoc.ModuleDocumenter)
                  and parent.name == "mpi4py.typing"
                  and istypealias(member)
              )
  
          def update_content(self, more_content):
              if istypealias(self.object):
                  more_content.append(
                      _("alias of %s") % typing.restify(self.object), ""
                  )
                  more_content.append("", "")
              super().update_content(more_content)
  
      app.add_autodocumenter(TypeDocumenter)
  
      #
  
      class ExceptionDocumenterCustom(ExceptionDocumenter):
          objtype = "class"
  
      def get_documenter(app, obj, parent):
          if isinstance(obj, type) and issubclass(obj, BaseException):
              caller = sys._getframe().f_back.f_code.co_name
              if caller == "generate_autosummary_content":
                  if obj.__module__ == "mpi4py.MPI":
                      if obj.__name__ == "Exception":
                          return ExceptionDocumenterCustom
          return autosummary.get_documenter(app, obj, parent)
  
      from sphinx.ext.autosummary import generate
  
      generate.get_documenter = get_documenter
  
file_path: mpi4py/docs/source/conf.py
imports: import os
  import sys
  import typing
  import datetime
  import importlib
label_desc: Use image node_id 4 for calling a global function with example usage: _setup_autodoc(app) and returns: unknown, autosummary, True, unknown, ExceptionDocumenterCustom