Java Code Examples for com.sun.javadoc.RootDoc#classes()

The following examples show how to use com.sun.javadoc.RootDoc#classes() . 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: SwaggerMoreDoclet.java    From swagger-more with Apache License 2.0 6 votes vote down vote up
private static void parseAndAnnotate(RootDoc rootDoc) throws ClassNotFoundException, NotFoundException, CannotCompileException, IOException {
    for (ClassDoc classDoc : rootDoc.classes()) {
        if (StringUtils.isEmpty(classDoc.getRawCommentText())) {
            DocLogger.warn("No javadoc found in class " + classDoc.qualifiedName() + "." + classDoc.name());
        }
        Class clazz = Class.forName(classDoc.qualifiedName());
        ClassPool pool = ClassPool.getDefault();
        pool.insertClassPath(new ClassClassPath(clazz));
        CtClass ctClass = pool.get(clazz.getName());
        ApiInfo apiInfo = ApiInfo.fromClassDoc(clazz, classDoc);
        if (!apiInfo.hidden()) {
            annotateClassAnn(ctClass, apiInfo);
            for (MethodDoc methodDoc : classDoc.methods()) {
                ApiMethodInfo apiMethodInfo = ApiMethodInfo.fromMethodDoc(matchingMethod(clazz, methodDoc), methodDoc);
                if (StringUtils.isEmpty(methodDoc.getRawCommentText())) {
                    DocLogger.warn("No javadoc found in method " + classDoc.qualifiedName() + "." + methodDoc.name() + methodDoc.signature());
                }
                annotateMethodAnn(ctClass, apiMethodInfo);
            }
            DocLogger.info("Successfully annotated " + clazz.getTypeName());
        }
        ctClass.writeFile(classDir);
    }
}
 
Example 2
Source File: DocTestSuite.java    From joinery with GNU General Public License v3.0 6 votes vote down vote up
public static boolean start(final RootDoc root) {
    for (final ClassDoc cls : root.classes()) {
        final List<ProgramElementDoc> elements = new LinkedList<>();
        elements.add(cls);
        elements.addAll(Arrays.asList(cls.constructors()));
        elements.addAll(Arrays.asList(cls.methods()));
        for (final ProgramElementDoc elem : elements) {
            for (final Tag tag : elem.inlineTags()) {
                final String name = tag.name();
                if (name.equals("@code") && tag.text().trim().startsWith(">")) {
                    generateRunner(cls, elem, tag);
                }
            }
        }
    }
    return true;
}
 
Example 3
Source File: ConfigStandardDoclet.java    From tez with Apache License 2.0 6 votes vote down vote up
public static boolean start(RootDoc root) {
  //look for debug flag
  for (String[] opts : root.options()) {
    for (String opt : opts) {
      if (opt.equals(DEBUG_SWITCH)) {
        debugMode = true;
      }
    }
  }

  logMessage("Running doclet " + ConfigStandardDoclet.class.getSimpleName());
  ClassDoc[] classes = root.classes();
  for (int i = 0; i < classes.length; ++i) {
    processDoc(classes[i]);
  }

  return true;
}
 
Example 4
Source File: Main.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
Example 5
Source File: Main.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
Example 6
Source File: Main.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
Example 7
Source File: PSDoclet.java    From PrivacyStreams with Apache License 2.0 5 votes vote down vote up
private boolean build(RootDoc rootDoc) {
    this.readOptions(rootDoc.options());

    ClassDoc[] classes = rootDoc.classes();

    for (int i = 0; i < classes.length; ++i) {
        ClassDoc classDoc = classes[i];

        PSItemDoc itemDoc = PSItemDoc.build(classDoc);
        if (itemDoc != null) this.psItems.add(itemDoc);

        PSOperatorWrapperDoc operatorWrapperDoc = PSOperatorWrapperDoc.build(classDoc);
        if (operatorWrapperDoc != null) this.psOperatorWrappers.add(operatorWrapperDoc);

        if (Utils.instanceOf(classDoc, Consts.TYPE_P_STREAM)) {
            for (MethodDoc methodDoc : classDoc.methods()) {
                PSPipelineDoc pipelineDoc = PSPipelineDoc.build(classDoc, methodDoc);
                if (pipelineDoc != null) {
                    this.psPipelines.add(pipelineDoc);
                }
            }
        }
    }

    this.dump();
    return true;
}
 
Example 8
Source File: Main.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
Example 9
Source File: Main.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
Example 10
Source File: Main.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
Example 11
Source File: Main.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
Example 12
Source File: Main.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean start(RootDoc root) {
    for (ClassDoc d : root.classes()) {
        for (AnnotationDesc a : d.annotations()) {
            System.out.println(a.annotationType());
        }
    }
    return true;
}
 
Example 13
Source File: ExtractDocumentationAsJsonDoclet.java    From spring-auto-restdocs with Apache License 2.0 5 votes vote down vote up
public static boolean start(RootDoc root) {
    String destinationDir = destinationDir(root.options());
    ObjectMapper mapper = createObjectMapper();

    for (ClassDoc classDoc : root.classes()) {
        ClassDocumentation cd = ClassDocumentation.fromClassDoc(classDoc);
        writeToFile(destinationDir, mapper, classDoc, cd);
    }
    return true;
}
 
Example 14
Source File: EnforcementDoclet.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * start the doclet
 * @param root the document root
 * @return boolean
 * @throws Exception e
 */
public static boolean start(RootDoc root) throws Exception {
    ClassDoc[] classes = root.classes();
    initializeExceptions();
    boolean found = false;

    for (ClassDoc clas : classes) {

        ClassDoc parent = clas.findClass("org.apache.struts.action.Action");
        if (parent == null) {
            System.out.println("Skipping " + clas.name());
            continue;
        }

        if (clas.subclassOf(parent)) {
            for (FieldDoc field : clas.fields()) {
                if (!field.isFinal() && !hasException(clas.name(), field.name())) {
                    found = true;
                    System.out.println("WARNING: Action Class " + clas.name() +
                            " has member: " + field.name());
                }
            }
        }
    }
    if (found) {
        throw new InvalidObjectException("Found non-final, non-exempt member " +
                "variables in one or more Action classes.  See Warnings " +
                "above for more information.");
    }
    return true;
}
 
Example 15
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 16
Source File: Parser.java    From xml-doclet with Apache License 2.0 5 votes vote down vote up
/**
 * The entry point into parsing the javadoc.
 * 
 * @param rootDoc
 *            The RootDoc intstance obtained via the doclet API
 * @return The root node, containing everything parsed from javadoc doclet
 */
public Root parseRootDoc(RootDoc rootDoc) {
	Root rootNode = objectFactory.createRoot();

	for (ClassDoc classDoc : rootDoc.classes()) {
		PackageDoc packageDoc = classDoc.containingPackage();

		Package packageNode = packages.get(packageDoc.name());
		if (packageNode == null) {
			packageNode = parsePackage(packageDoc);
			packages.put(packageDoc.name(), packageNode);
			rootNode.getPackage().add(packageNode);
		}

		if (classDoc instanceof AnnotationTypeDoc) {
			packageNode.getAnnotation().add(parseAnnotationTypeDoc((AnnotationTypeDoc) classDoc));
		} else if (classDoc.isEnum()) {
			packageNode.getEnum().add(parseEnum(classDoc));
		} else if (classDoc.isInterface()) {
			packageNode.getInterface().add(parseInterface(classDoc));
		} else {
			packageNode.getClazz().add(parseClass(classDoc));
		}
	}

	return rootNode;
}