use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.
the class MarkupToDitaTask method execute.
@Override
public void execute() throws BuildException {
if (file == null && filesets.isEmpty()) {
// $NON-NLS-1$
throw new BuildException(Messages.getString("MarkupToDitaTask.1"));
}
if (file != null && !filesets.isEmpty()) {
// $NON-NLS-1$
throw new BuildException(Messages.getString("MarkupToDitaTask.2"));
}
if (file != null) {
if (!file.exists()) {
// $NON-NLS-1$
throw new BuildException(MessageFormat.format(Messages.getString("MarkupToDitaTask.3"), file));
} else if (!file.isFile()) {
// $NON-NLS-1$
throw new BuildException(MessageFormat.format(Messages.getString("MarkupToDitaTask.4"), file));
} else if (!file.canRead()) {
// $NON-NLS-1$
throw new BuildException(MessageFormat.format(Messages.getString("MarkupToDitaTask.5"), file));
}
}
if (filenameFormat == null) {
switch(topicStrategy) {
case NONE:
// $NON-NLS-1$
filenameFormat = "$1.dita";
break;
default:
// $NON-NLS-1$
filenameFormat = "$1.ditamap";
}
}
MarkupLanguage markupLanguage = createMarkupLanguage();
for (FileSet fileset : filesets) {
File filesetBaseDir = fileset.getDir(getProject());
DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
String[] files = ds.getIncludedFiles();
if (files != null) {
File baseDir = ds.getBasedir();
for (String file : files) {
File inputFile = new File(baseDir, file);
try {
processFile(markupLanguage, filesetBaseDir, inputFile);
} catch (BuildException e) {
throw e;
} catch (Exception e) {
throw new BuildException(MessageFormat.format(// $NON-NLS-1$
Messages.getString("MarkupToDitaTask.6"), // $NON-NLS-1$
inputFile, e.getMessage()), e);
}
}
}
}
if (file != null) {
try {
processFile(markupLanguage, file.getParentFile(), file);
} catch (BuildException e) {
throw e;
} catch (Exception e) {
throw new BuildException(MessageFormat.format(Messages.getString("MarkupToDitaTask.7"), file, e.getMessage()), // $NON-NLS-1$
e);
}
}
}
use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.
the class MarkupToHtmlTask method execute.
@Override
public void execute() throws BuildException {
if (file == null && filesets.isEmpty()) {
// $NON-NLS-1$
throw new BuildException(Messages.getString("MarkupToHtmlTask.1"));
}
if (file != null && !filesets.isEmpty()) {
// $NON-NLS-1$
throw new BuildException(Messages.getString("MarkupToHtmlTask.2"));
}
if (file != null) {
if (!file.exists()) {
// $NON-NLS-1$
throw new BuildException(MessageFormat.format(Messages.getString("MarkupToHtmlTask.3"), file));
} else if (!file.isFile()) {
// $NON-NLS-1$
throw new BuildException(MessageFormat.format(Messages.getString("MarkupToHtmlTask.4"), file));
} else if (!file.canRead()) {
// $NON-NLS-1$
throw new BuildException(MessageFormat.format(Messages.getString("MarkupToHtmlTask.5"), file));
}
}
MarkupLanguage markupLanguage = createMarkupLanguage();
for (Stylesheet stylesheet : stylesheets) {
if (stylesheet.url == null && stylesheet.file == null) {
// $NON-NLS-1$
throw new BuildException(Messages.getString("MarkupToHtmlTask.6"));
}
if (stylesheet.url != null && stylesheet.file != null) {
// $NON-NLS-1$
throw new BuildException(Messages.getString("MarkupToHtmlTask.7"));
}
if (stylesheet.file != null) {
if (!stylesheet.file.exists()) {
// $NON-NLS-1$
throw new BuildException(Messages.getString("MarkupToHtmlTask.8") + stylesheet.file);
}
if (!stylesheet.file.isFile()) {
// $NON-NLS-1$
throw new BuildException(Messages.getString("MarkupToHtmlTask.9") + stylesheet.file);
}
if (!stylesheet.file.canRead()) {
// $NON-NLS-1$
throw new BuildException(Messages.getString("MarkupToHtmlTask.10") + stylesheet.file);
}
}
}
Set<File> outputFolders = new HashSet<File>();
for (FileSet fileset : filesets) {
File filesetBaseDir = fileset.getDir(getProject());
DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
String[] files = ds.getIncludedFiles();
if (files != null) {
File baseDir = ds.getBasedir();
for (String file : files) {
File inputFile = new File(baseDir, file);
testForOutputFolderConflict(outputFolders, inputFile);
try {
processFile(markupLanguage, filesetBaseDir, inputFile);
} catch (BuildException e) {
throw e;
} catch (Exception e) {
throw new BuildException(MessageFormat.format(// $NON-NLS-1$
Messages.getString("MarkupToHtmlTask.11"), // $NON-NLS-1$
inputFile, e.getMessage()), e);
}
}
}
}
if (file != null) {
testForOutputFolderConflict(outputFolders, file);
try {
processFile(markupLanguage, file.getParentFile(), file);
} catch (BuildException e) {
throw e;
} catch (Exception e) {
throw new BuildException(MessageFormat.format(Messages.getString("MarkupToHtmlTask.12"), file, e.getMessage()), // $NON-NLS-1$
e);
}
}
}
use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.
the class TracWikiLanguageTest method testDiscoverable.
public void testDiscoverable() {
// $NON-NLS-1$
MarkupLanguage language = ServiceLocator.getInstance().getMarkupLanguage("TracWiki");
assertNotNull(language);
assertTrue(language instanceof TracWikiLanguage);
}
use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.
the class CommonMarkLanguageTest method isDiscoverable.
@Test
public void isDiscoverable() {
MarkupLanguage markupLanguage = ServiceLocator.getInstance().getMarkupLanguage("CommonMark");
assertNotNull(markupLanguage);
assertEquals(CommonMarkLanguage.class, markupLanguage.getClass());
}
use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.
the class HtmlLanguageTest method isDiscoverable.
@Test
public void isDiscoverable() {
MarkupLanguage language = ServiceLocator.getInstance().getMarkupLanguage("HTML");
assertNotNull(language);
assertTrue(language instanceof HtmlLanguage);
}
Aggregations