use of org.eclipse.mylyn.wikitext.splitter.SplittingHtmlDocumentBuilder in project mylyn.docs by eclipse.
the class MarkupToEclipseHelpMojo method processMarkup.
protected void processMarkup(File sourceFile, String relativePath, MarkupLanguage markupLanguage) {
getLog().info(format("Processing markup file: {0}", sourceFile));
String name = sourceFile.getName();
if (name.lastIndexOf('.') != -1) {
name = name.substring(0, name.lastIndexOf('.'));
}
File htmlOutputFile = computeHtmlFile(relativePath, name);
if (!htmlOutputFile.exists() || htmlOutputFile.lastModified() < sourceFile.lastModified()) {
String markupContent = readFully(sourceFile);
if (!htmlOutputFile.getParentFile().exists()) {
if (!htmlOutputFile.getParentFile().mkdirs()) {
throw new BuildFailureException(format("Cannot create folder {0}", htmlOutputFile.getParentFile()));
}
}
Writer writer = createWriter(htmlOutputFile);
try {
HtmlDocumentBuilder builder = createRootBuilder(writer, name, relativePath);
SplittingStrategy splittingStrategy = createSplittingStrategy();
SplittingOutlineParser outlineParser = createOutlineParser(markupLanguage, splittingStrategy);
SplitOutlineItem rootTocItem = outlineParser.parse(markupContent);
rootTocItem.setSplitTarget(htmlOutputFile.getName());
SplittingHtmlDocumentBuilder splittingBuilder = createSplittingBuilder(builder, rootTocItem, htmlOutputFile, relativePath);
MarkupParser parser = new MarkupParser();
parser.setMarkupLanguage(markupLanguage);
parser.setBuilder(splittingBuilder);
parser.parse(markupContent);
createEclipseHelpToc(rootTocItem, sourceFile, relativePath, htmlOutputFile, name);
} finally {
close(writer, htmlOutputFile);
}
}
}
Aggregations