String relpathTmp;
relpathTmp = gappFile.getParentFile().getAbsolutePath();
final String relpath = relpathTmp;
File templateDir = new File(templateDirName);
System.out.println("AppDoc: using template directory " + templateDir);
Settings settings = new fmpp.setting.Settings(templateDir);
settings.define("outFileExtension", Settings.TYPE_STRING, false, true);
settings.load(new File(templateDir, "config.fmpp"));
// the directory that will contain all output files
System.out.println("AppDoc: using output directory " + outputDirName);
settings.setWithString("outputRoot", outputDirName);
String extension = (String) settings.get("outFileExtension");
if (extension == null) { // if somebody
throw new GateRuntimeException("Parameter outfileExtension not set in the config file!");
}
String docFileName = gappFile.getName() + ".doc" + settings.get("outFileExtension");
System.out.println("AppDoc: generating documentation root file: " + docFileName);
String gappFileNameSlashes = gappFileName;
String docFileNameSlashes = docFileName;
String gatehomeSlashes = gatehome;
String relpathSlashes = relpath;
// TODO: this is rather a hack. We should figure out how to construct
// the settings datastructure directly instead of supplying a string
// where we have to struggle to get the file path names right.
if(File.separator.equals("\\")) {
gappFileNameSlashes = gappFileName.replaceAll("\\\\", "/");
docFileNameSlashes = docFileName.replaceAll("\\\\","/");
gatehomeSlashes = gatehome.replaceAll("\\\\", "/");
relpathSlashes = relpath.replaceAll("\\\\", "/");
}
String settingsString =
"{doc: xml(\"" + gappFileNameSlashes + "\")\n"
+ "docFile: \"" + docFileNameSlashes + "\"\n"
+ "gatehome: \"" + gatehomeSlashes + "\"\n"
+ "relpath: \"" + relpathSlashes + "\"\n"
+ "}";
//System.out.println("Settings string is: "+settingsString);
settings.setWithString("data",settingsString);
settings.addProgressListener(new ConsoleProgressListener());
settings.execute();
} // generateDoc