code: def make_link_role(
      name: str, base_url: str, caption: str
  ) -> RoleFunction:
      # Check whether we have base_url and caption strings have an '%s' for
      # expansion.  If not, fall back the the old behaviour and use the string as
      # a prefix.
      # Remark: It is an implementation detail that we use Pythons %-formatting.
      # So far we only expose ``%s`` and require quoting of ``%`` using ``%%``.
      def role(
          typ: str,
          rawtext: str,
          text: str,
          lineno: int,
          inliner: Inliner,
          options: dict | None = None,
          content: Sequence[str] = (),
      ) -> tuple[list[Node], list[system_message]]:
          text = utils.unescape(text)
          has_explicit_title, title, part = split_explicit_title(text)
          full_url = base_url % part
          if not has_explicit_title:
              if caption is None:
                  title = full_url
              else:
                  title = caption % part
          pnode = nodes.reference(
              title, title, internal=False, refuri=full_url
          )
          return [pnode], []
  
      return role
  
file_path: sphinx/sphinx/ext/extlinks.py
imports: from __future__ import annotations
  import re
  from typing import TYPE_CHECKING, Any
  from docutils import nodes, utils
  import sphinx
  from sphinx.locale import __
  from sphinx.transforms.post_transforms import SphinxPostTransform
  from sphinx.util import logging, rst
  from sphinx.util.nodes import split_explicit_title
label_desc: Use image node_id 1 for calling a global function with example usage: make_link_role(name, base_url, caption) and returns: role, list,  list