diff --git a/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeature.java b/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeature.java index 710503ca8..89163dfcb 100644 --- a/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeature.java +++ b/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeature.java @@ -39,6 +39,5 @@ public @interface DocumentedGATKFeature { public boolean enable() default true; public String groupName(); public String summary() default ""; - public Class handler() default GenericDocumentationHandler.class; public Class[] extraDocs() default {}; } diff --git a/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeatureObject.java b/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeatureObject.java new file mode 100644 index 000000000..9d198ee1a --- /dev/null +++ b/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeatureObject.java @@ -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; } +} diff --git a/public/java/src/org/broadinstitute/sting/utils/help/GATKDocWorkUnit.java b/public/java/src/org/broadinstitute/sting/utils/help/GATKDocWorkUnit.java index 1f6db2757..41c855329 100644 --- a/public/java/src/org/broadinstitute/sting/utils/help/GATKDocWorkUnit.java +++ b/public/java/src/org/broadinstitute/sting/utils/help/GATKDocWorkUnit.java @@ -51,7 +51,7 @@ class GATKDocWorkUnit implements Comparable { /** 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 { Map 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; diff --git a/public/java/src/org/broadinstitute/sting/utils/help/GATKDoclet.java b/public/java/src/org/broadinstitute/sting/utils/help/GATKDoclet.java index 8f3ec293a..070663605 100644 --- a/public/java/src/org/broadinstitute/sting/utils/help/GATKDoclet.java +++ b/public/java/src/org/broadinstitute/sting/utils/help/GATKDoclet.java @@ -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 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 docFeatures = new HashSet(); + Set docFeatures = new HashSet(); List> data = new ArrayList>(); for ( GATKDocWorkUnit workUnit : indexData ) { data.add(workUnit.indexDataMap()); @@ -225,7 +220,7 @@ public class GATKDoclet { } List> groups = new ArrayList>(); - 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 toMap(DocumentedGATKFeature annotation) { + private static final Map toMap(DocumentedGATKFeatureObject annotation) { Map root = new HashMap(); root.put("name", annotation.groupName()); root.put("summary", annotation.summary());