com.github.javaparser.javadoc.description.JavadocDescription Java Examples
The following examples show how to use
com.github.javaparser.javadoc.description.JavadocDescription.
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: PackageInfoReader.java From jig with Apache License 2.0 | 6 votes |
Optional<PackageAlias> read(PackageInfoSource packageInfoSource) { CompilationUnit cu = StaticJavaParser.parse(packageInfoSource.toInputStream()); Optional<PackageIdentifier> optPackageIdentifier = cu.getPackageDeclaration() .map(NodeWithName::getNameAsString) .map(PackageIdentifier::new); Optional<Alias> optAlias = getJavadoc(cu) .map(Javadoc::getDescription) .map(JavadocDescription::toText) .map(JavadocAliasSource::new) .map(JavadocAliasSource::toAlias); return optPackageIdentifier.flatMap(packageIdentifier -> optAlias.map(alias -> new PackageAlias(packageIdentifier, alias))); }
Example #2
Source File: ImpSort.java From impsort-maven-plugin with Apache License 2.0 | 6 votes |
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 #3
Source File: AutoDoc.java From joyqueue with Apache License 2.0 | 5 votes |
/** * JavadocDescription toString **/ private void toString(JavadocDescription description, StringBuilder content) { for (JavadocDescriptionElement e : description.getElements()) { content.append(e.toText()).append(","); } if (content.length() > 0) { content.deleteCharAt(content.length() - 1); } }
Example #4
Source File: JavadocUtils.java From chrome-devtools-java-client with Apache License 2.0 | 5 votes |
/** * Creates a javadoc comment object given a comment string. * * @param comment Comment. * @param indentation Indentation. * @return Javadoc comment object. */ public JavadocComment createJavadocComment(String comment, String indentation) { JavadocSnippet javadocSnippet = new JavadocSnippet(""); if (StringUtils.isNotEmpty(comment)) { javadocSnippet = new JavadocSnippet(comment); } JavadocDescription description = new JavadocDescription(); description.addElement(javadocSnippet); Javadoc javadoc = new Javadoc(description); return javadoc.toComment(indentation); }
Example #5
Source File: CommentHelper.java From apigcc with MIT License | 5 votes |
/** * 获取注释完整字符串 * * @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 #6
Source File: JavaDocParser.java From quarkus with Apache License 2.0 | 5 votes |
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(); }
Example #7
Source File: JavaDocParserVisitor.java From jaxrs-analyzer with Apache License 2.0 | 5 votes |
private MemberParameterTag createMemberParamTag(JavadocDescription javadocDescription, Stream<AnnotationExpr> annotationStream) { Map<String, String> annotations = annotationStream .filter(Expression::isSingleMemberAnnotationExpr) .collect(Collectors.toMap(a -> a.getName().getIdentifier(), this::createMemberParamValue)); return new MemberParameterTag(javadocDescription.toText(), annotations); }