code: def app_params(
      request: Any,
      test_params: dict,
      shared_result: SharedResult,
      sphinx_test_tempdir: str,
      rootdir: str,
  ) -> _app_params:
      """
      Parameters that are specified by 'pytest.mark.sphinx' for
      sphinx.application.Sphinx initialization
      """
      # ##### process pytest.mark.sphinx
  
      pargs: dict[int, Any] = {}
      kwargs: dict[str, Any] = {}
  
      # to avoid stacking positional args
      for info in reversed(list(request.node.iter_markers("sphinx"))):
          pargs |= dict(enumerate(info.args))
          kwargs.update(info.kwargs)
  
      args = [pargs[i] for i in sorted(pargs.keys())]
  
      # ##### process pytest.mark.test_params
      if test_params["shared_result"]:
          if "srcdir" in kwargs:
              msg = "You can not specify shared_result and srcdir in same time."
              raise pytest.Exception(msg)
          kwargs["srcdir"] = test_params["shared_result"]
          restore = shared_result.restore(test_params["shared_result"])
          kwargs.update(restore)
  
      # ##### prepare Application params
  
      testroot = kwargs.pop("testroot", "root")
      kwargs["srcdir"] = srcdir = sphinx_test_tempdir / kwargs.get(
          "srcdir", testroot
      )
  
      # special support for sphinx/tests
      if rootdir and not srcdir.exists():
          testroot_path = rootdir / ("test-" + testroot)
          shutil.copytree(testroot_path, srcdir)
  
      return _app_params(args, kwargs)
  
imports: from __future__ import annotations
  import shutil
  import subprocess
  import sys
  from collections import namedtuple
  from io import StringIO
  from typing import TYPE_CHECKING, Any, Callable
  import pytest
  from sphinx.testing.util import SphinxTestApp, SphinxTestAppWrapperForSkipBuilding
label_desc: Use image node_id 3 for calling a global function with example usage: app_params(request, test_params, shared_result, sphinx_test_tempdir, rootdir) and returns: _app_params