Improvements to GATKDocs
-- Now supports a static list of root classes / interfaces that should receive docs. A complementary approach to documenting features to the DocumentedGATKFeature annotation -- Tribble codecs are now documented! -- No longer displayed sub and super classes
This commit is contained in:
parent
e03db30ca0
commit
5772766dd5
|
|
@ -30,17 +30,24 @@ package org.broadinstitute.sting.utils.help;
|
||||||
* @author depristo
|
* @author depristo
|
||||||
*/
|
*/
|
||||||
class DocumentedGATKFeatureObject {
|
class DocumentedGATKFeatureObject {
|
||||||
final boolean enable;
|
private final Class classToDoc;
|
||||||
final String groupName, summary;
|
private final boolean enable;
|
||||||
final Class[] extraDocs;
|
private final String groupName, summary;
|
||||||
|
private final Class[] extraDocs;
|
||||||
|
|
||||||
public DocumentedGATKFeatureObject(final boolean enable, final String groupName, final String summary, final Class[] extraDocs) {
|
public DocumentedGATKFeatureObject(Class classToDoc, final boolean enable, final String groupName, final String summary, final Class[] extraDocs) {
|
||||||
|
this.classToDoc = classToDoc;
|
||||||
this.enable = enable;
|
this.enable = enable;
|
||||||
this.groupName = groupName;
|
this.groupName = groupName;
|
||||||
this.summary = summary;
|
this.summary = summary;
|
||||||
this.extraDocs = extraDocs;
|
this.extraDocs = extraDocs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DocumentedGATKFeatureObject(Class classToDoc, final String groupName, final String summary) {
|
||||||
|
this(classToDoc, true, groupName, summary, new Class[]{});
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class getClassToDoc() { return classToDoc; }
|
||||||
public boolean enable() { return enable; }
|
public boolean enable() { return enable; }
|
||||||
public String groupName() { return groupName; }
|
public String groupName() { return groupName; }
|
||||||
public String summary() { return summary; }
|
public String summary() { return summary; }
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import freemarker.template.TemplateException;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.log4j.Level;
|
import org.apache.log4j.Level;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.broad.tribble.FeatureCodec;
|
||||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
@ -50,6 +51,14 @@ public class GATKDoclet {
|
||||||
|
|
||||||
RootDoc rootDoc;
|
RootDoc rootDoc;
|
||||||
|
|
||||||
|
final static Collection<DocumentedGATKFeatureObject> STATIC_DOCS = new ArrayList<DocumentedGATKFeatureObject>();
|
||||||
|
static {
|
||||||
|
STATIC_DOCS.add(new DocumentedGATKFeatureObject(FeatureCodec.class,
|
||||||
|
"Reference ordered data (ROD) codecs",
|
||||||
|
"Tribble codecs for reading reference ordered data such as VCF or BED files"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the contents of certain types of javadoc and adds them to an XML file.
|
* Extracts the contents of certain types of javadoc and adds them to an XML file.
|
||||||
* @param rootDoc The documentation root.
|
* @param rootDoc The documentation root.
|
||||||
|
|
@ -162,12 +171,20 @@ public class GATKDoclet {
|
||||||
|
|
||||||
private DocumentedGATKFeatureObject getFeatureForClassDoc(ClassDoc doc) {
|
private DocumentedGATKFeatureObject getFeatureForClassDoc(ClassDoc doc) {
|
||||||
Class<? extends Object> docClass = getClassForClassDoc(doc);
|
Class<? extends Object> docClass = getClassForClassDoc(doc);
|
||||||
// todo -- add looked here to static TO DOC collection as well
|
|
||||||
if ( docClass != null && docClass.isAnnotationPresent(DocumentedGATKFeature.class) ) {
|
if ( docClass == null )
|
||||||
DocumentedGATKFeature f = docClass.getAnnotation(DocumentedGATKFeature.class);
|
|
||||||
return new DocumentedGATKFeatureObject(f.enable(), f.groupName(), f.summary(), f.extraDocs());
|
|
||||||
} else {
|
|
||||||
return null; // not annotated so it shouldn't be documented
|
return null; // not annotated so it shouldn't be documented
|
||||||
|
|
||||||
|
if ( docClass.isAnnotationPresent(DocumentedGATKFeature.class) ) {
|
||||||
|
DocumentedGATKFeature f = docClass.getAnnotation(DocumentedGATKFeature.class);
|
||||||
|
return new DocumentedGATKFeatureObject(docClass, f.enable(), f.groupName(), f.summary(), f.extraDocs());
|
||||||
|
} else {
|
||||||
|
for ( DocumentedGATKFeatureObject staticDocs : STATIC_DOCS ) {
|
||||||
|
if ( staticDocs.getClassToDoc().isAssignableFrom(docClass) ) {
|
||||||
|
return new DocumentedGATKFeatureObject(docClass, staticDocs.enable(), staticDocs.groupName(), staticDocs.summary(), staticDocs.extraDocs());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,16 +229,15 @@ public class GATKDoclet {
|
||||||
|
|
||||||
Collections.sort(indexData);
|
Collections.sort(indexData);
|
||||||
|
|
||||||
Set<DocumentedGATKFeatureObject> docFeatures = new HashSet<DocumentedGATKFeatureObject>();
|
List<Map<String, String>> groups = new ArrayList<Map<String, String>>();
|
||||||
|
Set<String> seenDocumentationFeatures = new HashSet<String>();
|
||||||
List<Map<String, String>> data = new ArrayList<Map<String, String>>();
|
List<Map<String, String>> data = new ArrayList<Map<String, String>>();
|
||||||
for ( GATKDocWorkUnit workUnit : indexData ) {
|
for ( GATKDocWorkUnit workUnit : indexData ) {
|
||||||
data.add(workUnit.indexDataMap());
|
data.add(workUnit.indexDataMap());
|
||||||
docFeatures.add(workUnit.annotation);
|
if ( ! seenDocumentationFeatures.contains(workUnit.annotation.groupName()) ) {
|
||||||
}
|
groups.add(toMap(workUnit.annotation));
|
||||||
|
seenDocumentationFeatures.add(workUnit.annotation.groupName());
|
||||||
List<Map<String, String>> groups = new ArrayList<Map<String, String>>();
|
}
|
||||||
for ( DocumentedGATKFeatureObject feature : docFeatures ) {
|
|
||||||
groups.add(toMap(feature));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
root.put("data", data);
|
root.put("data", data);
|
||||||
|
|
|
||||||
|
|
@ -255,21 +255,21 @@ public class GenericDocumentationHandler extends DocumentedGATKFeatureHandler {
|
||||||
put("name", otherUnit.name);}});
|
put("name", otherUnit.name);}});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Map<String, Object>> hierarchyDocs = new ArrayList<Map<String, Object>>();
|
|
||||||
for (final GATKDocWorkUnit other : all ) {
|
|
||||||
final String relation = classRelationship(toProcess.clazz, other.clazz);
|
|
||||||
if ( relation != null )
|
|
||||||
hierarchyDocs.add(
|
|
||||||
new HashMap<String, Object>(){{
|
|
||||||
put("filename", other.filename);
|
|
||||||
put("relation", relation);
|
|
||||||
put("name", other.name);}});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
root.put("relatedDocs", hierarchyDocs);
|
|
||||||
root.put("extradocs", extraDocsData);
|
root.put("extradocs", extraDocsData);
|
||||||
|
|
||||||
|
|
||||||
|
// List<Map<String, Object>> hierarchyDocs = new ArrayList<Map<String, Object>>();
|
||||||
|
// for (final GATKDocWorkUnit other : all ) {
|
||||||
|
// final String relation = classRelationship(toProcess.clazz, other.clazz);
|
||||||
|
// if ( relation != null )
|
||||||
|
// hierarchyDocs.add(
|
||||||
|
// new HashMap<String, Object>(){{
|
||||||
|
// put("filename", other.filename);
|
||||||
|
// put("relation", relation);
|
||||||
|
// put("name", other.name);}});
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// root.put("relatedDocs", hierarchyDocs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String classRelationship(Class me, Class other) {
|
private static final String classRelationship(Class me, Class other) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue