code: def fmt_tag(cur_namespace, tag, val):
      
      if tag == 'type':
          fq_val = val
          if '.' not in val and cur_namespace is not None:
              fq_val = cur_namespace.name + '.' + fq_val
          return fq_val
      elif tag == 'route':
          if ':' in val:
              val, version = val.split(':', 1)
              version = int(version)
          else:
              version = 1
          return fmt_func(val, version) + "()"
      elif tag == 'link':
          anchor, link = val.rsplit(' ', 1)
          # There's no way to have links in TSDoc, so simply use JSDoc's formatting.
          # It's entirely possible some editors support this.
          return '[%s]{@link %s}' % (anchor, link)
      elif tag == 'val':
          # Value types seem to match JavaScript (true, false, null)
          return val
      elif tag == 'field':
          return val
      else:
          raise RuntimeError('Unknown doc ref tag %r' % tag)
docs: Processes a documentation reference.