@@ -0,0 +1,2612 @@
+package ie.ucd.clops.documentation;%0A%0Aimport ie.ucd.clops.dsl.structs.BasicOptionDescription;%0Aimport ie.ucd.clops.dsl.structs.DSLInformation;%0Aimport ie.ucd.clops.dsl.structs.OptionDescription;%0A%0Aimport java.io.OutputStream;%0Aimport java.io.PrintStream;%0Aimport java.io.Writer;%0A%0Aimport org.apache.velocity.Template;%0Aimport org.apache.velocity.VelocityContext;%0Aimport org.apache.velocity.app.Velocity;%0A%0A/**%0A * %3CBON%3E%0A * class_chart DOCUMENT_GENERATION %0A * explanation %0A *   %22Generation of documentation from the descriptions of options%22%0A * command%0A *   %22Generate Documentation%22%0A * end%0A * %3C/BON%3E%0A */%0A%0Apublic class DocumentGenerator %7B%0A%09%0A%09public static final String HTML_TEMPLATE = %22templates/html.vm%22;%0A%09public static final String HELP_TEMPLATE = %22templates/help.vm%22;%0A%09private VelocityContext context;%0A%0A%09public DocumentGenerator(DSLInformation information) throws Exception %7B%0A%09%09Velocity.init();%0A%09%09context = createContext(information);%09%0A%09%09%7D%0A%0A%09/**%0A%09 * %0A%09 * @param filename%0A%09 * @param templateName%0A%09 * @throws Exception%0A%09 * %0A%09 * %3CJML%3E%0A%09 *   requires velocity.templateExists(templateName);%0A%09 * %3C/JML%3E%0A%09 */%0A%09public void generate(String filename, String templateName) throws Exception %7B%0A%09%09%09%0A%09%09%09Template template = Velocity.getTemplate(templateName);%0A%09%09%09%0A%09%09%09PrintStream printStream = new PrintStream(filename);%0A%0A%09%09%09Writer writer = new java.io.OutputStreamWriter(printStream);%0A%0A%09%09%09template.merge(context, writer);%0A%09%09%09%0A%09%09%09writer.flush();%0A%09%09%09writer.close();%0A%0A%09%09 %0A%09%7D%0A%0A%09/**%0A%09 * Define the context for document generation%0A%09 * %0A%09 * @return Context for DSL information%0A%09 */%0A%09protected VelocityContext createContext(DSLInformation information) %7B%0A%09%09VelocityContext context = new VelocityContext();%0A%0A%09%09context.put(%22information%22, information);%0A%09%09return context;%0A%09%7D%0A%09%0A%09/**%0A%09 * Test document generation%0A%09 */%0A%09public static void main(String%5B%5D args) %7B%0A%09%09%0A%09%09PrintStream logfile = System.out;%0A%09%09%0A%09%09logfile.println(%22Starting document generation%22);%0A%09%09%0A%09%09DSLInformation information = new DSLInformation();%0A%09%09information.setPackageName(%22TEST%22);%0A%09%09OptionDescription optionDescription = new BasicOptionDescription();%0A%09%09optionDescription.setId(%22Option 1%22);%0A%09%09information.addOptionDescription(optionDescription);%0A%09%09optionDescription.setId(%22Option 2%22);%0A%09%09information.addOptionDescription(optionDescription);%0A%09%09information.setParserName(%22Parser%22);%0A%09%09%0A%09%09try %7B%0A%09%09%09DocumentGenerator documentation = new DocumentGenerator(information);%0A%09%09%09documentation.generate (%22help.txt%22, HELP_TEMPLATE);%0A%09%09%09documentation.generate (%22help.html%22, HTML_TEMPLATE);%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%09%0A%09%09logfile.println(%22Finished document generation%22);%0A%09%7D%0A%0A%7D%0A

Rename document generation