Java Code Examples for com.github.javaparser.javadoc.Javadoc#getBlockTags()

The following examples show how to use com.github.javaparser.javadoc.Javadoc#getBlockTags() . 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: AutoDoc.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
/**
 * 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 2
Source File: ParseHelper.java    From genDoc with Apache License 2.0 5 votes vote down vote up
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 3
Source File: RemoveMethodParameter.java    From Refactoring-Bot with MIT License 5 votes vote down vote up
/**
 * 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 4
Source File: JavaDocParser.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private boolean isAsciidoc(Javadoc javadoc) {
    for (JavadocBlockTag blockTag : javadoc.getBlockTags()) {
        if ("asciidoclet".equals(blockTag.getTagName())) {
            return true;
        }
    }
    return false;
}