@Override public DocTag converter(SeeTag o) { ClassDoc aClass = o.referencedClass().findClass(o.referencedClassName()); String text = aClass.commentText(); String classType = aClass.qualifiedTypeName(); try { Class<?> classz = Class.forName(classType); List<FieldInfo> fields = analysisFields(classz, aClass); ObjectInfo objectInfo = new ObjectInfo(); objectInfo.setType(Class.forName(classType)); objectInfo.setFieldInfos(fields); objectInfo.setComment(text); return new SeeTagImpl(o.name(), objectInfo); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; }
/** * This methods will process the given ``inlineTags`` * comment text, by replacing each link tags * by effective markdown link. * * @param inlineTags Inline tags to generate description from. */ public void description(final Tag [] inlineTags) { for (final Tag tag : inlineTags) { if (("Text").equals(tag.name())) { text(tag.text()); } else if (("@link").equals(tag.name())) { final SeeTag seeTag = (SeeTag) tag; final ClassDoc classDoc = seeTag.referencedClass(); if (classDoc != null) { classLink(source, classDoc); } else { // TODO : Process other link type here. text(tag.text()); } } } }
private static String getFirstSentence(Doc doc) { Tag[] tags = doc.firstSentenceTags(); if (tags.length == 0) { return null; } StringBuilder buffer = new StringBuilder(); for (Tag tag : tags) { if (tag instanceof SeeTag) { buffer.append("{"); buffer.append(tag.name()); buffer.append(" "); buffer.append(((SeeTag)tag).referencedClassName()); buffer.append("}"); } else { buffer.append(tag.text()); } } return buffer.toString(); }
public Vector getSeeTags() { // adjust the path, so the links get build correctly docWriter.relativePath = getPathToRoot(); Doc pack = (Doc) getVariables().get("curitem"); Tag[] tags = pack.tags("see"); Vector results = new Vector(); for (int i = 0; i != tags.length; i++) { SeeTag tag = (SeeTag) tags[i]; String link = docWriter.seeTagToString(tag); results.add(link); } return results; }
public String getTagText(Tag tag) { if (tag.name().equals("@see")) { try { return docWriter.seeTagToString((SeeTag) tag); } catch (ClassCastException e) { System.err.println("Error bulding @see tag " + tag.name()); return tag.text(); } } else if (tag.name().equals("@param")) { return buildParamTagText((ParamTag) tag); } else if (tag.name().equals("@throws") || tag.name().equals("@exception")) { return buildThrowTag((ThrowsTag) tag); } return tag.text(); }
/** * Transforms comments on the Doc object into XML. * * @param doc The Doc object. * @param node The node to add the comment nodes to. */ private static List<XMLNode> toSeeNodes(SeeTag[] tags) { if (tags == null || tags.length == 0) return Collections.emptyList(); List<XMLNode> nodes = new ArrayList<XMLNode>(tags.length); for (SeeTag tag : tags) { XMLNode n = toSeeNode(tag); if (n != null) { nodes.add(n); } } // Add the node to the host return nodes; }
protected Package parsePackage(PackageDoc packageDoc) { Package packageNode = objectFactory.createPackage(); packageNode.setName(packageDoc.name()); packageNode.setIdentifier(parseIdentifier((Doc) packageDoc)); packageNode.setComment(parseComment(packageDoc)); Tag[] tags; SeeTag[] seeTags; tags = packageDoc.tags("@deprecated"); if (tags.length > 0) { packageNode.setDeprecated(parseComment(tags[0])); } tags = packageDoc.tags("@since"); if (tags.length > 0) { packageNode.setSince(tags[0].text()); } tags = packageDoc.tags("@version"); if (tags.length > 0) { packageNode.setVersion(tags[0].text()); } seeTags = packageDoc.seeTags(); for (int i = 0; i < seeTags.length; i++) { packageNode.getLink().add(parseLink(seeTags[i])); } return packageNode; }
/** * Parses an enum type definition * * @param fieldDoc * @return */ protected EnumValue parseEnumValue(FieldDoc fieldDoc) { EnumValue enumValue = objectFactory.createEnumValue(); enumValue.setName(fieldDoc.name()); enumValue.setIdentifier(parseIdentifier((Doc) fieldDoc)); enumValue.setId(fieldDoc.name()); enumValue.setComment(parseComment(fieldDoc)); Tag[] tags; SeeTag[] seeTags; tags = fieldDoc.tags("@deprecated"); if (tags.length > 0) { enumValue.setDeprecated(parseComment(tags[0])); } tags = fieldDoc.tags("@since"); if (tags.length > 0) { enumValue.setSince(tags[0].text()); } tags = fieldDoc.tags("@version"); if (tags.length > 0) { enumValue.setVersion(tags[0].text()); } seeTags = fieldDoc.seeTags(); for (int i = 0; i < seeTags.length; i++) { enumValue.getLink().add(parseLink(seeTags[i])); } return enumValue; }
/** * Transforms comments on the Doc object into XML. * * @param doc The Doc object. * @param node The node to add the comment nodes to. */ private static List<XMLNode> toSeeNodes(SeeTag[] tags) { if (tags == null || tags.length == 0) return Collections.emptyList(); List<XMLNode> nodes = new ArrayList<XMLNode>(tags.length); for (SeeTag tag : tags) { XMLNode n = toSeeNode(tag); if (n != null) nodes.add(n); } // Add the node to the host return nodes; }
/** * Parse an annotation. * * @param annotationTypeDoc * A AnnotationTypeDoc instance * @return the annotation node */ protected Annotation parseAnnotationTypeDoc(ClassDoc classDoc) { Annotation annotationNode = objectFactory.createAnnotation(); annotationNode.setName(classDoc.name()); annotationNode.setDisplayName(classDoc.simpleTypeName()); annotationNode.setIdentifier(parseIdentifier((Doc) classDoc)); annotationNode.setFull(classDoc.qualifiedName()); annotationNode.setComment(parseComment(classDoc)); annotationNode.setScope(parseScope(classDoc)); Tag[] tags; SeeTag[] seeTags; tags = classDoc.tags("@deprecated"); if (tags.length > 0) { annotationNode.setDeprecated(parseComment(tags[0])); } tags = classDoc.tags("@since"); if (tags.length > 0) { annotationNode.setSince(tags[0].text()); } tags = classDoc.tags("@version"); if (tags.length > 0) { annotationNode.setVersion(tags[0].text()); } tags = classDoc.tags("@author"); for (int i = 0; i < tags.length; i++) { annotationNode.getAuthor().add(tags[i].text()); } seeTags = classDoc.seeTags(); for (int i = 0; i < seeTags.length; i++) { annotationNode.getLink().add(parseLink(seeTags[i])); } for (AnnotationTypeElementDoc annotationTypeElementDoc : ((AnnotationTypeDoc) classDoc).elements()) { annotationNode.getElement().add(parseAnnotationTypeElementDoc(annotationTypeElementDoc)); } return annotationNode; }
/** * Parse the elements of an annotation * * @param element * A AnnotationTypeElementDoc instance * @return the annotation element node */ protected AnnotationElement parseAnnotationTypeElementDoc(AnnotationTypeElementDoc annotationTypeElementDoc) { AnnotationElement annotationElementNode = objectFactory.createAnnotationElement(); annotationElementNode.setName(annotationTypeElementDoc.name()); annotationElementNode.setIdentifier(parseIdentifier((Doc) annotationTypeElementDoc)); annotationElementNode.setId(annotationTypeElementDoc.name()); annotationElementNode.setFull(annotationTypeElementDoc.qualifiedName()); annotationElementNode.setComment(parseComment(annotationTypeElementDoc)); AnnotationValue value = annotationTypeElementDoc.defaultValue(); if (value != null) { annotationElementNode.setDefault(value.toString()); } Tag[] tags; SeeTag[] seeTags; tags = annotationTypeElementDoc.tags("@deprecated"); if (tags.length > 0) { annotationElementNode.setDeprecated(parseComment(tags[0])); } tags = annotationTypeElementDoc.tags("@since"); if (tags.length > 0) { annotationElementNode.setSince(tags[0].text()); } tags = annotationTypeElementDoc.tags("@version"); if (tags.length > 0) { annotationElementNode.setVersion(tags[0].text()); } Return returnNode = objectFactory.createReturn(); tags = annotationTypeElementDoc.tags("@return"); if (tags.length > 0) { returnNode.setComment(parseComment(tags[0])); } returnNode.setType(parseTypeInfo(annotationTypeElementDoc.returnType())); annotationElementNode.setReturn(returnNode); seeTags = annotationTypeElementDoc.seeTags(); for (int i = 0; i < seeTags.length; i++) { annotationElementNode.getLink().add(parseLink(seeTags[i])); } return annotationElementNode; }
protected Interface parseInterface(ClassDoc classDoc) { Interface interfaceNode = objectFactory.createInterface(); interfaceNode.setName(classDoc.name()); interfaceNode.setDisplayName(classDoc.simpleTypeName()); interfaceNode.setIdentifier(parseIdentifier((Doc) classDoc)); interfaceNode.setFull(classDoc.qualifiedName()); interfaceNode.setComment(parseComment(classDoc)); interfaceNode.setScope(parseScope(classDoc)); for (TypeVariable typeVariable : classDoc.typeParameters()) { interfaceNode.getGeneric().add(parseGeneric(typeVariable)); } for (Type interfaceType : classDoc.interfaceTypes()) { interfaceNode.getInterface().add(parseTypeInfo(interfaceType)); } for (MethodDoc method : classDoc.methods()) { interfaceNode.getMethod().add(parseMethod(method)); } Tag[] tags; SeeTag[] seeTags; tags = classDoc.tags("@deprecated"); if (tags.length > 0) { interfaceNode.setDeprecated(parseComment(tags[0])); } tags = classDoc.tags("@since"); if (tags.length > 0) { interfaceNode.setSince(tags[0].text()); } tags = classDoc.tags("@version"); if (tags.length > 0) { interfaceNode.setVersion(tags[0].text()); } seeTags = classDoc.seeTags(); for (int i = 0; i < seeTags.length; i++) { interfaceNode.getLink().add(parseLink(seeTags[i])); } return interfaceNode; }
protected Class parseClass(ClassDoc classDoc) { Class classNode = objectFactory.createClass(); classNode.setName(classDoc.name()); classNode.setDisplayName(classDoc.simpleTypeName()); classNode.setIdentifier(parseIdentifier((Doc) classDoc)); classNode.setFull(classDoc.qualifiedName()); classNode.setComment(parseComment(classDoc)); classNode.setAbstract(classDoc.isAbstract()); classNode.setError(classDoc.isError()); classNode.setException(classDoc.isException()); classNode.setExternalizable(classDoc.isExternalizable()); classNode.setSerializable(classDoc.isSerializable()); classNode.setScope(parseScope(classDoc)); for (TypeVariable typeVariable : classDoc.typeParameters()) { classNode.getGeneric().add(parseGeneric(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 (ConstructorDoc constructor : classDoc.constructors()) { classNode.getConstructor().add(parseConstructor(constructor)); } for (FieldDoc field : classDoc.fields()) { classNode.getField().add(parseField(field)); } Tag[] tags; SeeTag[] seeTags; tags = classDoc.tags("@deprecated"); if (tags.length > 0) { classNode.setDeprecated(parseComment(tags[0])); } tags = classDoc.tags("@since"); if (tags.length > 0) { classNode.setSince(tags[0].text()); } tags = classDoc.tags("@version"); if (tags.length > 0) { classNode.setVersion(tags[0].text()); } tags = classDoc.tags("@author"); for (int i = 0; i < tags.length; i++) { classNode.getAuthor().add(tags[i].text()); } seeTags = classDoc.seeTags(); for (int i = 0; i < seeTags.length; i++) { classNode.getLink().add(parseLink(seeTags[i])); } return classNode; }
protected Field parseField(FieldDoc fieldDoc) { Field fieldNode = objectFactory.createField(); fieldNode.setName(fieldDoc.name()); fieldNode.setIdentifier(parseIdentifier((FieldDoc) fieldDoc)); fieldNode.setId(fieldDoc.name()); fieldNode.setFull(fieldDoc.qualifiedName()); fieldNode.setComment(parseComment(fieldDoc)); fieldNode.setScope(parseScope(fieldDoc)); fieldNode.setFinal(fieldDoc.isFinal()); fieldNode.setStatic(fieldDoc.isStatic()); fieldNode.setVolatile(fieldDoc.isVolatile()); fieldNode.setTransient(fieldDoc.isTransient()); fieldNode.setDefault(fieldDoc.constantValueExpression()); Tag[] tags; SeeTag[] seeTags; Return returnNode = objectFactory.createReturn(); tags = fieldDoc.tags("@return"); if (tags.length > 0) { returnNode.setComment(parseComment(tags[0])); } returnNode.setType(parseTypeInfo(fieldDoc.type())); fieldNode.setReturn(returnNode); tags = fieldDoc.tags("@deprecated"); if (tags.length > 0) { fieldNode.setDeprecated(parseComment(tags[0])); } tags = fieldDoc.tags("@since"); if (tags.length > 0) { fieldNode.setSince(tags[0].text()); } tags = fieldDoc.tags("@version"); if (tags.length > 0) { fieldNode.setVersion(tags[0].text()); } seeTags = fieldDoc.seeTags(); for (int i = 0; i < seeTags.length; i++) { fieldNode.getLink().add(parseLink(seeTags[i])); } return fieldNode; }
@Override public SeeTag[] seeTags() { return delegate.seeTags(); }
public SeeTag[] seeTags() { return new SeeTag[0]; }