use of org.eclipse.mylyn.wikitext.splitter.SplitOutlineItem in project mylyn.docs by eclipse.
the class WikiToDocTask method computeTocRelativeFile.
private String computeTocRelativeFile(OutlineItem item, Path path) {
String name = ((SplitOutlineItem) item).getSplitTarget();
File pathDestDir = computeDestDir(path);
File tocParentFile = tocFile.getParentFile();
String prefix = computePrefixPath(pathDestDir, tocParentFile);
String relativePath = prefix + '/' + name;
relativePath = relativePath.replace('\\', '/');
if (helpPrefix != null) {
String helpPath = helpPrefix;
helpPath = helpPath.replace('\\', '/');
if (!helpPath.endsWith("/")) {
// $NON-NLS-1$
// $NON-NLS-1$
helpPath += "/";
}
relativePath = helpPath + relativePath;
}
// $NON-NLS-1$//$NON-NLS-2$
relativePath = relativePath.replaceAll("/{2,}", "/");
return relativePath;
}
use of org.eclipse.mylyn.wikitext.splitter.SplitOutlineItem in project mylyn.docs by eclipse.
the class MarkupToEclipseHelpMojoTest method embeddedTableOfContents.
@Test
public void embeddedTableOfContents() {
HtmlDocumentBuilder builder = mock(HtmlDocumentBuilder.class);
SplitOutlineItem item = mock(SplitOutlineItem.class);
File htmlOutputFile = mock(File.class);
SplittingHtmlDocumentBuilder splittingBuilder = markupToEclipseHelp.createSplittingBuilder(builder, item, htmlOutputFile, "");
assertFalse(splittingBuilder.isEmbeddedTableOfContents());
markupToEclipseHelp.embeddedTableOfContents = true;
splittingBuilder = markupToEclipseHelp.createSplittingBuilder(builder, item, htmlOutputFile, "");
assertTrue(splittingBuilder.isEmbeddedTableOfContents());
}
use of org.eclipse.mylyn.wikitext.splitter.SplitOutlineItem in project mylyn.docs by eclipse.
the class MarkupToEclipseHelpMojoTest method assertNavigationImagesPath.
private void assertNavigationImagesPath(String expected, String relativePath) {
HtmlDocumentBuilder builder = mock(HtmlDocumentBuilder.class);
SplitOutlineItem item = mock(SplitOutlineItem.class);
SplittingHtmlDocumentBuilder splittingBuilder = markupToEclipseHelp.createSplittingBuilder(builder, item, mock(File.class), relativePath);
assertEquals(expected, splittingBuilder.getNavigationImagePath());
}
use of org.eclipse.mylyn.wikitext.splitter.SplitOutlineItem 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);
}
}
}
use of org.eclipse.mylyn.wikitext.splitter.SplitOutlineItem in project mylyn.docs by eclipse.
the class SplittingHtmlDocumentBuilderTest method generateContents.
private void generateContents(String markup, boolean embeddedTableOfContents) throws IOException, FileNotFoundException {
try (OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(outputFile), StandardCharsets.UTF_8)) {
rootBuilder = new HtmlDocumentBuilder(out, true);
SplittingOutlineParser outlineParser = new SplittingOutlineParser();
outlineParser.setMarkupLanguage(new TextileLanguage());
outlineParser.setSplittingStrategy(new DefaultSplittingStrategy());
SplitOutlineItem outline = outlineParser.parse(markup);
outline.setSplitTarget(outputFile.getName());
builder.setEmbeddedTableOfContents(embeddedTableOfContents);
builder.setRootBuilder(rootBuilder);
builder.setRootFile(outputFile);
builder.setFormatting(true);
builder.setOutline(outline);
MarkupParser parser = new MarkupParser(new TextileLanguage());
parser.setBuilder(builder);
parser.parse(markup);
}
}
Aggregations