Help now points to GATKDocs instead of spitting out full, garbled description

This commit is contained in:
Mark DePristo 2011-08-07 15:02:46 -04:00
parent a8eb8c27f0
commit 1c63d43176
4 changed files with 59 additions and 24 deletions

View File

@ -36,6 +36,7 @@ import org.broadinstitute.sting.gatk.walkers.Walker;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.help.ApplicationDetails;
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
import org.broadinstitute.sting.utils.help.GATKDoclet;
import org.broadinstitute.sting.utils.text.TextFormattingUtils;
import java.util.*;
@ -175,12 +176,8 @@ public class CommandLineGATK extends CommandLineExecutable {
StringBuilder additionalHelp = new StringBuilder();
Formatter formatter = new Formatter(additionalHelp);
formatter.format("Description:%n");
WalkerManager walkerManager = engine.getWalkerManager();
String walkerHelpText = walkerManager.getWalkerDescriptionText(walkerType);
printDescriptorLine(formatter,WALKER_INDENT,"",WALKER_INDENT,FIELD_SEPARATOR,walkerHelpText,TextFormattingUtils.DEFAULT_LINE_WIDTH);
formatter.format("For a full description of this walker, see its GATKdocs at:%n");
formatter.format("%s%n", GATKDoclet.helpLinksToGATKDocs(walkerType));
return additionalHelp.toString();
}
@ -194,8 +191,6 @@ public class CommandLineGATK extends CommandLineExecutable {
StringBuilder additionalHelp = new StringBuilder();
Formatter formatter = new Formatter(additionalHelp);
formatter.format("Available analyses:%n");
// Get the list of walker names from the walker manager.
WalkerManager walkerManager = engine.getWalkerManager();

View File

@ -50,8 +50,8 @@ public abstract class DocumentedGATKFeatureHandler {
public boolean shouldBeProcessed(ClassDoc doc) { return true; }
public String getDestinationFilename(ClassDoc doc) {
return HelpUtils.getClassName(doc).replace(".", "_") + ".html";
public String getDestinationFilename(ClassDoc doc, Class clazz) {
return GATKDoclet.htmlFilenameForClass(clazz);
}
public abstract String getTemplateName(ClassDoc doc) throws IOException;

View File

@ -30,19 +30,29 @@ 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<GATKDocWorkUnit> {
// known at the start
final String name, filename, group;
final DocumentedGATKFeatureHandler handler;
final ClassDoc classDoc;
* Simple collection of all relevant information about something the GATKDoclet can document
*
* Created by IntelliJ IDEA.
* User: depristo
* Date: 7/24/11
* Time: 7:59 PM
*/
class GATKDocWorkUnit implements Comparable<GATKDocWorkUnit> {
/** The class that's being documented */
final Class clazz;
/** The name of the thing we are documenting */
final String name;
/** the filename where we will be writing the docs for this class */
final String filename;
/** The name of the documentation group (e.g., walkers, read filters) class belongs to */
final String group;
/** The documentation handler for this class */
final DocumentedGATKFeatureHandler handler;
/** The javadoc documentation for clazz */
final ClassDoc classDoc;
/** The annotation that lead to this Class being in GATKDoc */
final DocumentedGATKFeature annotation;
/** When was this walker built, and what's the absolute version number */
final String buildTimestamp, absoluteVersion;
// set by the handler
@ -64,12 +74,21 @@ public class GATKDocWorkUnit implements Comparable<GATKDocWorkUnit> {
this.absoluteVersion = absoluteVersion;
}
/**
* Called by the GATKDoclet to set handler provided context for this work unit
* @param summary
* @param forTemplate
*/
public void setHandlerContent(String summary, Map<String, Object> forTemplate) {
this.summary = summary;
this.forTemplate = forTemplate;
}
public Map<String, String> toMap() {
/**
* Return a String -> String map suitable for FreeMarker to create an index to this WorkUnit
* @return
*/
public Map<String, String> indexDataMap() {
Map<String, String> data = new HashMap<String, String>();
data.put("name", name);
data.put("summary", summary);
@ -78,6 +97,11 @@ public class GATKDocWorkUnit implements Comparable<GATKDocWorkUnit> {
return data;
}
/**
* Sort in order of the name of this WorkUnit
* @param other
* @return
*/
public int compareTo(GATKDocWorkUnit other) {
return this.name.compareTo(other.name);
}

View File

@ -42,6 +42,9 @@ import java.util.*;
*
*/
public class GATKDoclet {
private final static String URL_ROOT_FOR_RELEASE_GATKDOCS = "http://www.broadinstitute.org/gsa/gatkdocs/release/";
private final static String URL_ROOT_FOR_STABLE_GATKDOCS = "http://iwww.broadinstitute.org/gsa/gatkdocs/stable/";
private final static String URL_ROOT_FOR_UNSTABLE_GATKDOCS = "http://iwww.broadinstitute.org/gsa/gatkdocs/unstable/";
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);
@ -89,6 +92,19 @@ public class GATKDoclet {
return showHiddenFeatures;
}
public static String htmlFilenameForClass(Class c) {
return c.getName().replace(".", "_") + ".html";
}
public static String helpLinksToGATKDocs(Class c) {
String classPath = htmlFilenameForClass(c);
StringBuilder b = new StringBuilder();
b.append("release version: ").append(URL_ROOT_FOR_RELEASE_GATKDOCS).append(classPath).append("\n");
b.append("stable version: ").append(URL_ROOT_FOR_STABLE_GATKDOCS).append(classPath).append("\n");
b.append("unstable version: ").append(URL_ROOT_FOR_UNSTABLE_GATKDOCS).append(classPath).append("\n");
return b.toString();
}
public Set<GATKDocWorkUnit> workUnits() {
TreeSet<GATKDocWorkUnit> m = new TreeSet<GATKDocWorkUnit>();
@ -103,7 +119,7 @@ public class GATKDoclet {
DocumentedGATKFeatureHandler handler = createHandler(doc, feature);
if ( handler != null && handler.shouldBeProcessed(doc) ) {
logger.info("Going to generate documentation for class " + doc);
String filename = handler.getDestinationFilename(doc);
String filename = handler.getDestinationFilename(doc, clazz);
GATKDocWorkUnit unit = new GATKDocWorkUnit(doc.name(),
filename, feature.groupName(),
feature, handler, doc, clazz,
@ -220,7 +236,7 @@ public class GATKDoclet {
Set<DocumentedGATKFeature> docFeatures = new HashSet<DocumentedGATKFeature>();
List<Map<String, String>> data = new ArrayList<Map<String, String>>();
for ( GATKDocWorkUnit workUnit : indexData ) {
data.add(workUnit.toMap());
data.add(workUnit.indexDataMap());
docFeatures.add(workUnit.annotation);
}