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 String getLongDescription() { return fieldDoc != null ? fieldDoc.commentText() : ""; } }
/** * Check to see if overview details should be printed. If * nocomment option set or if there is no text to be printed * for deprecation info, comment or tags, do not print overview details. * * @param field the field to check overview details for. * @return true if overview details need to be printed */ public boolean shouldPrintOverview(FieldDoc field) { if (!configuration.nocomment) { if(!field.commentText().isEmpty() || writer.hasSerializationOverviewTags(field)) return true; } if (field.tags("deprecated").length > 0) return true; return false; } }
root.put("fulltext", fieldDoc.commentText());
/** * Check to see if overview details should be printed. If * nocomment option set or if there is no text to be printed * for deprecation info, comment or tags, do not print overview details. * * @param field the field to check overview details for. * @return true if overview details need to be printed */ public boolean shouldPrintOverview(FieldDoc field) { if (!configuration().nocomment) { if(!field.commentText().isEmpty() || writer.hasSerializationOverviewTags(field)) return true; } if (field.tags("deprecated").length > 0) return true; return false; }
private static Entry<String, String> createParameterRow(FieldDoc field) { Tag[] tags = field.tags("@" + ConfigurationParameters.NAME); if (tags.length == 0) { return null; } String name = wrapWithTag("td", field.constantValue(), "padding-right: 20px"); String desc = wrapWithTag("td", field.commentText(), "padding-right: 20px"); StringBuilder defaultValues = new StringBuilder(""); for (Tag tag : tags) { defaultValues.append(tag.text()); defaultValues.append("<br />"); } String values = wrapWithTag("td", defaultValues.toString(), null); String row = wrapWithTag("tr", name + desc + values, null); return new AbstractMap.SimpleEntry<>(field.constantValue().toString(), row); }
public static FieldDocumentation fromFieldDoc(FieldDoc fieldDoc) { FieldDocumentation fd = new FieldDocumentation(); fd.comment = fieldDoc.commentText(); for (Tag tag : fieldDoc.tags()) { fd.tags.put(cleanupTagName(tag.name()), tag.text()); } return fd; }
root.put("fulltext", fieldDoc.commentText());
String originalText = fieldDoc.commentText(); Tag[] originalInlineTags = fieldDoc.inlineTags(); revertInlineTags = true; else if (Strings.isNullOrEmpty(fieldDoc.commentText()))
/** * Helper routine that provides a FreeMarker map for an enumClass, grabbing the * values of the enum and their associated javadoc documentation. * * @param enumClass * @return */ @Requires("enumClass.isEnum()") private List<Map<String, Object>> docForEnumArgument(final Class enumClass) { final ClassDoc doc = this.getDoclet().getClassDocForClass(enumClass); if ( doc == null ) throw new RuntimeException("Tried to get docs for enum " + enumClass + " but got null instead"); final Set<String> enumConstantFieldNames = enumConstantsNames(enumClass); final List<Map<String, Object>> bindings = new ArrayList<Map<String, Object>>(); for (final FieldDoc fieldDoc : doc.fields(false)) { if (enumConstantFieldNames.contains(fieldDoc.name()) ) bindings.add( new HashMap<String, Object>() {{ put("name", fieldDoc.name()); put("summary", fieldDoc.commentText()); }}); } return bindings; }
/** * Helper routine that provides a FreeMarker map for an enumClass, grabbing the * values of the enum and their associated javadoc documentation. * * @param enumClass * @return */ private List<Map<String, Object>> docForEnumArgument(final Class<?> enumClass) { final ClassDoc doc = this.getDoclet().getClassDocForClass(enumClass); if ( doc == null ) { throw new RuntimeException("Tried to get docs for enum " + enumClass + " but got null instead"); } final Set<String> enumConstantFieldNames = enumConstantsNames(enumClass); final List<Map<String, Object>> bindings = new ArrayList<Map<String, Object>>(); for (final FieldDoc fieldDoc : doc.fields(false)) { if (enumConstantFieldNames.contains(fieldDoc.name()) ) { bindings.add( new HashMap<String, Object>() { static final long serialVersionUID = 0L; { put("name", fieldDoc.name()); put("summary", fieldDoc.commentText()); } } ); } } return bindings; }
resultDoc.setType(fieldDoc.type().typeName()); addRefType(classDoc, DocletUtil.getFieldByDoc(resultClassDoc, fieldDoc).getGenericType() , resultDoc); String[] paramTexts = fieldDoc.commentText().split("(e.g|eg|e.g.|example|exam|例如|如)(:|:)", 2); resultDoc.setDesc(paramTexts[0]); resultDoc.setExampleValue(paramTexts.length==2 ? paramTexts[1] : "");
/** * Parses an enum type definition * * @param fieldDoc * @return */ protected EnumConstant parseEnumConstant(FieldDoc fieldDoc) { EnumConstant enumConstant = objectFactory.createEnumConstant(); enumConstant.setName(fieldDoc.name()); String comment = fieldDoc.commentText(); if (comment.length() > 0) { enumConstant.setComment(comment); } for (AnnotationDesc annotationDesc : fieldDoc.annotations()) { enumConstant.getAnnotation().add(parseAnnotationDesc(annotationDesc, fieldDoc.qualifiedName())); } for (Tag tag : fieldDoc.tags()) { enumConstant.getTag().add(parseTag(tag)); } return enumConstant; }
protected Field parseField(FieldDoc fieldDoc) { Field fieldNode = objectFactory.createField(); fieldNode.setType(parseTypeInfo(fieldDoc.type())); fieldNode.setName(fieldDoc.name()); fieldNode.setQualified(fieldDoc.qualifiedName()); String comment = fieldDoc.commentText(); if (comment.length() > 0) { fieldNode.setComment(comment); } fieldNode.setScope(parseScope(fieldDoc)); fieldNode.setFinal(fieldDoc.isFinal()); fieldNode.setStatic(fieldDoc.isStatic()); fieldNode.setVolatile(fieldDoc.isVolatile()); fieldNode.setTransient(fieldDoc.isTransient()); fieldNode.setConstant(fieldDoc.constantValueExpression()); for (AnnotationDesc annotationDesc : fieldDoc.annotations()) { fieldNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, fieldDoc.qualifiedName())); } for (Tag tag : fieldDoc.tags()) { fieldNode.getTag().add(parseTag(tag)); } return fieldNode; }
if (fieldDoc != null) { paramDoc.setType(fieldDoc==null ? "" : fieldDoc.type().typeName()); String[] paramTexts = fieldDoc.commentText().split("(e.g|eg|e.g.|example|exam|例如|如)(:|:)", 2); paramDoc.setDesc(paramTexts[0]); paramDoc.setExampleValue(paramTexts.length==2 ? paramTexts[1] : "");
factory.constructTagDocumentation( result, fieldDoc.commentText() );