Search in sources :

Example 6 with ParamTag

use of com.sun.javadoc.ParamTag in project cxf by apache.

the class DumpJavaDoc method start.

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;
}
Also used : ParamTag(com.sun.javadoc.ParamTag) MethodDoc(com.sun.javadoc.MethodDoc) OutputStream(java.io.OutputStream) Parameter(com.sun.javadoc.Parameter) ParamTag(com.sun.javadoc.ParamTag) Tag(com.sun.javadoc.Tag) Properties(java.util.Properties) ClassDoc(com.sun.javadoc.ClassDoc)

Example 7 with ParamTag

use of com.sun.javadoc.ParamTag in project Orchid by JavaEden.

the class ParameterParser method getParameters.

public JSONArray getParameters(ExecutableMemberDoc doc) {
    JSONArray array = new JSONArray();
    for (Parameter parameter : doc.parameters()) {
        JSONObject object = new JSONObject();
        object.put("type", typeParser.getTypeObject(parameter.type()));
        object.put("name", parameter.name());
        for (ParamTag paramTag : doc.paramTags()) {
            if (parameter.name().equals(paramTag.parameterName())) {
                object.put("description", paramTag.parameterComment());
            }
        }
        array.put(object);
    }
    return (array.length() > 0) ? array : null;
}
Also used : ParamTag(com.sun.javadoc.ParamTag) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) Parameter(com.sun.javadoc.Parameter)

Example 8 with ParamTag

use of com.sun.javadoc.ParamTag in project h2database by h2database.

the class Doclet method writeMethodDetails.

private void writeMethodDetails(PrintWriter writer, ClassDoc clazz, ExecutableMemberDoc method, String signature) {
    String name = method.name();
    if (skipMethod(method)) {
        return;
    }
    Parameter[] params = method.parameters();
    StatementBuilder buff = new StatementBuilder();
    buff.append('(');
    int i = 0;
    for (Parameter p : params) {
        boolean isVarArgs = method.isVarArgs() && i++ == params.length - 1;
        buff.appendExceptFirst(", ");
        buff.append(getTypeName(false, isVarArgs, p.type()));
        buff.append(' ');
        buff.append(p.name());
    }
    buff.append(')');
    ClassDoc[] exceptions = method.thrownExceptions();
    if (exceptions.length > 0) {
        buff.append(" throws ");
        buff.resetCount();
        for (ClassDoc ex : exceptions) {
            buff.appendExceptFirst(", ");
            buff.append(ex.typeName());
        }
    }
    if (isDeprecated(method)) {
        name = "<span class=\"deprecated\">" + name + "</span>";
    }
    writer.println("<a id=\"" + signature + "\" href=\"#" + signature + "\">" + name + "</a>" + buff.toString());
    boolean hasComment = method.commentText() != null && method.commentText().trim().length() != 0;
    writer.println("<div class=\"methodText\">" + formatText(method.commentText()) + "</div>");
    ParamTag[] paramTags = method.paramTags();
    ThrowsTag[] throwsTags = method.throwsTags();
    boolean hasThrowsTag = throwsTags != null && throwsTags.length > 0;
    if (paramTags.length != params.length) {
        if (hasComment && !method.commentText().startsWith("[")) {
            // [Not supported] and such are not problematic
            addError("Undocumented parameter(s) (" + getLink(clazz, method.position().line()) + ") " + name + " documented: " + paramTags.length + " params: " + params.length);
        }
    }
    for (int j = 0; j < paramTags.length; j++) {
        String paramName = paramTags[j].parameterName();
        String comment = paramTags[j].parameterComment();
        if (comment.trim().length() == 0) {
            addError("Undocumented parameter (" + getLink(clazz, method.position().line()) + ") " + name + " " + paramName);
        }
        String p = paramName + " - " + comment;
        if (j == 0) {
            writer.println("<div class=\"itemTitle\">Parameters:</div>");
        }
        writer.println("<div class=\"item\">" + p + "</div>");
    }
    Tag[] returnTags = method.tags("return");
    Type returnType = getReturnType(method);
    if (returnTags != null && returnTags.length > 0) {
        writer.println("<div class=\"itemTitle\">Returns:</div>");
        String returnComment = returnTags[0].text();
        if (returnComment.trim().length() == 0) {
            addError("Undocumented return value (" + getLink(clazz, method.position().line()) + ") " + name);
        }
        writer.println("<div class=\"item\">" + returnComment + "</div>");
    } else if (returnType != null && !returnType.toString().equals("void")) {
        if (hasComment && !method.commentText().startsWith("[") && !hasThrowsTag) {
            // [Not supported] and such are not problematic
            // also not problematic are methods that always throw an
            // exception
            addError("Undocumented return value (" + getLink(clazz, method.position().line()) + ") " + name + " " + getReturnType(method));
        }
    }
    if (hasThrowsTag) {
        writer.println("<div class=\"itemTitle\">Throws:</div>");
        for (ThrowsTag tag : throwsTags) {
            String p = tag.exceptionName();
            String c = tag.exceptionComment();
            if (c.length() > 0) {
                p += " - " + c;
            }
            writer.println("<div class=\"item\">" + p + "</div>");
        }
    }
}
Also used : ParamTag(com.sun.javadoc.ParamTag) ThrowsTag(com.sun.javadoc.ThrowsTag) Type(com.sun.javadoc.Type) StatementBuilder(org.h2.util.StatementBuilder) Parameter(com.sun.javadoc.Parameter) Tag(com.sun.javadoc.Tag) ParamTag(com.sun.javadoc.ParamTag) ThrowsTag(com.sun.javadoc.ThrowsTag) ClassDoc(com.sun.javadoc.ClassDoc)

Example 9 with ParamTag

use of com.sun.javadoc.ParamTag in project coprhd-controller by CoprHD.

the class MethodProcessor method getApiParameters.

public static List<ApiField> getApiParameters(MethodDoc method, String parameterAnnotation) {
    List<ApiField> apiParams = Lists.newArrayList();
    for (Parameter parameter : method.parameters()) {
        if (AnnotationUtils.hasAnnotation(parameter, parameterAnnotation)) {
            ApiField apiParam = new ApiField();
            apiParam.name = AnnotationUtils.getAnnotationValue(parameter, parameterAnnotation, KnownAnnotations.Value_Element, parameter.name());
            if (parameter.type().asClassDoc() != null) {
                apiParam.type = JaxbClassProcessor.convertToApiClass(parameter.type().asClassDoc());
            }
            for (ParamTag paramTag : method.paramTags()) {
                if (paramTag.parameterName().equals(parameter.name())) {
                    apiParam.description = paramTag.parameterComment();
                }
            }
            apiParams.add(apiParam);
        }
    }
    return apiParams;
}
Also used : ParamTag(com.sun.javadoc.ParamTag) Parameter(com.sun.javadoc.Parameter) ApiField(com.emc.apidocs.model.ApiField)

Aggregations

ParamTag (com.sun.javadoc.ParamTag)9 Parameter (com.sun.javadoc.Parameter)6 ClassDoc (com.sun.javadoc.ClassDoc)3 Tag (com.sun.javadoc.Tag)3 MethodDoc (com.sun.javadoc.MethodDoc)2 Type (com.sun.javadoc.Type)2 ApiField (com.emc.apidocs.model.ApiField)1 AnnotationDesc (com.sun.javadoc.AnnotationDesc)1 ElementValuePair (com.sun.javadoc.AnnotationDesc.ElementValuePair)1 SeeTag (com.sun.javadoc.SeeTag)1 ThrowsTag (com.sun.javadoc.ThrowsTag)1 FileOutputStream (java.io.FileOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 OutputStream (java.io.OutputStream)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Properties (java.util.Properties)1 AnnotationDocType (org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.AnnotationDocType)1 NamedValueType (org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.NamedValueType)1 ParamDocType (org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ParamDocType)1