parameters: (pattern)
return_statement: return role
docstring: Defines the role function
  
      Args:
          pattern (str): This argument represents the input pattern of the role which is just a string (%s).
  
      Returns:
          function: Returns the defined role function.
docstring_summary: Defines the role function
docstring_tokens: Defines the role function
function: def version_role(pattern):
      """ Defines the role function
  
      Args:
          pattern (str): This argument represents the input pattern of the role which is just a string (%s).
  
      Returns:
          function: Returns the defined role function.
      """
  
      def role(name, rawtext, text, lineno, inliner, options={}, content=[]):
          """ Actual role implementation.
  
          Args:
              Refer to https://docutils.sourceforge.io/docs/howto/rst-roles.html for an overview.
  
          Returns:
              node.Text: Returns the node which contains the version number for a specific key (e.g. package).
          """
  
          package_level = pattern % text
          payload = package_level.split(',')
          package = payload[0]
  
          if len(payload) > 1:
              level = payload[1]
          else:
              level = "min"
  
          with open(str(doc_build_dir) + '/_ext/versions.json') as fp:
              data = json.load(fp)
  
          try:
              version = data[package.strip()][level.strip()]
          except KeyError as e:
              version = f"'{level}' was not found!"
  
          node = nodes.Text(version)
          return [node], []
      return role
function_tokens: def version_role ( pattern ) : def role ( name , rawtext , text , lineno , inliner , options = { } , content = [ ] ) : """ Actual role implementation.
  
          Args:
              Refer to https://docutils.sourceforge.io/docs/howto/rst-roles.html for an overview.
  
          Returns:
              node.Text: Returns the node which contains the version number for a specific key (e.g. package).
          """ package_level = pattern % text payload = package_level . split ( ',' ) package = payload [ 0 ] if len ( payload ) > 1 : level = payload [ 1 ] else : level = "min" with open ( str ( doc_build_dir ) + '/_ext/versions.json' ) as fp : data = json . load ( fp ) try : version = data [ package . strip ( ) ] [ level . strip ( ) ] except KeyError as e : version = f"'{level}' was not found!" node = nodes . Text ( version ) return [ node ] , [ ] return role