diff --git a/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeatureHandler.java b/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeatureHandler.java index 198b09ebc..2227f9aba 100644 --- a/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeatureHandler.java +++ b/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeatureHandler.java @@ -28,7 +28,6 @@ import com.sun.javadoc.ClassDoc; import com.sun.javadoc.RootDoc; import java.io.*; -import java.util.Map; import java.util.Set; /** @@ -52,5 +51,5 @@ public abstract class DocumentedGATKFeatureHandler { } public abstract String getTemplateName(ClassDoc doc) throws IOException; - public abstract void processOne(RootDoc rootDoc, GATKDoclet.DocWorkUnit toProcess, Set all); + public abstract void processOne(RootDoc rootDoc, GATKDocWorkUnit toProcess, Set all); } diff --git a/public/java/src/org/broadinstitute/sting/utils/help/GATKDocWorkUnit.java b/public/java/src/org/broadinstitute/sting/utils/help/GATKDocWorkUnit.java new file mode 100644 index 000000000..65c6624d5 --- /dev/null +++ b/public/java/src/org/broadinstitute/sting/utils/help/GATKDocWorkUnit.java @@ -0,0 +1,84 @@ +/* + * 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; + +import com.sun.javadoc.ClassDoc; + +import java.util.HashMap; +import java.util.Map; + +/** +* Created by IntelliJ IDEA. +* User: depristo +* Date: 7/24/11 +* Time: 7:59 PM +* To change this template use File | Settings | File Templates. +*/ +public class GATKDocWorkUnit implements Comparable { + // known at the start + final String name, filename, group; + final DocumentedGATKFeatureHandler handler; + final ClassDoc classDoc; + final Class clazz; + final DocumentedGATKFeature annotation; + final String buildTimestamp, absoluteVersion; + + // set by the handler + String summary; + Map forTemplate; + + public GATKDocWorkUnit(String name, String filename, String group, + DocumentedGATKFeature annotation, DocumentedGATKFeatureHandler handler, + ClassDoc classDoc, Class clazz, + String buildTimestamp, String absoluteVersion) { + this.annotation = annotation; + this.name = name; + this.filename = filename; + this.group = group; + this.handler = handler; + this.classDoc = classDoc; + this.clazz = clazz; + this.buildTimestamp = buildTimestamp; + this.absoluteVersion = absoluteVersion; + } + + public void setHandlerContent(String summary, Map forTemplate) { + this.summary = summary; + this.forTemplate = forTemplate; + } + + public Map toMap() { + Map data = new HashMap(); + data.put("name", name); + data.put("summary", summary); + data.put("filename", filename); + data.put("group", group); + return data; + } + + public int compareTo(GATKDocWorkUnit other) { + return this.name.compareTo(other.name); + } +} 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 38a3f4e18..ff20afbfa 100644 --- a/public/java/src/org/broadinstitute/sting/utils/help/GATKDoclet.java +++ b/public/java/src/org/broadinstitute/sting/utils/help/GATKDoclet.java @@ -33,7 +33,6 @@ import freemarker.template.TemplateException; import org.apache.commons.io.FileUtils; import org.apache.log4j.Logger; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; -import sun.misc.IOUtils; import java.io.*; import java.util.*; @@ -41,57 +40,11 @@ import java.util.*; /** * */ -public class GATKDoclet extends ResourceBundleExtractorDoclet { +public class GATKDoclet { final protected static File SETTINGS_DIR = new File("settings/helpTemplates"); final protected static File DESTINATION_DIR = new File("gatkdocs"); final protected static Logger logger = Logger.getLogger(GATKDoclet.class); - - public static class DocWorkUnit implements Comparable { - // known at the start - final String name, filename, group; - final DocumentedGATKFeatureHandler handler; - final ClassDoc classDoc; - final Class clazz; - final DocumentedGATKFeature annotation; - final String buildTimestamp, absoluteVersion; - - // set by the handler - String summary; - Map forTemplate; - - public DocWorkUnit(String name, String filename, String group, - DocumentedGATKFeature annotation, DocumentedGATKFeatureHandler handler, - ClassDoc classDoc, Class clazz, - String buildTimestamp, String absoluteVersion) { - this.annotation = annotation; - this.name = name; - this.filename = filename; - this.group = group; - this.handler = handler; - this.classDoc = classDoc; - this.clazz = clazz; - this.buildTimestamp = buildTimestamp; - this.absoluteVersion = absoluteVersion; - } - - public void setHandlerContent(String summary, Map forTemplate) { - this.summary = summary; - this.forTemplate = forTemplate; - } - - public Map toMap() { - Map data = new HashMap(); - data.put("name", name); - data.put("summary", summary); - data.put("filename", filename); - data.put("group", group); - return data; - } - - public int compareTo(DocWorkUnit other) { - return this.name.compareTo(other.name); - } - } + protected static String buildTimestamp = null, absoluteVersion = null; RootDoc rootDoc; @@ -102,17 +55,33 @@ public class GATKDoclet extends ResourceBundleExtractorDoclet { * @throws java.io.IOException if output can't be written. */ public static boolean start(RootDoc rootDoc) throws IOException { + // load arguments + for(String[] options: rootDoc.options()) { + if(options[0].equals("-build-timestamp")) + buildTimestamp = options[1]; + if (options[0].equals("-absolute-version")) + absoluteVersion = options[1]; + } + GATKDoclet doclet = new GATKDoclet(); - doclet.processDocs(rootDoc, null); + doclet.processDocs(rootDoc); return true; } + /** + * Validate the given options against options supported by this doclet. + * @param option Option to validate. + * @return Number of potential parameters; 0 if not supported. + */ public static int optionLength(String option) { - return ResourceBundleExtractorDoclet.optionLength(option); + if(option.equals("-build-timestamp") || option.equals("-absolute-version") ) { + return 2; + } + return 0; } - public Set workUnits() { - TreeSet m = new TreeSet(); + public Set workUnits() { + TreeSet m = new TreeSet(); for ( ClassDoc doc : rootDoc.classes() ) { System.out.printf("Considering %s%n", doc); @@ -121,7 +90,7 @@ public class GATKDoclet extends ResourceBundleExtractorDoclet { DocumentedGATKFeatureHandler handler = createHandler(doc, feature); if ( handler != null && handler.shouldBeProcessed(doc) ) { String filename = handler.getDestinationFilename(doc); - DocWorkUnit unit = new DocWorkUnit(doc.name(), + GATKDocWorkUnit unit = new GATKDocWorkUnit(doc.name(), filename, feature.groupName(), feature, handler, doc, clazz, buildTimestamp, absoluteVersion); @@ -133,7 +102,7 @@ public class GATKDoclet extends ResourceBundleExtractorDoclet { } @Override - protected void processDocs(RootDoc rootDoc, PrintStream ignore) { + protected void processDocs(RootDoc rootDoc) { // setup the global access to the root this.rootDoc = rootDoc; super.loadData(rootDoc, false); @@ -152,12 +121,12 @@ public class GATKDoclet extends ResourceBundleExtractorDoclet { // Specify how templates will see the data-model. This is an advanced topic... cfg.setObjectWrapper(new DefaultObjectWrapper()); - Set myWorkUnits = workUnits(); - for ( DocWorkUnit workUnit : myWorkUnits ) { + Set myWorkUnits = workUnits(); + for ( GATKDocWorkUnit workUnit : myWorkUnits ) { processDocWorkUnit(cfg, workUnit, myWorkUnits); } - processIndex(cfg, new ArrayList(myWorkUnits)); + processIndex(cfg, new ArrayList(myWorkUnits)); } catch ( FileNotFoundException e ) { throw new RuntimeException(e); } catch ( IOException e ) { @@ -214,7 +183,7 @@ public class GATKDoclet extends ResourceBundleExtractorDoclet { return rootDoc.classNamed(clazz.getName()); } - private void processIndex(Configuration cfg, List indexData) throws IOException { + private void processIndex(Configuration cfg, List indexData) throws IOException { /* Get or create a template */ Template temp = cfg.getTemplate("generic.index.template.html"); @@ -228,7 +197,7 @@ public class GATKDoclet extends ResourceBundleExtractorDoclet { } } - private Map groupIndexData(List indexData) { + private Map groupIndexData(List indexData) { // // root -> data -> { summary -> y, filename -> z }, etc // -> groups -> group1, group2, etc. @@ -238,7 +207,7 @@ public class GATKDoclet extends ResourceBundleExtractorDoclet { Set docFeatures = new HashSet(); List> data = new ArrayList>(); - for ( DocWorkUnit workUnit : indexData ) { + for ( GATKDocWorkUnit workUnit : indexData ) { data.add(workUnit.toMap()); docFeatures.add(workUnit.annotation); } @@ -263,14 +232,14 @@ public class GATKDoclet extends ResourceBundleExtractorDoclet { return root; } - public final static DocWorkUnit findWorkUnitForClass(Class c, Set all) { - for ( final DocWorkUnit unit : all ) + public final static GATKDocWorkUnit findWorkUnitForClass(Class c, Set all) { + for ( final GATKDocWorkUnit unit : all ) if ( unit.clazz.equals(c) ) return unit; return null; } - private void processDocWorkUnit(Configuration cfg, DocWorkUnit unit, Set all) + private void processDocWorkUnit(Configuration cfg, GATKDocWorkUnit unit, Set all) throws IOException { System.out.printf("Processing documentation for class %s%n", unit.classDoc); diff --git a/public/java/src/org/broadinstitute/sting/utils/help/GenericDocumentationHandler.java b/public/java/src/org/broadinstitute/sting/utils/help/GenericDocumentationHandler.java index 5fd6f27d9..1aef110eb 100644 --- a/public/java/src/org/broadinstitute/sting/utils/help/GenericDocumentationHandler.java +++ b/public/java/src/org/broadinstitute/sting/utils/help/GenericDocumentationHandler.java @@ -32,7 +32,6 @@ import com.sun.javadoc.Tag; import org.broadinstitute.sting.commandline.*; import org.broadinstitute.sting.gatk.CommandLineGATK; import org.broadinstitute.sting.utils.Utils; -import org.broadinstitute.sting.utils.classloader.JVMUtils; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import java.io.*; @@ -43,9 +42,9 @@ import java.util.*; * */ public class GenericDocumentationHandler extends DocumentedGATKFeatureHandler { - GATKDoclet.DocWorkUnit toProcess; + GATKDocWorkUnit toProcess; ClassDoc classdoc; - Set all; + Set all; RootDoc rootDoc; @Override @@ -66,7 +65,7 @@ public class GenericDocumentationHandler extends DocumentedGATKFeatureHandler { } @Override - public void processOne(RootDoc rootDoc, GATKDoclet.DocWorkUnit toProcessArg, Set allArg) { + public void processOne(RootDoc rootDoc, GATKDocWorkUnit toProcessArg, Set allArg) { this.rootDoc = rootDoc; this.toProcess = toProcessArg; this.all = allArg; @@ -132,7 +131,7 @@ public class GenericDocumentationHandler extends DocumentedGATKFeatureHandler { // add in all of the explicitly related items for ( final Class extraDocClass : toProcess.annotation.extraDocs() ) { - final GATKDoclet.DocWorkUnit otherUnit = GATKDoclet.findWorkUnitForClass(extraDocClass, all); + final GATKDocWorkUnit otherUnit = GATKDoclet.findWorkUnitForClass(extraDocClass, all); if ( otherUnit == null ) throw new ReviewedStingException("Requested extraDocs for class without any documentation: " + extraDocClass); extraDocsData.add( @@ -143,7 +142,7 @@ public class GenericDocumentationHandler extends DocumentedGATKFeatureHandler { } List> hierarchyDocs = new ArrayList>(); - for (final GATKDoclet.DocWorkUnit other : all ) { + for (final GATKDocWorkUnit other : all ) { final String relation = classRelationship(toProcess.clazz, other.clazz); if ( relation != null ) hierarchyDocs.add(