com.github.javaparser.javadoc.description.JavadocInlineTag Java Examples

The following examples show how to use com.github.javaparser.javadoc.description.JavadocInlineTag. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImpSort.java    From impsort-maven-plugin with Apache License 2.0 6 votes vote down vote up
private static Stream<String> parseJavadocDescription(JavadocDescription description) {
  return description.getElements().stream().map(element -> {
    if (element instanceof JavadocInlineTag) {
      // inline tags like {@link Foo}
      return ((JavadocInlineTag) element).getContent();
    } else if (element instanceof JavadocSnippet) {
      // snippets like @see Foo
      return element.toText();
    } else {
      // try to handle unknown elements as best we can
      return element.toText();
    }
  }).flatMap(s -> {
    // split text descriptions into word tokens
    return Stream.of(s.split("\\W+"));
  });
}
 
Example #2
Source File: CommentHelper.java    From apigcc with MIT License 5 votes vote down vote up
/**
 * 获取注释完整字符串
 *
 * @param description
 * @return
 */
public static String getDescription(JavadocDescription description) {
    return description.getElements()
            .stream()
            .filter(e -> !(e instanceof JavadocInlineTag))
            .map(JavadocDescriptionElement::toText).collect(Collectors.joining());
}
 
Example #3
Source File: JavaDocParser.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private String htmlJavadocToAsciidoc(JavadocDescription javadocDescription) {
    StringBuilder sb = new StringBuilder();

    for (JavadocDescriptionElement javadocDescriptionElement : javadocDescription.getElements()) {
        if (javadocDescriptionElement instanceof JavadocInlineTag) {
            JavadocInlineTag inlineTag = (JavadocInlineTag) javadocDescriptionElement;
            String content = inlineTag.getContent().trim();
            switch (inlineTag.getType()) {
                case CODE:
                case VALUE:
                case LITERAL:
                case SYSTEM_PROPERTY:
                    sb.append('`');
                    appendEscapedAsciiDoc(sb, content);
                    sb.append('`');
                    break;
                case LINK:
                case LINKPLAIN:
                    if (content.startsWith(HASH)) {
                        content = hyphenate(content.substring(1));
                    }
                    sb.append('`');
                    appendEscapedAsciiDoc(sb, content);
                    sb.append('`');
                    break;
                default:
                    sb.append(content);
                    break;
            }
        } else {
            appendHtml(sb, Jsoup.parseBodyFragment(javadocDescriptionElement.toText()));
        }
    }

    return sb.toString().trim();
}