def _one_ref()

in tools/tensorflow_docs/api_generator/reference_resolver.py [0:0]


  def _one_ref(self, match, full_name=None):
    """Return a link for a single "`tf.symbol`" reference."""

    if match.group(1):
      # Found a '[]' group, return it unmodified.
      return match.group('brackets')

    # Found a '``' group.
    string = match.group('backticks')

    link_text = string

    # Drop everything after the *last* ( or [ to get the
    # symbol name. The last is used so complex nested or chained calls are not
    # recognized as valid links.
    string = re.sub(r'^(.*)[\(\[].*', r'\1', string)
    # Drop the optional leading `@`.
    string = re.sub(r'^@', r'', string)

    if string.startswith('compat.v1') or string.startswith('compat.v2'):
      string = 'tf.' + string
    elif string.startswith('v1') or string.startswith('v2'):
      string = 'tf.compat.' + string

    elif full_name is None or ('tf.compat.v' not in full_name and
                               'tf.contrib' not in full_name):
      string = self._partial_symbols_dict.get(string, string)

    try:
      if string.startswith('tensorflow::'):
        # C++ symbol
        return self._cc_link(string, link_text)

      return self.python_link(link_text, string)
    except TFDocsError:
      pass

    return match.group(0)