Search in sources :

Example 1 with ParamTag

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

the class ResourceDoclet method addParamDocs.

private static void addParamDocs(final MethodDoc methodDoc, final MethodDocType methodDocType, final DocProcessor docProcessor) {
    final Parameter[] parameters = methodDoc.parameters();
    final ParamTag[] paramTags = methodDoc.paramTags();
    /* only use both javadoc and reflection information when the number
         * of params are the same
         */
    if (parameters != null && paramTags != null && parameters.length == paramTags.length) {
        for (int i = 0; i < parameters.length; i++) {
            final Parameter parameter = parameters[i];
            /* TODO: this only works if the params and tags are in the same
                 * order. If the param tags are mixed up, the comments for parameters
                 * will be wrong.
                 */
            final ParamTag paramTag = paramTags[i];
            final ParamDocType paramDocType = new ParamDocType();
            paramDocType.setParamName(paramTag.parameterName());
            paramDocType.setCommentText(paramTag.parameterComment());
            docProcessor.processParamTag(paramTag, parameter, paramDocType);
            final AnnotationDesc[] annotations = parameter.annotations();
            if (annotations != null) {
                for (final AnnotationDesc annotationDesc : annotations) {
                    final AnnotationDocType annotationDocType = new AnnotationDocType();
                    final String typeName = annotationDesc.annotationType().qualifiedName();
                    annotationDocType.setAnnotationTypeName(typeName);
                    for (final ElementValuePair elementValuePair : annotationDesc.elementValues()) {
                        final NamedValueType namedValueType = new NamedValueType();
                        namedValueType.setName(elementValuePair.element().name());
                        namedValueType.setValue(elementValuePair.value().value().toString());
                        annotationDocType.getAttributeDocs().add(namedValueType);
                    }
                    paramDocType.getAnnotationDocs().add(annotationDocType);
                }
            }
            methodDocType.getParamDocs().add(paramDocType);
        }
    }
}
Also used : ParamTag(com.sun.javadoc.ParamTag) ElementValuePair(com.sun.javadoc.AnnotationDesc.ElementValuePair) NamedValueType(org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.NamedValueType) Parameter(com.sun.javadoc.Parameter) AnnotationDocType(org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.AnnotationDocType) ParamDocType(org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ParamDocType) AnnotationDesc(com.sun.javadoc.AnnotationDesc)

Example 2 with ParamTag

use of com.sun.javadoc.ParamTag in project RESTdoclet by IG-Group.

the class BaseType method initJavadoc.

/**
    * Initialises the documentation of this parameter.
    * 
    * @param param the parameter's Java documentation object.
    * @param tags the Java documentation tags of the parameters of the method
    *           this parameter belongs to.
    */
protected void initJavadoc(final Parameter param, final ParamTag[] tags) {
    for (ParamTag tag : tags) {
        if (param.name().equals(tag.parameterName())) {
            String comment = DocTypeUtils.getTypeDoc(param.type());
            setJavadoc(DocletUtils.preserveJavadocFormatting(comment == null || comment.isEmpty() ? tag.parameterComment() : comment));
        }
    }
}
Also used : ParamTag(com.sun.javadoc.ParamTag)

Example 3 with ParamTag

use of com.sun.javadoc.ParamTag in project RESTdoclet by IG-Group.

the class BaseTypeBuilder method initJavadoc.

/**
    * Initialise type javadoc
    * 
    * @param type type to initialise
    * @param param parameter info
    * @param tags tag info
    */
private void initJavadoc(BaseType type, final Parameter param, final ParamTag[] tags) {
    LOG.debug(type.getType() + " - " + param.type() + " - " + param.name());
    for (ParamTag tag : tags) {
        if (param.name().equals(tag.parameterName())) {
            String comment = DocTypeUtils.getTypeDoc(param.type());
            LOG.debug(" - " + type.getType() + " : " + comment);
            if (comment.isEmpty()) {
                comment = tag.parameterComment();
            } else {
                comment = tag.parameterComment() + "<table><tr><td>" + comment + "</td></tr></table>";
            }
            type.setJavadoc(DocletUtils.preserveJavadocFormatting(comment));
        }
    }
}
Also used : ParamTag(com.sun.javadoc.ParamTag)

Example 4 with ParamTag

use of com.sun.javadoc.ParamTag in project wso2-axis2-transports by wso2.

the class ResourceInfoDoclet method start.

public static boolean start(RootDoc root) throws IOException {
    parseOptions(root.options());
    ResourceInfo resourceInfo = new ResourceInfo();
    for (ClassDoc clazz : root.classes()) {
        Resource resource = null;
        for (MethodDoc method : clazz.methods()) {
            if (getAnnotation(method, "org.apache.axis2.transport.testkit.tests.Setup") != null) {
                if (resource == null) {
                    resource = new Resource(clazz.qualifiedName());
                }
                ParamTag[] paramTags = method.paramTags();
                for (Parameter parameter : method.parameters()) {
                    Type type = parameter.type();
                    String name = parameter.name();
                    String comment = null;
                    for (ParamTag paramTag : paramTags) {
                        if (paramTag.parameterName().equals(name)) {
                            comment = paramTag.parameterComment();
                            break;
                        }
                    }
                    if (comment == null) {
                        comment = getFirstSentence(root.classNamed(type.qualifiedTypeName()));
                    }
                    resource.addDependency(type.qualifiedTypeName(), type.dimension().equals("[]") ? "0..*" : "1", comment);
                }
            }
        }
        if (resource != null) {
            resourceInfo.addResource(resource);
        }
    }
    ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(outFile));
    out.writeObject(resourceInfo);
    out.close();
    return true;
}
Also used : ParamTag(com.sun.javadoc.ParamTag) Type(com.sun.javadoc.Type) MethodDoc(com.sun.javadoc.MethodDoc) FileOutputStream(java.io.FileOutputStream) Parameter(com.sun.javadoc.Parameter) ObjectOutputStream(java.io.ObjectOutputStream) ClassDoc(com.sun.javadoc.ClassDoc)

Example 5 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)

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