com.github.javaparser.javadoc.JavadocBlockTag Java Examples
The following examples show how to use
com.github.javaparser.javadoc.JavadocBlockTag.
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 |
private static Stream<String> parseJavadoc(Javadoc javadoc) { // parse main doc description Stream<String> stringsFromJavadocDescription = Stream.of(javadoc.getDescription()).flatMap(ImpSort::parseJavadocDescription); // grab tag names and parsed descriptions for block tags Stream<String> stringsFromBlockTags = javadoc.getBlockTags().stream().flatMap(tag -> { // only @throws and @exception have names who are importable; @param and others don't EnumSet<JavadocBlockTag.Type> blockTagTypesWithImportableNames = EnumSet.of(THROWS, EXCEPTION); Stream<String> importableTagNames = blockTagTypesWithImportableNames.contains(tag.getType()) ? Stream.of(tag.getName()).filter(Optional::isPresent).map(Optional::get) : Stream.empty(); Stream<String> tagDescriptions = Stream.of(tag.getContent()).flatMap(ImpSort::parseJavadocDescription); return Stream.concat(importableTagNames, tagDescriptions); }); return Stream.concat(stringsFromJavadocDescription, stringsFromBlockTags); }
Example #2
Source File: OpenApiObjectGenerator.java From flow with Apache License 2.0 | 6 votes |
private ApiResponse createApiSuccessfulResponse( MethodDeclaration methodDeclaration) { Content successfulContent = new Content(); // "description" is a REQUIRED property of Response ApiResponse successfulResponse = new ApiResponse().description(""); methodDeclaration.getJavadoc().ifPresent(javadoc -> { for (JavadocBlockTag blockTag : javadoc.getBlockTags()) { if (blockTag.getType() == JavadocBlockTag.Type.RETURN) { successfulResponse.setDescription( "Return " + blockTag.getContent().toText()); } } }); if (!methodDeclaration.getType().isVoidType()) { MediaType mediaItem = createReturnMediaType(methodDeclaration); successfulContent.addMediaType("application/json", mediaItem); successfulResponse.content(successfulContent); } return successfulResponse; }
Example #3
Source File: AutoDoc.java From joyqueue with Apache License 2.0 | 5 votes |
/** * Write the method parameters and it's doc to target api doc * * @param doc target doc * @param comment parameters and method doc **/ private void fillParamDoc(APIDoc doc, JavadocComment comment, StringBuilder methodDesBuilder) { Javadoc javadoc = comment.parse(); toString(javadoc.getDescription(), methodDesBuilder); doc.setDesc(methodDesBuilder.toString()); methodDesBuilder.setLength(0); List<JavadocBlockTag> tags = javadoc.getBlockTags(); if (comment.getCommentedNode().isPresent()) { Node node = comment.getCommentedNode().get(); if (node instanceof MethodDeclaration) { MethodDeclaration method = (MethodDeclaration) node; for (Parameter p : method.getParameters()) { String type = p.getType().asString(); String name = p.getName().asString(); List<Param> params = doc.getParams(); Param param = new Param(); param.setName(name); param.setType(type); for (JavadocBlockTag t : tags) { if (t.getName().isPresent()) { if (name.endsWith(t.getName().get())) { toString(t.getContent(), methodDesBuilder); param.setComment(methodDesBuilder.toString()); methodDesBuilder.setLength(0); } } } if (params == null) { params = new ArrayList<>(); doc.setParams(params); } params.add(param); } } } }
Example #4
Source File: ParseHelper.java From genDoc with Apache License 2.0 | 5 votes |
static Comment parseComment(Node node) { if (node.getComment().isPresent()) { Javadoc javadoc = JavaParser.parseJavadoc(node.getComment().get().getContent()); Comment comment = new Comment(); comment.setDescription(javadoc.getDescription().toText()); List<JavadocBlockTag> javadocBlockTags = javadoc.getBlockTags(); if (javadocBlockTags != null && javadocBlockTags.size() > 0) { List<Comment.Tag> tags = new ArrayList<Comment.Tag>(); for (JavadocBlockTag javadocBlockTag : javadocBlockTags) { Comment.Tag tag = new Comment.Tag(); tag.setTagName(javadocBlockTag.getTagName()); tag.setName(javadocBlockTag.getName().orElse(null)); tag.setContent(javadocBlockTag.getContent().toText()); tags.add(tag); } comment.setTags(tags); } return comment; } return null; }
Example #5
Source File: RemoveMethodParameter.java From Refactoring-Bot with MIT License | 5 votes |
/** * Removes the parameter with the given name from the Javadoc of the given * method declaration * * @param methodDeclaration * @param paramName */ private void removeParameterFromJavadoc(MethodDeclaration methodDeclaration, String paramName) { Optional<Javadoc> javadoc = methodDeclaration.getJavadoc(); if (javadoc.isPresent()) { Javadoc methodJavadoc = javadoc.get(); List<JavadocBlockTag> javadocTags = methodJavadoc.getBlockTags(); for (Iterator<JavadocBlockTag> it = javadocTags.iterator(); it.hasNext();) { JavadocBlockTag javadocTag = it.next(); Optional<String> javadocTagName = javadocTag.getName(); boolean isEqualParamName = javadocTagName.isPresent() && javadocTagName.get().equals(paramName); boolean isParamType = javadocTag.getType().equals(JavadocBlockTag.Type.PARAM); if (isParamType && isEqualParamName) { it.remove(); } } // create new Javadoc with remaining Javadoc tags because there is no way to // remove individual tags directly Javadoc newJavadoc = new Javadoc(methodJavadoc.getDescription()); for (JavadocBlockTag blockTag : javadocTags) { newJavadoc.addBlockTag(blockTag); } methodDeclaration.setJavadocComment(newJavadoc); } }
Example #6
Source File: RemoveMethodParameterTest.java From Refactoring-Bot with MIT License | 5 votes |
/** * Asserts that the given parameter is not present in the javadoc of the given * method * * @param methodDeclaration * @param parameterName */ private void assertParameterNotPresentInJavadoc(MethodDeclaration methodDeclaration, String parameterName) { List<JavadocBlockTag> javadocBlockTags = methodDeclaration.getJavadoc().get().getBlockTags(); for (JavadocBlockTag javadocBlockTag : javadocBlockTags) { if (javadocBlockTag.getTagName().equals("param")) { assertThat(javadocBlockTag.getName().get()).isNotEqualTo(parameterName); } } }
Example #7
Source File: JavaDocParser.java From quarkus with Apache License 2.0 | 5 votes |
private boolean isAsciidoc(Javadoc javadoc) { for (JavadocBlockTag blockTag : javadoc.getBlockTags()) { if ("asciidoclet".equals(blockTag.getTagName())) { return true; } } return false; }
Example #8
Source File: AbsControllerParser.java From JApiDocs with Apache License 2.0 | 5 votes |
private void parseClassDoc(ClassOrInterfaceDeclaration c) { c.getParentNode().get().findFirst(PackageDeclaration.class).ifPresent(pd -> { controllerNode.setPackageName(pd.getNameAsString()); }); boolean generateDocs = c.getAnnotationByName("ApiDoc").isPresent(); controllerNode.setGenerateDocs(generateDocs); c.getJavadoc().ifPresent(d -> { String description = d.getDescription().toText(); controllerNode.setDescription(Utils.isNotEmpty(description) ? description : c.getNameAsString()); List<JavadocBlockTag> blockTags = d.getBlockTags(); if (blockTags != null) { for (JavadocBlockTag blockTag : blockTags) { if ("author".equalsIgnoreCase(blockTag.getTagName())) { controllerNode.setAuthor(blockTag.getContent().toText()); } if ("description".equalsIgnoreCase(blockTag.getTagName())) { controllerNode.setDescription(blockTag.getContent().toText()); } } } }); if (controllerNode.getDescription() == null) { controllerNode.setDescription(c.getNameAsString()); } }
Example #9
Source File: JavaDocParserVisitor.java From jaxrs-analyzer with Apache License 2.0 | 5 votes |
private MemberParameterTag createMethodParameterTag(JavadocBlockTag tag, MethodDeclaration method) { Stream<AnnotationExpr> annotations = method.getParameterByName(tag.getName().orElse(null)) .map(Parameter::getAnnotations) .map(NodeList::stream) .orElseGet(Stream::empty); return createMemberParamTag(tag.getContent(), annotations); }
Example #10
Source File: NodeWithComment.java From apigcc with MIT License | 4 votes |
/** * 解析并保存blockTag * @param blockTag */ private void parse(JavadocBlockTag blockTag) { Tag tag = new Tag(blockTag); tags.put(tag.getCompositeId(), tag); }
Example #11
Source File: Tag.java From apigcc with MIT License | 4 votes |
public Tag(JavadocBlockTag blockTag){ setId(blockTag.getTagName()); setKey(blockTag.getName().isPresent() ? blockTag.getName().get() : ""); setContent(CommentHelper.getDescription(blockTag.getContent())); }
Example #12
Source File: JavaDocParserVisitor.java From jaxrs-analyzer with Apache License 2.0 | 4 votes |
private boolean isDeprecated(Javadoc javadoc) { return javadoc.getBlockTags().stream().anyMatch(t -> t.getType() == JavadocBlockTag.Type.DEPRECATED); }
Example #13
Source File: JavaDocParserVisitor.java From jaxrs-analyzer with Apache License 2.0 | 4 votes |
private List<MemberParameterTag> createMethodParameterTags(Javadoc javadoc, MethodDeclaration method) { return javadoc.getBlockTags().stream() .filter(t -> t.getType() == JavadocBlockTag.Type.PARAM) .map(t -> createMethodParameterTag(t, method)) .collect(Collectors.toList()); }
Example #14
Source File: OpenApiObjectGenerator.java From flow with Apache License 2.0 | 4 votes |
private RequestBody createRequestBody(MethodDeclaration methodDeclaration) { Map<String, String> paramsDescription = new HashMap<>(); methodDeclaration.getJavadoc().ifPresent(javadoc -> { for (JavadocBlockTag blockTag : javadoc.getBlockTags()) { if (blockTag.getType() == JavadocBlockTag.Type.PARAM) { paramsDescription.put(blockTag.getName().orElse(""), blockTag.getContent().toText()); } } }); RequestBody requestBody = new RequestBody(); Content requestBodyContent = new Content(); requestBody.content(requestBodyContent); MediaType requestBodyObject = new MediaType(); requestBodyContent.addMediaType("application/json", requestBodyObject); Schema requestSchema = new ObjectSchema(); requestSchema.setRequired(new ArrayList<>()); requestBodyObject.schema(requestSchema); methodDeclaration.getParameters().forEach(parameter -> { Schema paramSchema = parseTypeToSchema(parameter.getType(), ""); usedTypes.putAll(collectUsedTypesFromSchema(paramSchema)); String name = (isReservedWord(parameter.getNameAsString()) ? "_" : "").concat(parameter.getNameAsString()); if (GeneratorUtils.isBlank(paramSchema.get$ref())) { paramSchema.description( paramsDescription.remove(parameter.getNameAsString())); } requestSchema.addProperties(name, paramSchema); if (GeneratorUtils.isNotTrue(paramSchema.getNullable()) && !parameter.isAnnotationPresent(Nullable.class)) { requestSchema.addRequiredItem(name); } paramSchema.setNullable(null); }); if (!paramsDescription.isEmpty()) { requestSchema.addExtension( EXTENSION_VAADIN_CONNECT_PARAMETERS_DESCRIPTION, new LinkedHashMap<>(paramsDescription)); } return requestBody; }