final ClassDocType classDocType = new ClassDocType(); classDocType.setClassName(classDoc.qualifiedTypeName()); classDocType.setCommentText(classDoc.commentText()); docProcessor.processClassDoc(classDoc, classDocType);
/** * 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(""); }
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; }
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(); } } }
for (ClassDoc classDoc : ROOTDOC.classes()) { String type = classDoc.qualifiedTypeName(); String comment = filter.filterAndTruncate(classDoc.commentText()); String pathToSourceFile = classDoc.position().file().getCanonicalPath();
public String commentText() { return wrapped.commentText(); }
public String getLongDescription() { return classDoc.commentText(); }
/** * Is the javadoc for the given class missing? * @param classDoc Class for which to inspect the JavaDoc. * @return True if the JavaDoc is missing. False otherwise. */ private static boolean isRequiredJavadocMissing(ClassDoc classDoc) { return classDoc.commentText().length() == 0 || classDoc.commentText().contains("Created by IntelliJ"); }
@Override public String getClassDoc(Class<?> resourceClass) { final ClassDoc doc = _doclet.getClassDoc(resourceClass); if (doc == null) { return null; } return buildDoc(doc.commentText()); }
@Override public void processOperator(OperatorDesc operatorDesc) throws Exception { ClassDoc typeDoc = operatorDesc.getClassDoc(); StringBuilder sb = new StringBuilder(300); sb.append(String.format("Operator: %s\n", typeDoc.typeName())); sb.append(String.format("\tClass: %s\n", typeDoc.qualifiedTypeName())); sb.append(String.format("\tText: %s\n", typeDoc.commentText())); writeClassAnnotiations(typeDoc, sb); FieldDoc[] fieldDocs = typeDoc.fields(false); for (FieldDoc fieldDoc : fieldDocs) { writeFieldAnnotiations(fieldDoc, sb); } System.out.println(sb.toString()); }
/** * Add high-level summary information about toProcess to root, such as its * name, summary, description, version, etc. * * @param root */ protected void addHighLevelBindings(Map<String, Object> root) { root.put("name", toProcess.classDoc.name()); // Extract overrides from the doc tags. StringBuilder summaryBuilder = new StringBuilder(); for (Tag tag : toProcess.classDoc.firstSentenceTags()) summaryBuilder.append(tag.text()); root.put("summary", summaryBuilder.toString()); root.put("description", toProcess.classDoc.commentText().substring(summaryBuilder.toString().length())); root.put("timestamp", toProcess.buildTimestamp); root.put("version", toProcess.absoluteVersion); for (Tag tag : toProcess.classDoc.tags()) { root.put(tag.name(), tag.text()); } }
/** * 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(""); }
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; }
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; }
@Override public void print() throws IOException { Map<String, ClassDoc> classDocs = getAllClassDocs(); for (String className : classes) { ClassDoc classDoc = classDocs.get(className); if (classDoc == null) continue; SortedSet<MethodDoc> methods = Sets.newTreeSet(new MethodComparator()); // Iterate methods and sort them for (MethodDoc method : classDoc.methods(false)) { methods.add(method); } appendNewline("# %s", StringUtils.substringAfterLast("." + classDoc.name(), ".")); appendNewline(); appendNewline(asMarkdown(classDoc.commentText())); appendNewline(); for (MethodDoc method : methods) { printMarkDown(method); } } }
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; }
typeDoc.setName(resultClz.getSimpleName()); typeDoc.setQualifiedTypeName(resultClz.getName()); typeDoc.setDesc(resultClassDoc.commentText());
category.setDesc(classDoc.commentText()); String tagName = getTagText(classDoc, "summary", true); category.setName(StringUtils.isEmpty(tagName) ? classDoc.commentText() : tagName); apiCategorys.add(category);
protected Interface parseInterface(ClassDoc classDoc) { Interface interfaceNode = objectFactory.createInterface(); interfaceNode.setName(classDoc.name()); interfaceNode.setQualified(classDoc.qualifiedName()); String comment = classDoc.commentText(); if (comment.length() > 0) { interfaceNode.setComment(comment); } interfaceNode.setIncluded(classDoc.isIncluded()); interfaceNode.setScope(parseScope(classDoc)); for (TypeVariable typeVariable : classDoc.typeParameters()) { interfaceNode.getGeneric().add(parseTypeParameter(typeVariable)); } for (Type interfaceType : classDoc.interfaceTypes()) { interfaceNode.getInterface().add(parseTypeInfo(interfaceType)); } for (MethodDoc method : classDoc.methods()) { interfaceNode.getMethod().add(parseMethod(method)); } for (AnnotationDesc annotationDesc : classDoc.annotations()) { interfaceNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, classDoc.qualifiedName())); } for (Tag tag : classDoc.tags()) { interfaceNode.getTag().add(parseTag(tag)); } for (FieldDoc field : classDoc.fields()) { interfaceNode.getField().add(parseField(field)); } return interfaceNode; }
protected Enum parseEnum(ClassDoc classDoc) { Enum enumNode = objectFactory.createEnum(); enumNode.setName(classDoc.name()); enumNode.setQualified(classDoc.qualifiedName()); String comment = classDoc.commentText(); if (comment.length() > 0) { enumNode.setComment(comment); } enumNode.setIncluded(classDoc.isIncluded()); enumNode.setScope(parseScope(classDoc)); Type superClassType = classDoc.superclassType(); if (superClassType != null) { enumNode.setClazz(parseTypeInfo(superClassType)); } for (Type interfaceType : classDoc.interfaceTypes()) { enumNode.getInterface().add(parseTypeInfo(interfaceType)); } for (FieldDoc field : classDoc.enumConstants()) { enumNode.getConstant().add(parseEnumConstant(field)); } for (AnnotationDesc annotationDesc : classDoc.annotations()) { enumNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, classDoc.qualifiedName())); } for (Tag tag : classDoc.tags()) { enumNode.getTag().add(parseTag(tag)); } return enumNode; }