Java Code Examples for com.sun.javadoc.MethodDoc#tags()

The following examples show how to use com.sun.javadoc.MethodDoc#tags() . 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: PSOperatorDoc.java    From PrivacyStreams with Apache License 2.0 5 votes vote down vote up
private PSOperatorDoc(ClassDoc classDoc, MethodDoc methodDoc) {
        this.declaringClassDoc = classDoc;
        this.methodDoc = methodDoc;
        this.description = methodDoc.commentText().replace('\n', ' ');
        this.paramDesc = "";

        Tag[] paramTags = methodDoc.tags("param");
        for (Tag paramTag : paramTags) {
            String paraStr = paramTag.text();
            String paraName = paraStr.substring(0, paraStr.indexOf(' ')).replace('\n', ' ');;
            String paraDesc = paraStr.substring(paraStr.indexOf(' ') + 1).replace('\n', ' ');;
            this.paramDesc += "<br> - `" + paraName + "`: " + paraDesc;
        }

        this.returnType = methodDoc.returnType();
//        ParameterizedType returnType = methodDoc.returnType().asParameterizedType();
//        this.inputType = returnType.typeArguments()[0];
//        this.outputType = returnType.typeArguments()[1];
//        this.completeSignature = "Function<" + this.inputType + ", " + this.outputType + "> " + methodDoc.toString();

        String shortSignature = classDoc.name() + "." + methodDoc.name() + "(";
        boolean firstParameter = true;
        for (Parameter parameter : methodDoc.parameters()) {
            if (firstParameter) {
                shortSignature += Utils.getSimpleTypeName(parameter.type()) + " " + parameter.name();
                firstParameter = false;
            } else {
                shortSignature += ", " + Utils.getSimpleTypeName(parameter.type()) + " " + parameter.name();
            }
        }
        shortSignature += ")";
        this.shortSignature = shortSignature;
    }
 
Example 2
Source File: MethodDocumentation.java    From spring-auto-restdocs with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 3
Source File: DumpJavaDoc.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static boolean start(RootDoc root) throws IOException {
    String dumpFileName = readOptions(root.options());
    OutputStream os = Files.newOutputStream(Paths.get(dumpFileName));
    Properties javaDocMap = new Properties();
    for (ClassDoc classDoc : root.classes()) {
        javaDocMap.put(classDoc.toString(), classDoc.commentText());
        for (MethodDoc method : classDoc.methods()) {
            javaDocMap.put(method.qualifiedName(), method.commentText());
            for (ParamTag paramTag : method.paramTags()) {
                Parameter[] parameters = method.parameters();
                for (int i = 0; i < parameters.length; ++i) {
                    if (parameters[i].name().equals(paramTag.parameterName())) {
                        javaDocMap.put(method.qualifiedName() + ".paramCommentTag." + i,
                               paramTag.parameterComment());
                    }
                }
            }
            Tag[] retTags = method.tags("return");
            if (retTags != null && retTags.length == 1) {
                Tag retTag = method.tags("return")[0];
                javaDocMap.put(method.qualifiedName() + "." + "returnCommentTag",
                               retTag.text());
            }
        }

    }
    javaDocMap.store(os, "");
    os.flush();
    os.close();
    return true;
}
 
Example 4
Source File: Parser.java    From xml-doclet with Apache License 2.0 5 votes vote down vote up
protected Method parseMethod(MethodDoc methodDoc) {
	Method methodNode = objectFactory.createMethod();

	methodNode.setName(methodDoc.name());
	methodNode.setQualified(methodDoc.qualifiedName());
	String comment = methodDoc.commentText();
	if (comment.length() > 0) {
		methodNode.setComment(comment);
	}
	methodNode.setScope(parseScope(methodDoc));
	methodNode.setAbstract(methodDoc.isAbstract());
	methodNode.setIncluded(methodDoc.isIncluded());
	methodNode.setFinal(methodDoc.isFinal());
	methodNode.setNative(methodDoc.isNative());
	methodNode.setStatic(methodDoc.isStatic());
	methodNode.setSynchronized(methodDoc.isSynchronized());
	methodNode.setVarArgs(methodDoc.isVarArgs());
	methodNode.setSignature(methodDoc.signature());
	methodNode.setReturn(parseTypeInfo(methodDoc.returnType()));

	for (Parameter parameter : methodDoc.parameters()) {
		methodNode.getParameter().add(parseMethodParameter(parameter));
	}

	for (Type exceptionType : methodDoc.thrownExceptionTypes()) {
		methodNode.getException().add(parseTypeInfo(exceptionType));
	}

	for (AnnotationDesc annotationDesc : methodDoc.annotations()) {
		methodNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, methodDoc.qualifiedName()));
	}

	for (Tag tag : methodDoc.tags()) {
		methodNode.getTag().add(parseTag(tag));
	}

	return methodNode;
}
 
Example 5
Source File: AntTaskDoclet.java    From ant-git-tasks with Apache License 2.0 5 votes vote down vote up
static AttributeData fromMethodDoc(MethodDoc methodDoc) {
        AttributeData data = new AttributeData();
        data.description = methodDoc.commentText();
        data.required = !(methodDoc.tags(TAG_ANTDOC_NOTREQUIRED).length > 0);
        data.name = sanitizeName(methodDoc.name(), ATTRIBUTE_PREFIXES);

        return data;
}
 
Example 6
Source File: SwaggerPropertiesDoclet.java    From springfox-javadoc with Apache License 2.0 4 votes vote down vote up
private static void processMethod(
  Properties properties,
  MethodDoc methodDoc,
  String defaultRequestMethod,
  String pathRoot,
  boolean exceptionRef) {

    for (AnnotationDesc annotationDesc : methodDoc.annotations()) {
        String annotationType = annotationDesc.annotationType().toString();
        if (isMapping(annotationType)) {
            StringBuilder path = new StringBuilder(pathRoot);
            for (AnnotationDesc.ElementValuePair pair : annotationDesc.elementValues()) {
                if (VALUE.equals(pair.element().name()) || PATH.equals(pair.element().name())) {
                    appendPath(path, pair);
                    break;
                }
            }
            if (!path.substring(path.length() - 1).equals(".")) {
                path.append(".");
            }
            String requestMethod = getRequestMethod(annotationDesc, annotationType, defaultRequestMethod);
            if (requestMethod != null) {
                path.append(requestMethod);
                saveProperty(properties, path.toString() + ".notes", methodDoc.commentText());

                for (ParamTag paramTag : methodDoc.paramTags()) {
                    saveProperty(properties, path.toString() + ".param." + paramTag.parameterName(),
                      paramTag.parameterComment());
                }
                for (Tag tag : methodDoc.tags()) {
                    if (tag.name().equals(RETURN)) {
                        saveProperty(properties, path.toString() + ".return", tag.text());
                        break;
                    }
                }
                if (exceptionRef) {
                    processThrows(properties, methodDoc.throwsTags(), path);
                }
            }
        }
    }
}