Refine search
LOG.fine("Writing class " + classDoc.qualifiedTypeName()); final ClassDocType classDocType = new ClassDocType(); classDocType.setClassName(classDoc.qualifiedTypeName()); classDocType.setCommentText(classDoc.commentText()); docProcessor.processClassDoc(classDoc, classDocType); methodDocType.setMethodName(methodDoc.name()); methodDocType.setMethodSignature(methodDoc.signature()); methodDocType.setCommentText(methodDoc.commentText()); docProcessor.processMethodDoc(methodDoc, methodDocType);
/** * 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]); }
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) 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; }
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();
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]); 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);
import com.sun.javadoc.ClassDoc; import com.sun.javadoc.Doclet; import com.sun.javadoc.MethodDoc; import com.sun.javadoc.RootDoc; import com.sun.tools.javadoc.Main; public class DocletTest { public static void main(String[] args) { Main.execute("", Analyzer.class.getName(), new String[] {"path/to/your/file.java"}); } public static class Analyzer extends Doclet { public static boolean start(RootDoc root) { for (ClassDoc classDoc : root.classes()) { System.out.println("Class: " + classDoc.qualifiedName()); for (MethodDoc methodDoc : classDoc.methods()) { System.out.println(" " + methodDoc.returnType() + " " + methodDoc.name() + methodDoc.signature()); } } return false; } } }
result = factory.constructOperation( doc.name() ); result.setSpecification( false ); // assume the method exists, so it is not a specification result.setQuery( false ); // assume the method is not read-only factory.constructTagDocumentation( result, doc.commentText() ); if ( doc.isPublic() ) { result.setVisibility( VisibilityKindEnum.VK_PUBLIC ); } else if ( doc.isPrivate() ) { result.setVisibility( VisibilityKindEnum.VK_PRIVATE ); } else if ( doc.isProtected() ) { result.setVisibility( VisibilityKindEnum.VK_PROTECTED ); if ( doc.isStatic() ) { result.setOwnerScope( ScopeKindEnum.SK_CLASSIFIER ); } else { result.setAbstract( doc.isAbstract() ); result.setLeaf( doc.isFinal() ); if ( doc.isSynchronized() ) { result.setConcurrency( CallConcurrencyKindEnum.CCK_SEQUENTIAL ); } else { parameters = doc.parameters(); parameterTags = doc.paramTags(); parameterTypeDoc = doc.returnType();
/** * Build the method tags. */ public void buildMethodTags() { methodWriter.writeMemberTags((MethodDoc) currentMember); MethodDoc method = (MethodDoc)currentMember; if (method.name().compareTo("writeExternal") == 0 && method.tags("serialData").length == 0) { if (configuration.serialwarn) { configuration.getDocletSpecificMsg().warning( currentMember.position(), "doclet.MissingSerialDataTag", method.containingClass().qualifiedName(), method.name()); } } }
ApiEntryNotes entryNotes = new ApiEntryNotes().setName(classDoc.qualifiedName()); for (MethodDoc methodDoc : classDoc.methods()) { for (AnnotationDesc annotationDesc : methodDoc.annotations()) { if (annotationDesc.annotationType().qualifiedName().startsWith("restx.annotations.")) { Optional<Object> value = getAnnotationParamValue(annotationDesc.elementValues(), "value"); trace.trace(classDoc.name() + " > " + methodDoc.qualifiedName() + " > " + annotationDesc.annotationType().name()); trace.trace(asList(annotationDesc.elementValues()).toString()); trace.trace(methodDoc.commentText()); .setNotes(methodDoc.commentText()); for (ParamTag paramTag : methodDoc.paramTags()) { trace.trace("\t" + paramTag.parameterName() + " > " + paramTag.parameterComment()); for (Tag aReturn : methodDoc.tags("return")) { trace.trace("\t" + aReturn.name() + " > " + aReturn.text());
/** * The documentation for values() and valueOf() in Enums are set by the * doclet. */ public static void setEnumDocumentation(Configuration configuration, ClassDoc classDoc) { MethodDoc[] methods = classDoc.methods(); for (int j = 0; j < methods.length; j++) { MethodDoc currentMethod = methods[j]; if (currentMethod.name().equals("values") && currentMethod.parameters().length == 0) { currentMethod.setRawCommentText( configuration.getText("doclet.enum_values_doc", classDoc.name())); } else if (currentMethod.name().equals("valueOf") && currentMethod.parameters().length == 1) { Type paramType = currentMethod.parameters()[0].type(); if (paramType != null && paramType.qualifiedTypeName().equals(String.class.getName())) { currentMethod.setRawCommentText( configuration.getText("doclet.enum_valueof_doc")); } } } }
methodNode.setName(methodDoc.name()); methodNode.setQualified(methodDoc.qualifiedName()); String comment = methodDoc.commentText(); if (comment.length() > 0) { methodNode.setComment(comment); 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));
/** * 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(""); }
protected ApiElement printMethod(MethodDoc method) throws IOException { ApiElement element = new ApiElement(); element.setCaption(String.format("%s(%s)", method.name(), parameters(method.parameters()))); element.setContent(String.format("%s(%s)", method.name(), placeholders(method.parameters()))); StringBuilder sb = new StringBuilder(); String comment = !method.commentText().isEmpty() ? removeImagesTags(method.commentText().replaceAll("[\\n]+", "\n")) + "\n" : ""; sb.append(comment); if (method.paramTags().length > 0) { sb.append("<table>"); sb.append("<tr><th>Parameter</th> <th>Description</th></tr>"); for (ParamTag param : method.paramTags()) { sb.append(String.format("<tr> <th> %s </th> <th> %s </th></tr>", param.parameterName(), asMarkdown(param.parameterComment()))); } sb.append("</table>"); } for (Tag t : method.tags("return")) { String text = t.text(); if (text != null) { sb.append(String.format("-<strong>returns:</strong> %s \n", asMarkdown(text))); } } for (Tag t : method.tags("see")) { String text = t.text(); if (text != null) { sb.append(String.format("-<strong>see:</strong> %s \n", asMarkdown(text))); } } element.setDescription(sb.toString()); return element; }
cd.qualifiedName()); try { implClass = root.getClass().getClassLoader().loadClass(cd.qualifiedTypeName()); implMethods = implClass.getMethods(); final MethodDoc[] methods = cd.methods(); expression.setDescription(md.commentText().replaceAll("\n", " ")); final Parameter[] parameters = md.parameters(); if (parameters != null && parameters.length > 0) { for (final Parameter p : parameters) {
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; }
private static void addFieldDocs(ClassDoc classDoc, List<SchemaFieldDoc> schemaFieldDocs, Map<String, String> fieldDocOverrides) throws NoSuchFieldException, IllegalAccessException if (null == classDoc || Object.class.getName().equals(classDoc.qualifiedName())) for (FieldDoc fieldDoc : classDoc.fields()) if (null != accessor && !Strings.isNullOrEmpty(accessor.commentText())) addFieldDocs(classDoc.superclass(), schemaFieldDocs, fieldDocOverrides);
/** Print the class's operations m */ private boolean operations(Options opt, MethodDoc m[]) { boolean printed = false; for (MethodDoc md : m) { if (hidden(md)) continue; // Filter-out static initializer method if (md.name().equals("<clinit>") && md.isStatic() && md.isPackagePrivate()) continue; stereotype(opt, md, Align.LEFT); String op = visibility(opt, md) + md.name() + // (opt.showType ? "(" + parameter(opt, md.parameters()) + ")" + typeAnnotation(opt, md.returnType()) : "()"); tableLine(Align.LEFT, (md.isAbstract() ? Font.ABSTRACT : Font.NORMAL).wrap(opt, op)); printed = true; tagvalue(opt, md); } return printed; }
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; } }
private MethodDoc setterForField(MethodDoc[] methods, MethodDoc propertyMethod) { final String propertyMethodName = propertyMethod.name(); final String fieldName = propertyMethodName.substring(0, propertyMethodName.lastIndexOf("Property")); final String fieldNameUppercased = "" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); final String setter = "set" + fieldNameUppercased; for (MethodDoc methodDoc : methods) { if (setter.equals(methodDoc.name())) { if (1 == methodDoc.parameters().length && "void".equals(methodDoc.returnType().simpleTypeName()) && (methodDoc.isPublic() || methodDoc.isProtected())) { return methodDoc; } } } return null; }