Support for style.css via refactored common.html included in all files

This commit is contained in:
Mark DePristo 2011-07-24 15:42:39 -04:00
parent d0ab6bf7a9
commit 5e0fe2d0f9
3 changed files with 21 additions and 14 deletions

View File

@ -30,8 +30,10 @@ import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapper; import freemarker.template.DefaultObjectWrapper;
import freemarker.template.Template; import freemarker.template.Template;
import freemarker.template.TemplateException; import freemarker.template.TemplateException;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
import sun.misc.IOUtils;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
@ -40,6 +42,8 @@ import java.util.*;
* *
*/ */
public class GATKDoclet extends ResourceBundleExtractorDoclet { public class GATKDoclet extends ResourceBundleExtractorDoclet {
final protected static File SETTINGS_DIR = new File("settings/helpTemplates");
final protected static File DESTINATION_DIR = new File("testdoc");
final protected static Logger logger = Logger.getLogger(GATKDoclet.class); final protected static Logger logger = Logger.getLogger(GATKDoclet.class);
public static class DocWorkUnit implements Comparable<DocWorkUnit> { public static class DocWorkUnit implements Comparable<DocWorkUnit> {
@ -128,12 +132,16 @@ public class GATKDoclet extends ResourceBundleExtractorDoclet {
this.rootDoc = rootDoc; this.rootDoc = rootDoc;
try { try {
// basic setup
DESTINATION_DIR.mkdirs();
FileUtils.copyFile(new File(SETTINGS_DIR + "/style.css"), new File(DESTINATION_DIR + "/style.css"));
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
/* You should do this ONLY ONCE in the whole application life-cycle: */ /* You should do this ONLY ONCE in the whole application life-cycle: */
Configuration cfg = new Configuration(); Configuration cfg = new Configuration();
// Specify the data source where the template files come from. // Specify the data source where the template files come from.
cfg.setDirectoryForTemplateLoading(new File("settings/helpTemplates/")); cfg.setDirectoryForTemplateLoading(SETTINGS_DIR);
// Specify how templates will see the data-model. This is an advanced topic... // Specify how templates will see the data-model. This is an advanced topic...
cfg.setObjectWrapper(new DefaultObjectWrapper()); cfg.setObjectWrapper(new DefaultObjectWrapper());
@ -200,7 +208,7 @@ public class GATKDoclet extends ResourceBundleExtractorDoclet {
Template temp = cfg.getTemplate("generic.index.template.html"); Template temp = cfg.getTemplate("generic.index.template.html");
/* Merge data-model with template */ /* Merge data-model with template */
Writer out = new OutputStreamWriter(new FileOutputStream(new File("testdoc/index.html"))); Writer out = new OutputStreamWriter(new FileOutputStream(new File(DESTINATION_DIR + "/index.html")));
try { try {
temp.process(groupIndexData(indexData), out); temp.process(groupIndexData(indexData), out);
out.flush(); out.flush();
@ -259,7 +267,7 @@ public class GATKDoclet extends ResourceBundleExtractorDoclet {
Template temp = cfg.getTemplate(unit.handler.getTemplateName(unit.classDoc)); Template temp = cfg.getTemplate(unit.handler.getTemplateName(unit.classDoc));
// Merge data-model with template // Merge data-model with template
File outputPath = new File("testdoc/" + unit.filename); File outputPath = new File(DESTINATION_DIR + "/" + unit.filename);
try { try {
Writer out = new OutputStreamWriter(new FileOutputStream(outputPath)); Writer out = new OutputStreamWriter(new FileOutputStream(outputPath));
temp.process(unit.forTemplate, out); temp.process(unit.forTemplate, out);

View File

@ -1,5 +1,7 @@
<#include "common.html"/>
<#macro emitGroup group> <#macro emitGroup group>
<table border="1" cellpadding="2"> <table border="1" cellpadding="2" width="100%">
<h2>${group.name}</h2> <h2>${group.name}</h2>
<p> <p>
${group.summary} ${group.summary}
@ -20,9 +22,7 @@
</#macro> </#macro>
<html> <html>
<head> <@makeHeader title="GATK documentation index"/>
<title>GATK documentation index</title>
</head>
<body> <body>
<h1>GATK documentation index</h1> <h1>GATK documentation index</h1>
<#list groups as group> <#list groups as group>

View File

@ -1,3 +1,5 @@
<#include "common.html"/>
<#macro argumentlist name myargs> <#macro argumentlist name myargs>
<#if myargs?size != 0> <#if myargs?size != 0>
<tr><th colspan="4" align="left">${name}</th></tr> <tr><th colspan="4" align="left">${name}</th></tr>
@ -39,12 +41,9 @@
</#if> </#if>
</#list> </#list>
</#macro> </#macro>
<html> <html>
<head> <@makeHeader title="${name} documentation"/>
<title>${name} documentation</title>
</head>
<body> <body>
<h1>${name}<h1> <h1>${name}<h1>
<h2>Brief summary</h2> <h2>Brief summary</h2>
@ -60,7 +59,7 @@
<#if arguments.all?size != 0> <#if arguments.all?size != 0>
<hr> <hr>
<h2>Feature specific arguments</h2> <h2>Feature specific arguments</h2>
<table border="1" cellpadding="2"> <table border="1" cellpadding="2" width="100%">
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Synonyms</th> <th>Synonyms</th>
@ -90,10 +89,10 @@
<#-- This class is related to other documented classes via sub/super relationships --> <#-- This class is related to other documented classes via sub/super relationships -->
<#if relatedDocs?size != 0> <#if relatedDocs?size != 0>
<hr>
<h2>Related capabilities</h2> <h2>Related capabilities</h2>
<@relatedByType name="Superclasses" type="superclass"/> <@relatedByType name="Superclasses" type="superclass"/>
<@relatedByType name="Subclasses" type="subclass"/> <@relatedByType name="Subclasses" type="subclass"/>
<hr>
</#if> </#if>
<#-- List all of the --> <#-- List all of the -->