com.sun.javadoc.Tag.name()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中com.sun.javadoc.Tag.name()方法的一些代码示例,展示了Tag.name()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tag.name()方法的具体详情如下:
包路径:com.sun.javadoc.Tag
类名称:Tag
方法名:name

Tag.name介绍

[英]Return the name of this tag. The name is the string starting with "@" that is used in a doc comment, such as @return. For inline tags, such as {@link}, the curly brackets are not part of the name, so in this example the name would be simply @link.
[中]返回此标记的名称。名称是文档注释中使用的以“@”开头的字符串,例如[$0$]。对于内联标记,例如{@link},花括号不是名称的一部分,因此在本例中,名称只是@link

代码示例

代码示例来源:origin: jersey/jersey

private static Map<String, List<Tag>> getResponseRepresentationTags(final MethodDoc methodDoc) {
  final Map<String, List<Tag>> tagsByStatus = new HashMap<>();
  for (final Tag tag : methodDoc.tags()) {
    final Matcher matcher = PATTERN_RESPONSE_REPRESENTATION.matcher(tag.name());
    if (matcher.matches()) {
      final String status = matcher.group(1);
      List<Tag> tags = tagsByStatus.get(status);
      if (tags == null) {
        tags = new ArrayList<>();
        tagsByStatus.put(status, tags);
      }
      tags.add(tag);
    }
  }
  return tagsByStatus;
}

代码示例来源:origin: jersey/jersey

static String toCSV(final Collection<Tag> items, final String separator, final String delimiter) {
  if (items == null) {
    return null;
  }
  if (items.isEmpty()) {
    return "";
  }
  final StringBuilder sb = new StringBuilder();
  for (final Iterator<Tag> iter = items.iterator(); iter.hasNext(); ) {
    if (delimiter != null) {
      sb.append(delimiter);
    }
    final Tag item = iter.next();
    sb.append(item.name());
    if (delimiter != null) {
      sb.append(delimiter);
    }
    if (iter.hasNext()) {
      sb.append(separator);
    }
  }
  return sb.toString();
}

代码示例来源:origin: jersey/jersey

private static String print(final Tag tag) {
  return String.valueOf(tag.getClass()) + "["
      + "firstSentenceTags=" + toCSV(tag.firstSentenceTags())
      + ", inlineTags=" + toCSV(tag.inlineTags())
      + ", kind=" + tag.kind()
      + ", name=" + tag.name()
      + ", text=" + tag.text()
      + "]";
}

代码示例来源:origin: jersey/jersey

LOG.fine("Have inline tag: " + print(inlineTag));
if ("@link".equals(inlineTag.name())) {
  if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Have link: " + print(inlineTag));

代码示例来源:origin: jersey/jersey

final String tagName = inlineTag.name();
  final String tagText = inlineTag.text();
representationDoc.setStatus(Long.valueOf(entry.getKey()));
for (final Tag tag : entry.getValue()) {
  if (tag.name().endsWith(".qname")) {
    representationDoc.setElement(QName.valueOf(tag.text()));
  } else if (tag.name().endsWith(".mediaType")) {
    representationDoc.setMediaType(tag.text());
  } else if (tag.name().endsWith(".example")) {
    representationDoc.setExample(getSerializedExample(tag));
  } else if (tag.name().endsWith(".doc")) {
    representationDoc.setDoc(tag.text());
  } else {
    LOG.warning("Unknown response representation tag " + tag.name());

代码示例来源:origin: com.atlassian.swagger/atlassian-swagger-doclet

private boolean endsWithIgnoreCase(Tag tag, String s) {
    return tag.name().toUpperCase().endsWith(s.toUpperCase());
  }
}

代码示例来源:origin: com.atlassian.swagger/atlassian-swagger-doclet

private static Optional<String> getVersionedOperationCommentText(Tag[] tags, String dialect) {
  String versionedDescriptionTag = "@description." + dialect;
  return Arrays.stream(tags)
      .filter(tag -> versionedDescriptionTag.equals(tag.name()))
      .findFirst()
      .map(Tag::text);
}

代码示例来源:origin: com.atlassian.swagger/atlassian-swagger-doclet

private static void matchResponseRepresentationTagsKeyedByHttpStatus(Map<String, List<Tag>> tagsByStatus, List<Tag> javadocTags) {
    for (Tag tag : javadocTags) {
      final Matcher matcher = PATTERN_RESPONSE_REPRESENTATION.matcher(tag.name());
      if (matcher.matches()) {
        final String status = matcher.group(1);
        List<Tag> tags = tagsByStatus.computeIfAbsent(status, k -> new ArrayList<>());
        tags.add(tag);
      }
    }
  }
}

代码示例来源:origin: ch.raffael.pegdown-doclet/pegdown-doclet

@Override
  public void render(Tag tag, StringBuilder target, PegdownDoclet doclet) {
    target.append(tag.name()).append(" ").append(tag.text());
  }
};

代码示例来源:origin: com.atlassian.swagger/atlassian-swagger-doclet

private static Stream<Tag> streamRequestRepresentationTags(MethodDoc methodDoc) {
  return Arrays.stream(methodDoc.tags())
      .filter(tag -> PATTERN_REQUEST_REPRESENTATION.matcher(tag.name()).matches());
}

代码示例来源:origin: com.atlassian.jersey/atlassian-jersey-restdoc

private static String print( Tag tag ) {
  final StringBuilder sb = new StringBuilder();
  sb.append( tag.getClass() ).append( "[" );
  sb.append( "firstSentenceTags=" ).append( toCSV( tag.firstSentenceTags() ) );
  sb.append( ", inlineTags=" ).append( toCSV( tag.inlineTags() ) );
  sb.append( ", kind=" ).append( tag.kind() );
  sb.append( ", name=" ).append( tag.name() );
  sb.append( ", text=" ).append( tag.text() );
  sb.append( "]" );
  return sb.toString();
}

代码示例来源:origin: org.broadinstitute/barclay

/**
 * Add any custom freemarker bindings discovered via custom javadoc tags. Subclasses can override this to
 * provide additional custom bindings.
 *
 * @param currentWorkUnit the work unit for the feature being documented
 */
protected void addCustomBindings(final DocWorkUnit currentWorkUnit) {
  final String tagFilterPrefix = getTagPrefix();
  Arrays.stream(currentWorkUnit.getClassDoc().inlineTags())
      .filter(t -> t.name().startsWith(tagFilterPrefix))
      .forEach(t -> currentWorkUnit.setProperty(t.name().substring(tagFilterPrefix.length()), t.text()));
}

代码示例来源:origin: com.atlassian.swagger/atlassian-swagger-doclet

private Option<SeeTag> findAtLinkTag(Tag[] inlineTags) {
  for (Tag inlineTag : inlineTags) {
    if ("@link".equals(inlineTag.name())) {
      final SeeTag linkTag = (SeeTag) inlineTag;
      return some(linkTag);
    }
  }
  return none();
}

代码示例来源:origin: org.apache.axis2.transport/axis2-transport-testkit

private static String getFirstSentence(Doc doc) {
  Tag[] tags = doc.firstSentenceTags();
  if (tags.length == 0) {
    return null;
  }
  StringBuilder buffer = new StringBuilder();
  for (Tag tag : tags) {
    if (tag instanceof SeeTag) {
      buffer.append("{");
      buffer.append(tag.name());
      buffer.append(" ");
      buffer.append(((SeeTag)tag).referencedClassName());
      buffer.append("}");
    } else {
      buffer.append(tag.text());
    }
  }
  return buffer.toString();
}

代码示例来源:origin: com.atlassian.swagger/atlassian-swagger-doclet

private void parseJavadocForSwaggerNamedTags(Operation operation, List<Tag> tags) {
  for (Tag tag : tags) {
    final Matcher matcher = SWAGGER_NAMED_TAG.matcher(tag.name());
    if (matcher.matches()) {
      final String swaggerTagName = matcher.group(1);
      // it must have previously been found for the extended description
      List<String> currentTags = option(operation.getTags()).getOrElse(emptyList());
      if (!currentTags.contains(swaggerTagName)) {
        operation.addTagsItem(swaggerTagName);
      }
    }
  }
}

代码示例来源:origin: ch.raffael.pegdown-doclet/pegdown-doclet

@Override
public void render(Tag tag, StringBuilder target, PegdownDoclet doclet) {
  target.append(tag.name()).append(" ").append(simplifySingleParagraph(doclet.toHtml(tag.text())));
}

代码示例来源:origin: org.broadinstitute/barclay

/**
 * Return the description to be used for the work unit. We need to manually strip
 * out any inline custom javadoc tags since we don't those in the summary.
 *
 * @param currentWorkUnit
 * @return Description to be used or the work unit.
 */
protected String getDescription(final DocWorkUnit currentWorkUnit) {
  return Arrays.stream(currentWorkUnit.getClassDoc().inlineTags())
      .filter(t -> getTagPrefix() == null || !t.name().startsWith(getTagPrefix()))
      .map(t -> t.text())
      .collect(Collectors.joining());
}

代码示例来源:origin: improbable-research/keanu

@Before
public void initialiseMocks() {
  when(constructorDoc.tags(PARAM_TAG_NAME)).thenReturn(new Tag[] {tag1, tag2});
  when(tag1.name()).thenReturn(PARAM_TAG_NAME);
  when(tag1.text()).thenReturn(FIRST_PARAM_TEXT);
  when(tag2.name()).thenReturn(PARAM_TAG_NAME);
  when(tag2.text()).thenReturn(SECOND_PARAM_TEXT);
  when(tag3.name()).thenReturn(RETURN_TAG_NAME);
  when(tag3.text()).thenReturn(RETURN_TAG_TEXT);
}

代码示例来源:origin: ScaCap/spring-auto-restdocs

public static FieldDocumentation fromFieldDoc(FieldDoc fieldDoc) {
  FieldDocumentation fd = new FieldDocumentation();
  fd.comment = fieldDoc.commentText();
  for (Tag tag : fieldDoc.tags()) {
    fd.tags.put(cleanupTagName(tag.name()), tag.text());
  }
  return fd;
}

代码示例来源:origin: ScaCap/spring-auto-restdocs

public static MethodDocumentation fromMethodDoc(MethodDoc methodDoc) {
    MethodDocumentation md = new MethodDocumentation();
    md.comment = methodDoc.commentText();

    for (Tag tag : methodDoc.tags()) {
      if (tag instanceof ParamTag) {
        ParamTag paramTag = (ParamTag) tag;
        md.parameters.put(paramTag.parameterName(), paramTag.parameterComment());
      } else {
        md.tags.put(cleanupTagName(tag.name()), tag.text());
      }
    }

    return md;
  }
}

相关文章