New uses DocumentedGATKFeatureObject instead of annotation directly
-- Step 1 on the way to creating a static list of additional classes that we want to document.
This commit is contained in:
parent
d4511807ed
commit
e03db30ca0
|
|
@ -39,6 +39,5 @@ public @interface DocumentedGATKFeature {
|
|||
public boolean enable() default true;
|
||||
public String groupName();
|
||||
public String summary() default "";
|
||||
public Class<? extends DocumentedGATKFeatureHandler> handler() default GenericDocumentationHandler.class;
|
||||
public Class[] extraDocs() default {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2011, The Broad Institute
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.utils.help;
|
||||
|
||||
/**
|
||||
* Documentation unit. Effectively a class version of the DocumentedGATKFeature
|
||||
*
|
||||
* @author depristo
|
||||
*/
|
||||
class DocumentedGATKFeatureObject {
|
||||
final boolean enable;
|
||||
final String groupName, summary;
|
||||
final Class[] extraDocs;
|
||||
|
||||
public DocumentedGATKFeatureObject(final boolean enable, final String groupName, final String summary, final Class[] extraDocs) {
|
||||
this.enable = enable;
|
||||
this.groupName = groupName;
|
||||
this.summary = summary;
|
||||
this.extraDocs = extraDocs;
|
||||
}
|
||||
|
||||
public boolean enable() { return enable; }
|
||||
public String groupName() { return groupName; }
|
||||
public String summary() { return summary; }
|
||||
public Class[] extraDocs() { return extraDocs; }
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ class GATKDocWorkUnit implements Comparable<GATKDocWorkUnit> {
|
|||
/** The javadoc documentation for clazz */
|
||||
final ClassDoc classDoc;
|
||||
/** The annotation that lead to this Class being in GATKDoc */
|
||||
final DocumentedGATKFeature annotation;
|
||||
final DocumentedGATKFeatureObject annotation;
|
||||
/** When was this walker built, and what's the absolute version number */
|
||||
final String buildTimestamp, absoluteVersion;
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ class GATKDocWorkUnit implements Comparable<GATKDocWorkUnit> {
|
|||
Map<String, Object> forTemplate;
|
||||
|
||||
public GATKDocWorkUnit(String name, String filename, String group,
|
||||
DocumentedGATKFeature annotation, DocumentedGATKFeatureHandler handler,
|
||||
DocumentedGATKFeatureObject annotation, DocumentedGATKFeatureHandler handler,
|
||||
ClassDoc classDoc, Class clazz,
|
||||
String buildTimestamp, String absoluteVersion) {
|
||||
this.annotation = annotation;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public class GATKDoclet {
|
|||
//if ( clazz != null && clazz.getName().equals("org.broadinstitute.sting.gatk.walkers.annotator.AlleleBalance"))
|
||||
// logger.debug("foo");
|
||||
|
||||
DocumentedGATKFeature feature = getFeatureForClassDoc(doc);
|
||||
DocumentedGATKFeatureObject feature = getFeatureForClassDoc(doc);
|
||||
DocumentedGATKFeatureHandler handler = createHandler(doc, feature);
|
||||
if ( handler != null && handler.includeInDocs(doc) ) {
|
||||
logger.info("Generating documentation for class " + doc);
|
||||
|
|
@ -146,31 +146,26 @@ public class GATKDoclet {
|
|||
}
|
||||
}
|
||||
|
||||
private DocumentedGATKFeatureHandler createHandler(ClassDoc doc, DocumentedGATKFeature feature) {
|
||||
try {
|
||||
if ( feature != null ) {
|
||||
if ( feature.enable() ) {
|
||||
DocumentedGATKFeatureHandler handler = feature.handler().newInstance();
|
||||
handler.setDoclet(this);
|
||||
return handler;
|
||||
} else {
|
||||
logger.info("Skipping disabled Documentation for " + doc);
|
||||
}
|
||||
private DocumentedGATKFeatureHandler createHandler(ClassDoc doc, DocumentedGATKFeatureObject feature) {
|
||||
if ( feature != null ) {
|
||||
if ( feature.enable() ) {
|
||||
DocumentedGATKFeatureHandler handler = new GenericDocumentationHandler();
|
||||
handler.setDoclet(this);
|
||||
return handler;
|
||||
} else {
|
||||
logger.info("Skipping disabled Documentation for " + doc);
|
||||
}
|
||||
} catch ( IllegalAccessException e) {
|
||||
throw new RuntimeException(e); // the constructor is now private -- this is an error
|
||||
} catch ( InstantiationException e) {
|
||||
throw new RuntimeException(e); // the constructor is now private -- this is an error
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private DocumentedGATKFeature getFeatureForClassDoc(ClassDoc doc) {
|
||||
// todo -- what do I need the ? extends Object to pass the compiler?
|
||||
private DocumentedGATKFeatureObject getFeatureForClassDoc(ClassDoc 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) ) {
|
||||
return docClass.getAnnotation(DocumentedGATKFeature.class);
|
||||
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
|
||||
}
|
||||
|
|
@ -217,7 +212,7 @@ public class GATKDoclet {
|
|||
|
||||
Collections.sort(indexData);
|
||||
|
||||
Set<DocumentedGATKFeature> docFeatures = new HashSet<DocumentedGATKFeature>();
|
||||
Set<DocumentedGATKFeatureObject> docFeatures = new HashSet<DocumentedGATKFeatureObject>();
|
||||
List<Map<String, String>> data = new ArrayList<Map<String, String>>();
|
||||
for ( GATKDocWorkUnit workUnit : indexData ) {
|
||||
data.add(workUnit.indexDataMap());
|
||||
|
|
@ -225,7 +220,7 @@ public class GATKDoclet {
|
|||
}
|
||||
|
||||
List<Map<String, String>> groups = new ArrayList<Map<String, String>>();
|
||||
for ( DocumentedGATKFeature feature : docFeatures ) {
|
||||
for ( DocumentedGATKFeatureObject feature : docFeatures ) {
|
||||
groups.add(toMap(feature));
|
||||
}
|
||||
|
||||
|
|
@ -237,7 +232,7 @@ public class GATKDoclet {
|
|||
return root;
|
||||
}
|
||||
|
||||
private static final Map<String, String> toMap(DocumentedGATKFeature annotation) {
|
||||
private static final Map<String, String> toMap(DocumentedGATKFeatureObject annotation) {
|
||||
Map<String, String> root = new HashMap<String, String>();
|
||||
root.put("name", annotation.groupName());
|
||||
root.put("summary", annotation.summary());
|
||||
|
|
|
|||
Loading…
Reference in New Issue