Search in sources :

Example 21 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class ServiceLocator method filterDuplicates.

private Set<MarkupLanguage> filterDuplicates(Set<MarkupLanguage> markupLanguages) {
    Multimap<String, Class<?>> markupLanguageClassesByName = HashMultimap.create();
    ImmutableSet.Builder<MarkupLanguage> builder = ImmutableSet.builder();
    for (MarkupLanguage language : markupLanguages) {
        if (markupLanguageClassesByName.put(language.getName(), language.getClass())) {
            builder.add(language);
        }
    }
    return builder.build();
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)

Example 22 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class HtmlLanguageIntegrationTest method defaultMarkupLanguageHasImageSupport.

@Test
public void defaultMarkupLanguageHasImageSupport() {
    MarkupLanguage sourceLanguage = getDefaultMarkupLanguage("Source HTML");
    MarkupLanguage targetLanguage = getDefaultMarkupLanguage("Target HTML");
    StringWriter stringWriter = new StringWriter();
    MarkupParser markupParser = getMarkupParser(sourceLanguage, targetLanguage, stringWriter);
    markupParser.parse("Text Before Image<img src=\"/favicon.ico\"/>Text After Image", false);
    assertEquals("Text Before Image<img border=\"0\" src=\"/favicon.ico\"/>Text After Image", stringWriter.toString());
}
Also used : StringWriter(java.io.StringWriter) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser) Test(org.junit.Test)

Example 23 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class MarkupToEclipseHelpMojo method execute.

public void execute() throws MojoExecutionException, MojoFailureException {
    try {
        ensureOutputFolderExists();
        ensureSourceFolderExists();
        ServiceLocator serviceLocator = ServiceLocator.getInstance(MarkupToEclipseHelpMojo.class.getClassLoader());
        Set<MarkupLanguage> markupLanguages = serviceLocator.getAllMarkupLanguages();
        if (markupLanguages.isEmpty()) {
            throw new MojoFailureException("No markup languages are available");
        }
        getLog().info(format("Generating Eclipse help content from sources: {0} -> {1}", sourceFolder, outputFolder));
        final FileToMarkupLanguage fileToMarkupLanguage = new FileToMarkupLanguage(markupLanguages);
        SourceFileTraversal fileTraversal = new SourceFileTraversal(sourceFolder);
        final AtomicInteger fileCount = new AtomicInteger();
        fileTraversal.traverse(new Visitor() {

            @Override
            public void accept(String relativePath, File sourceFile) {
                fileCount.incrementAndGet();
                process(sourceFile, relativePath, fileToMarkupLanguage.get(sourceFile));
            }
        });
        getLog().info(format("Processed {0} files", fileCount.get()));
    } catch (BuildFailureException e) {
        getLog().error(e.getMessage(), e);
        throw new MojoFailureException(e.getMessage(), e.getCause());
    }
}
Also used : Visitor(org.eclipse.mylyn.wikitext.maven.internal.SourceFileTraversal.Visitor) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ServiceLocator(org.eclipse.mylyn.wikitext.util.ServiceLocator) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) File(java.io.File)

Example 24 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class FileToMarkupLanguageTest method getCaseInsensitive.

@Test
public void getCaseInsensitive() {
    MarkupLanguage language1 = mockMarkupLanguage("Test");
    MarkupLanguage language2 = mockMarkupLanguage("Test2");
    FileToMarkupLanguage fileToMarkupLanguage = create(language1, language2);
    assertSame(language1, fileToMarkupLanguage.get(mockFile("test.Test")));
    assertSame(language1, fileToMarkupLanguage.get(mockFile("test.test")));
    assertSame(language2, fileToMarkupLanguage.get(mockFile("test.test2")));
    assertSame(language2, fileToMarkupLanguage.get(mockFile("test.tEst2")));
}
Also used : FileToMarkupLanguage(org.eclipse.mylyn.wikitext.maven.internal.FileToMarkupLanguage) FileToMarkupLanguage(org.eclipse.mylyn.wikitext.maven.internal.FileToMarkupLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) Test(org.junit.Test)

Example 25 with MarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.

the class CreoleLanguageTest method testDiscoverable.

public void testDiscoverable() {
    MarkupLanguage language = ServiceLocator.getInstance().getMarkupLanguage("Creole");
    assertNotNull(language);
    assertTrue(language instanceof CreoleLanguage);
}
Also used : CreoleLanguage(org.eclipse.mylyn.wikitext.creole.CreoleLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)

Aggregations

MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)60 Test (org.junit.Test)18 AbstractMarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)15 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)8 File (java.io.File)7 BuildException (org.apache.tools.ant.BuildException)7 CoreException (org.eclipse.core.runtime.CoreException)7 MockMarkupLanguage (org.eclipse.mylyn.internal.wikitext.MockMarkupLanguage)7 StringWriter (java.io.StringWriter)6 HashMap (java.util.HashMap)5 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)5 FileSet (org.apache.tools.ant.types.FileSet)5 OutlineItem (org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)5 Point (org.eclipse.swt.graphics.Point)5 IOException (java.io.IOException)4 IFile (org.eclipse.core.resources.IFile)4 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)4 TreeMap (java.util.TreeMap)3 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3