code: def substitute_url_with_ref(self, txt):
          
  
          # Find links
          mi = re.finditer(r'\[([^\]]+|\[[^\]]+\])\]\(([^\)]+)\)', txt)
          if mi:
              # Iterate over match objects in iterator returned by
              # re.finditer
              for mo in mi:
                  # Get components of current match: full matching text,
                  # the link label, and the postfix to the base url in the
                  # link url
                  mtxt = mo.group(0)
                  lbl = mo.group(1)
                  url = mo.group(2)
  
                  # Try to look up the current link url. Issue a warning if
                  # the lookup fails, and do the substitution if it succeeds.
                  try:
                      ref = self.get_sphinx_ref(url, lbl)
                  except KeyError as ex:
                      print('Warning: %s' % ex.args[0])
                  else:
                      txt = re.sub(re.escape(mtxt), ref, txt)
  
          return txt
docs: In the string `txt`, replace links to online docs with
          corresponding sphinx cross-references.