diff --git a/build.xml b/build.xml
index fe4c7a3f4..b49c8fb4c 100644
--- a/build.xml
+++ b/build.xml
@@ -457,6 +457,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/public/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java b/public/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java
index aba4fc109..d88e7030e 100644
--- a/public/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java
+++ b/public/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java
@@ -43,7 +43,7 @@ import java.util.Locale;
public abstract class CommandLineProgram {
/** The command-line program and the arguments it returned. */
- protected ParsingEngine parser = null;
+ public ParsingEngine parser = null;
/** the default log level */
@Argument(fullName = "logging_level",
@@ -144,6 +144,11 @@ public abstract class CommandLineProgram {
public static int result = -1;
+ @SuppressWarnings("unchecked")
+ public static void start(CommandLineProgram clp, String[] args) throws Exception {
+ start(clp, args, false);
+ }
+
/**
* This function is called to start processing the command line, and kick
* off the execute message of the program.
@@ -153,7 +158,7 @@ public abstract class CommandLineProgram {
* @throws Exception when an exception occurs
*/
@SuppressWarnings("unchecked")
- public static void start(CommandLineProgram clp, String[] args) throws Exception {
+ public static void start(CommandLineProgram clp, String[] args, boolean dryRun) throws Exception {
try {
// setup our log layout
@@ -180,8 +185,9 @@ public abstract class CommandLineProgram {
// - InvalidArgument in case these arguments are specified by plugins.
// - MissingRequiredArgument in case the user requested help. Handle that later, once we've
// determined the full complement of arguments.
- parser.validate(EnumSet.of(ParsingEngine.ValidationType.MissingRequiredArgument,
- ParsingEngine.ValidationType.InvalidArgument));
+ if ( ! dryRun )
+ parser.validate(EnumSet.of(ParsingEngine.ValidationType.MissingRequiredArgument,
+ ParsingEngine.ValidationType.InvalidArgument));
parser.loadArgumentsIntoObject(clp);
// Initialize the logger using the loaded command line.
@@ -195,36 +201,40 @@ public abstract class CommandLineProgram {
if (isHelpPresent(parser))
printHelpAndExit(clp, parser);
- parser.validate();
+ if ( ! dryRun ) parser.validate();
} else {
parser.parse(args);
- if (isHelpPresent(parser))
- printHelpAndExit(clp, parser);
+ if ( ! dryRun ) {
+ if (isHelpPresent(parser))
+ printHelpAndExit(clp, parser);
- parser.validate();
+ parser.validate();
+ }
parser.loadArgumentsIntoObject(clp);
// Initialize the logger using the loaded command line.
clp.setupLoggerLevel(layout);
}
- // if they specify a log location, output our data there
- if (clp.toFile != null) {
- FileAppender appender;
- try {
- appender = new FileAppender(layout, clp.toFile, false);
- logger.addAppender(appender);
- } catch (IOException e) {
- throw new RuntimeException("Unable to re-route log output to " + clp.toFile + " make sure the destination exists");
+ if ( ! dryRun ) {
+ // if they specify a log location, output our data there
+ if (clp.toFile != null) {
+ FileAppender appender;
+ try {
+ appender = new FileAppender(layout, clp.toFile, false);
+ logger.addAppender(appender);
+ } catch (IOException e) {
+ throw new RuntimeException("Unable to re-route log output to " + clp.toFile + " make sure the destination exists");
+ }
}
+
+ // regardless of what happens next, generate the header information
+ HelpFormatter.generateHeaderInformation(clp.getApplicationDetails(), args);
+
+ // call the execute
+ CommandLineProgram.result = clp.execute();
}
-
- // regardless of what happens next, generate the header information
- HelpFormatter.generateHeaderInformation(clp.getApplicationDetails(), args);
-
- // call the execute
- CommandLineProgram.result = clp.execute();
}
catch (ArgumentException e) {
clp.parser.printHelp(clp.getApplicationDetails());
diff --git a/public/java/src/org/broadinstitute/sting/commandline/ParsingEngine.java b/public/java/src/org/broadinstitute/sting/commandline/ParsingEngine.java
index 8423bb2f2..0dc18e6f9 100755
--- a/public/java/src/org/broadinstitute/sting/commandline/ParsingEngine.java
+++ b/public/java/src/org/broadinstitute/sting/commandline/ParsingEngine.java
@@ -45,7 +45,7 @@ public class ParsingEngine {
* A list of defined arguments against which command lines are matched.
* Package protected for testing access.
*/
- ArgumentDefinitions argumentDefinitions = new ArgumentDefinitions();
+ public ArgumentDefinitions argumentDefinitions = new ArgumentDefinitions();
/**
* A list of matches from defined arguments to command-line text.
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 d73c3d6fc..bf99be641 100644
--- a/public/java/src/org/broadinstitute/sting/utils/help/GATKDoclet.java
+++ b/public/java/src/org/broadinstitute/sting/utils/help/GATKDoclet.java
@@ -29,10 +29,14 @@ import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapper;
import freemarker.template.Template;
import freemarker.template.TemplateException;
+import org.broadinstitute.sting.commandline.*;
+import org.broadinstitute.sting.gatk.CommandLineExecutable;
+import org.broadinstitute.sting.gatk.CommandLineGATK;
import org.broadinstitute.sting.gatk.walkers.Walker;
import org.broadinstitute.sting.utils.Utils;
import org.broadinstitute.sting.utils.classloader.JVMUtils;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
+import scala.reflect.Print;
import java.io.*;
import java.util.*;
@@ -40,7 +44,7 @@ import java.util.*;
/**
*
*/
-public class GATKDoclet {
+public class GATKDoclet extends ResourceBundleExtractorDoclet {
/**
* Extracts the contents of certain types of javadoc and adds them to an XML file.
* @param rootDoc The documentation root.
@@ -48,47 +52,164 @@ public class GATKDoclet {
* @throws java.io.IOException if output can't be written.
*/
public static boolean start(RootDoc rootDoc) throws IOException {
- /* ------------------------------------------------------------------- */
- /* You should do this ONLY ONCE in the whole application life-cycle: */
+ GATKDoclet doclet = new GATKDoclet();
+ //PrintStream out = doclet.loadData(rootDoc, false);
+ doclet.processDocs(rootDoc, null);
+ return true;
+ }
- Configuration cfg = new Configuration();
- // Specify the data source where the template files come from.
- // Here I set a file directory for it:
- cfg.setDirectoryForTemplateLoading(new File("settings/helpTemplates/"));
- // Specify how templates will see the data-model. This is an advanced topic...
- // but just use this:
- cfg.setObjectWrapper(new DefaultObjectWrapper());
+ public static int optionLength(String option) {
+ return ResourceBundleExtractorDoclet.optionLength(option);
+ }
+ @Override
+ protected void processDocs(RootDoc rootDoc, PrintStream ignore) {
+ try {
+ /* ------------------------------------------------------------------- */
+ /* You should do this ONLY ONCE in the whole application life-cycle: */
+ Configuration cfg = new Configuration();
+ // Specify the data source where the template files come from.
+ // Here I set a file directory for it:
+ cfg.setDirectoryForTemplateLoading(new File("settings/helpTemplates/"));
+ // Specify how templates will see the data-model. This is an advanced topic...
+ // but just use this:
+ cfg.setObjectWrapper(new DefaultObjectWrapper());
+
+ for ( ClassDoc doc : rootDoc.classes() ) {
+ if ( ResourceBundleExtractorDoclet.isWalker(doc) ) {
+ System.out.printf("Walker class %s%n", doc);
+ processWalkerDocs(cfg, doc);
+ //return;
+ }
+// else
+// System.out.printf("Excluding non-walker class %s%n", doc);
+ }
+ } catch ( FileNotFoundException e ) {
+ throw new RuntimeException(e);
+ } catch ( IOException e ) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void processWalkerDocs(Configuration cfg, ClassDoc doc) throws IOException {
/* ------------------------------------------------------------------- */
/* You usually do these for many times in the application life-cycle: */
- /* Create a data-model */
// Create the root hash
- Map root = new HashMap();
- // Put string ``user'' into the root
- root.put("user", "Mark DePristo");
+ Map root = buildWalkerDataModel(doc);
/* Get or create a template */
Template temp = cfg.getTemplate("test.html");
/* Merge data-model with template */
- Writer out = new OutputStreamWriter(System.out);
+ Writer out = new OutputStreamWriter(new FileOutputStream(new File("testdoc/" + getClassName(doc).replace(".", "_") + ".html")));
try {
temp.process(root, out);
out.flush();
} catch ( TemplateException e ) {
throw new ReviewedStingException("Failed to create GATK documentation", e);
}
- 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 0;
+
+ private Map buildWalkerDataModel(ClassDoc classdoc) {
+ Map root = new HashMap();
+
+ root.put("name", classdoc.name());
+
+ // Extract overrides from the doc tags.
+ StringBuilder summaryBuilder = new StringBuilder();
+ for(Tag tag: classdoc.firstSentenceTags())
+ summaryBuilder.append(tag.text());
+ root.put("summary", summaryBuilder.toString());
+ root.put("description", classdoc.commentText());
+
+ for(Tag tag: classdoc.tags()) {
+ root.put(tag.name(), tag.text());
+ }
+
+ ParsingEngine parsingEngine = createStandardGATKParsingEngine();
+// for (ArgumentDefinition argumentDefinition : parsingEngine.argumentDefinitions )
+// System.out.println(argumentDefinition);
+
+ Map> args = new HashMap>();
+ root.put("arguments", args);
+ args.put("required", new ArrayList