Refine search
public class ExtractCommentsDoclet { public static boolean start(RootDoc root) throws IOException { for (ClassDoc c : root.classes()) { print(c.qualifiedName(), c.commentText()); for (FieldDoc f : c.fields(false)) { print(f.qualifiedName(), f.commentText()); } for (MethodDoc m : c.methods(false)) { print(m.qualifiedName(), m.commentText()); if (m.commentText() != null && m.commentText().length() > 0) { for (ParamTag p : m.paramTags()) print(m.qualifiedName() + "@" + p.parameterName(), p.parameterComment()); for (Tag t : m.tags("return")) { if (t.text() != null && t.text().length() > 0) print(m.qualifiedName() + "@return", t.text()); } } } } return true; } private static void print(String name, String comment) throws IOException { if (comment != null && comment.length() > 0) { new FileWriter(name + ".txt").append(comment).close(); } } }
public static boolean start(RootDoc root) { //iterate over all classes. HashMap<String, ClassInspect> inspects = new HashMap<>(root.classes().length); ClassDoc[] classes = root.classes(); for (ClassDoc classDoc : classes) { ClassInspect classInspect = new ClassInspect(classDoc.name(), ((ClassDocImpl) classDoc).type.toString(), classDoc.commentText()); inspects.put(classInspect.getFullName(), classInspect); classInspect.setMethods(getInspects(classDoc.methods())); classInspect.setConstructors(getInspects(classDoc.constructors())); } SerializeInspect serializeInspect = new SerializeInspect(); String json = serializeInspect.toJson(inspects); serializeInspect.saveToFile(json); return true; }
/** * Returns an array containing all of the "test" methods (including those that are inherited) for * the given class. */ private static MethodDoc[] getTestMethods(ClassDoc c) { Set set = new TreeSet(); while (c != null) { MethodDoc[] methods = c.methods(); for (int i = 0; i < methods.length; i++) { MethodDoc method = methods[i]; if (method.isPublic() && method.parameters().length == 0 && method.name().startsWith("test")) { set.add(method); } } c = c.superclass(); } return (MethodDoc[]) set.toArray(new MethodDoc[0]); }
/** * Returns whether or not a class is a unit test. That is, whether or not it is a subclass of * {@link junit.framework.TestCase}. */ private static boolean isUnitTest(ClassDoc c) { if (c == null) { return false; } else if (c.qualifiedName().equals(TestCase.class.getName())) { return true; } else { return isUnitTest(c.superclass()); } }
final String output = getOptionArg(root.options(), OPTION_OUTPUT); final String classpath = getOptionArg(root.options(), OPTION_CLASSPATH); Thread.currentThread().setContextClassLoader(ncl); final String docProcessorOption = getOptionArg(root.options(), OPTION_DOC_PROCESSORS); final String[] docProcessors = docProcessorOption != null ? docProcessorOption.split(":") : null; final DocProcessorWrapper docProcessor = new DocProcessorWrapper(); final ClassDoc[] classes = root.classes(); for (final ClassDoc classDoc : classes) { LOG.fine("Writing class " + classDoc.qualifiedTypeName()); final ClassDocType classDocType = new ClassDocType(); classDocType.setClassName(classDoc.qualifiedTypeName()); classDocType.setCommentText(classDoc.commentText()); docProcessor.processClassDoc(classDoc, classDocType); for (final MethodDoc methodDoc : classDoc.methods()) { methodDocType.setMethodName(methodDoc.name()); methodDocType.setMethodSignature(methodDoc.signature()); methodDocType.setCommentText(methodDoc.commentText()); docProcessor.processMethodDoc(methodDoc, methodDocType);
ClassDoc[] classes = root.classes(); for (int i = 0; i < classes.length; i++) { PackageDoc pkg = classes[i].containingPackage(); mapAnnotations(classToPackageAnnotations, pkg, pkg); ClassDoc cd = classes[i]; mapTypeParameters(classToClassTypeParam, cd, cd); mapAnnotations(classToClassAnnotations, cd, cd); FieldDoc[] fields = cd.fields(); for (int j = 0; j < fields.length; j++) { FieldDoc fd = fields[j]; ConstructorDoc[] cons = cd.constructors(); for (int j = 0; j < cons.length; j++) { mapAnnotations(classToConstructorAnnotations, cons[j], cons[j]); mapExecutable(cons[j]); MethodDoc[] meths = cd.methods(); for (int j = 0; j < meths.length; j++) { MethodDoc md = meths[j]; mapTypeParameters(classToExecMemberDocTypeParam, md, md); mapAnnotations(classToExecMemberDocAnnotations, md, md); if (! (md.returnType().isPrimitive() || md.returnType() instanceof TypeVariable)) { mapTypeParameters(classToExecMemberDocReturnTypeParam, md.returnType(), md); add(classToMethodReturn, md.returnType().asClassDoc(), md);
classNode.setName(classDoc.name()); classNode.setQualified(classDoc.qualifiedName()); String comment = classDoc.commentText(); if (comment.length() > 0) { classNode.setComment(comment); classNode.setAbstract(classDoc.isAbstract()); classNode.setError(classDoc.isError()); classNode.setException(classDoc.isException()); classNode.setExternalizable(classDoc.isExternalizable()); classNode.setIncluded(classDoc.isIncluded()); classNode.setSerializable(classDoc.isSerializable()); classNode.setScope(parseScope(classDoc)); for (TypeVariable typeVariable : classDoc.typeParameters()) { classNode.getGeneric().add(parseTypeParameter(typeVariable)); Type superClassType = classDoc.superclassType(); if (superClassType != null) { classNode.setClazz(parseTypeInfo(superClassType)); for (Type interfaceType : classDoc.interfaceTypes()) { classNode.getInterface().add(parseTypeInfo(interfaceType)); for (MethodDoc method : classDoc.methods()) { classNode.getMethod().add(parseMethod(method)); for (AnnotationDesc annotationDesc : classDoc.annotations()) { classNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, classDoc.qualifiedName()));
ClassDoc[] classes = root.classes(); for (int i = 0; i < classes.length; i++) { ClassDoc cd = classes[i]; if (Util.isDeprecated(cd)) { if (cd.isOrdinaryClass()) { getList(CLASS).add(cd); } else if (cd.isInterface()) { getList(INTERFACE).add(cd); } else if (cd.isException()) { getList(EXCEPTION).add(cd); } else if (cd.isEnum()) { getList(ENUM).add(cd); } else if (cd.isError()) { getList(ERROR).add(cd); }else if (cd.isAnnotationType()) { getList(ANNOTATION_TYPE).add(cd); composeDeprecatedList(getList(FIELD), cd.fields()); composeDeprecatedList(getList(METHOD), cd.methods()); composeDeprecatedList(getList(CONSTRUCTOR), cd.constructors()); if (cd.isEnum()) { composeDeprecatedList(getList(ENUM_CONSTANT), cd.enumConstants()); if (cd.isAnnotationType()) { composeDeprecatedList(getList(ANNOTATION_TYPE_MEMBER), ((AnnotationTypeDoc) cd).elements());
/** * Put all the members(fields, methods and constructors) in the classdoc * to the indexmap. * * @param classdoc ClassDoc whose members will be added to the indexmap. */ protected void putMembersInIndexMap(ClassDoc classdoc) { adjustIndexMap(classdoc.fields()); adjustIndexMap(classdoc.methods()); adjustIndexMap(classdoc.constructors()); }
/** * Return the qualified name of the <code>ClassDoc</code> if it's qualifier is not excluded. Otherwise, * return the unqualified <code>ClassDoc</code> name. * @param cd the <code>ClassDoc</code> to check. */ public String getClassName(ClassDoc cd) { PackageDoc pd = cd.containingPackage(); if (pd != null && shouldExcludeQualifier(cd.containingPackage().name())) { return cd.name(); } else { return cd.qualifiedName(); } }
umlClassifier = (Classifier) factory.locateModelElement( classDoc.qualifiedName() ); // classDoc must be already existing fields = classDoc.fields( false ); // find all attributes regardless of the scope specified if ( classDoc.isInterface() ) { constructors = classDoc.constructors( false ); // all declared constructors for (int j = 0; j < constructors.length; j++) { constructor = createConstructor( constructors[ j ], umlClassifier ); methods = classDoc.methods( false ); // all declared methods for (int j = 0; j < methods.length; j++) { method = createMethod( methods[ j ] ); if ( classDoc.isInterface() ) {
public class ListClassAndMethods { public static boolean start(RootDoc root) { ClassDoc[] classes = root.classes(); for(ClassDoc clazz : classes){ System.out.println("Class Name: "+clazz); System.out.println("--------------------------"); for(MethodDoc methodz :clazz.methods()){ System.out.println(methodz.name()); } } return true; } }
/** * Summarizes the test methods of the given class */ public static void document(ClassDoc c, PrintWriter pw) throws IOException { pw.println(c.qualifiedName()); { String comment = c.commentText(); if (comment != null && !comment.equals("")) { pw.println(""); indent(comment, 4, pw); pw.println(""); } } MethodDoc[] methods = getTestMethods(c); for (int i = 0; i < methods.length; i++) { MethodDoc method = methods[i]; pw.print(" "); pw.println(method.name()); String comment = method.commentText(); if (comment != null && !comment.equals("")) { pw.println(""); indent(comment, 6, pw); pw.println(""); } } pw.println(""); }
/** * @return "com.acme.pkg.Outer$Inner$Inner2" */ public static String className(ClassDoc classDoc) { // "Outer.Inner.Inner2" => "Outer$Inner$Inner2" String name = classDoc.name().replace('.', '$'); String packageName = classDoc.containingPackage().name(); return packageName.isEmpty() ? name : packageName + '.' + name; } }
/** * Renders an individual class. * * @param doc input */ private void renderClass(ClassDoc doc, DocletRenderer renderer) { //handle the various parts of the Class doc renderer.renderDoc(doc); for (MemberDoc member : doc.fields()) { renderer.renderDoc(member); } for (MemberDoc member : doc.constructors()) { renderer.renderDoc(member); } for (MemberDoc member : doc.methods()) { renderer.renderDoc(member); } for (MemberDoc member : doc.enumConstants()) { renderer.renderDoc(member); } if (doc instanceof AnnotationTypeDoc) { for (MemberDoc member : ((AnnotationTypeDoc)doc).elements()) { renderer.renderDoc(member); } } }
protected ClassDoc implementsMethodInIntfac(MethodDoc method, ClassDoc[] intfacs) { for (int i = 0; i < intfacs.length; i++) { MethodDoc[] methods = intfacs[i].methods(); if (methods.length > 0) { for (int j = 0; j < methods.length; j++) { if (methods[j].name().equals(method.name()) && methods[j].signature().equals(method.signature())) { return intfacs[i]; } } } } return null; }
for (ClassDoc classDoc : ROOTDOC.classes()) { String type = classDoc.qualifiedTypeName(); String comment = filter.filterAndTruncate(classDoc.commentText()); String pathToSourceFile = classDoc.position().file().getCanonicalPath();
public static ClassDocumentation fromClassDoc(ClassDoc classDoc) { ClassDocumentation cd = new ClassDocumentation(); cd.setComment(classDoc.commentText()); for (FieldDoc fieldDoc : classDoc.fields(false)) { cd.addField(fieldDoc); } for (MethodDoc methodDoc : classDoc.methods(false)) { cd.addMethod(methodDoc); } return cd; }
public static boolean start(RootDoc rootDoc) throws Exception { final String output = getOptionArg(rootDoc.options(), OPTION_OUTPUT); JsonSchemaDocs rootSchemaDocs = new JsonSchemaDocs(); List<SchemaClassDoc> schemaClassDocs = new ArrayList<SchemaClassDoc>(); for (ClassDoc classDoc : rootDoc.classes()) { SchemaClassDoc schemaClassDoc = new SchemaClassDoc(); schemaClassDoc.setClassName(classDoc.qualifiedTypeName()); schemaClassDoc.setClassDoc(getDocWithIncludes(classDoc)); schemaClassDoc.setClassTitle(getTitle(classDoc)); List<SchemaFieldDoc> schemaFieldDocs = new ArrayList<SchemaFieldDoc>(); addFieldDocs(classDoc, schemaFieldDocs, new HashMap<String, String>()); schemaClassDoc.setFieldDocs(schemaFieldDocs); schemaClassDocs.add(schemaClassDoc); } rootSchemaDocs.setClassDocs(schemaClassDocs); Gson gson = new Gson(); try { Files.write(gson.toJson(rootSchemaDocs), new File(output), Charsets.UTF_8); } catch (IOException e) { e.printStackTrace(); return false; } return true; }