private String assertDoc(String pkg) throws Exception { Compiler<TestGenProcessor> compiler = buildCompiler(new TestGenProcessor(), pkg); compiler.assertCompile(); return compiler.processor.getDoc(pkg); }
@Test public void testNestedBlocks() throws Exception { Compiler<TestGenProcessor> compiler = buildCompiler(new TestGenProcessor(), "io.vertx.test.postprocessors.nested"); compiler.assertCompile(); String content = compiler.processor.getDoc("io.vertx.test.postprocessors.nested"); assertThat(content, containsString("[source,java]")); assertThat(content, containsString("----")); assertThat(content, not(containsString("\\----"))); assertThat(content, containsString("System.out.println(\"Hello\");")); }
private String assertDocFile(String relativeName) throws Exception { File src = docFile(relativeName); Compiler<TestGenProcessor> compiler = buildCompiler(new TestGenProcessor(), "io.vertx.test.file"); compiler.setOption("docgen.source", src.getAbsolutePath()); compiler.assertCompile(); return compiler.processor.getDoc(src.getName()); }
@Test public void testMissingPostProcessor() throws Exception { Compiler<TestGenProcessor> compiler = buildCompiler(new TestGenProcessor(), "io.vertx.test.postprocessors.missing"); compiler.assertCompile(); String content = compiler.processor.getDoc("io.vertx.test.postprocessors.missing"); // String processed = compiler.processor.applyPostProcessors(content); assertThat(content, containsString("This should be included.")); assertThat(content, containsString("[missing]")); assertThat(content, containsString("----")); }
@Test public void testCodeBlocks() throws Exception { // Code blocks must not be touched by pre-processors. Compiler<TestGenProcessor> compiler = buildCompiler(new TestGenProcessor(), "io.vertx.test.postprocessors.code"); compiler.assertCompile(); String content = compiler.processor.getDoc("io.vertx.test.postprocessors.code"); assertThat(content, containsString("[source,java]")); assertThat(content, containsString("[source]")); assertThat(content, containsString("----")); assertThat(content, containsString("System.out.println(\"Hello\");")); assertThat(content, containsString(" System.out.println(\"Bye\");")); }
compiler.fileManager.setLocation(StandardLocation.CLASS_PATH, files); compiler.assertCompile(); String s = compiler.processor.getDoc("io.vertx.test.linkresolution.resolving"); assertEquals("`link:type[ResolvableType]`", s); assertEquals(Collections.<Coordinate>singletonList(null), resolved);
@Test public void testLinkUnresolved() throws Exception { Compiler<TestGenProcessor> compiler = buildCompiler(new TestGenProcessor() { @Override protected String resolveTypeLink(TypeElement elt, Coordinate coordinate) { return null; } }, "io.vertx.test.linkunresolved"); compiler.assertCompile(); String s = compiler.processor.getDoc("io.vertx.test.linkunresolved"); assertEquals("`TheClass`", s); }
"io.vertx.test.postprocessors.language"); compiler.assertCompile(); String content = compiler.processor.getDoc("io.vertx.test.postprocessors.language"); "io.vertx.test.postprocessors.language"); compiler.assertCompile(); content = compiler.processor.getDoc("io.vertx.test.postprocessors.language"); assertThat(content, not(containsString("This is only displayed for java."))); assertThat(content, containsString("This is only displayed for javascript and ruby.")); "io.vertx.test.postprocessors.language"); compiler.assertCompile(); content = compiler.processor.getDoc("io.vertx.test.postprocessors.language"); assertThat(content, not(containsString("This is only displayed for java."))); assertThat(content, not(containsString("This is only displayed for javascript and ruby.")));
compiler.fileManager.setLocation(StandardLocation.CLASS_PATH, files); compiler.assertCompile(); String s = compiler.processor.getDoc("io.vertx.test.linkresolution.resolving"); assertEquals("`link:type[ResolvableType]`", s); assertEquals(1, resolved.size());
@Test public void testVariableSubstitution() throws Exception { Compiler<TestGenProcessor> compiler = buildCompiler(new TestGenProcessor(), "io.vertx.test.variables"); compiler.setOption("foo", "hello"); compiler.setOption("bar", "not-used"); compiler.setOption("baz", "vert.x"); compiler.assertCompile(); String content = compiler.processor.getDoc("io.vertx.test.variables"); String processed = compiler.processor.applyVariableSubstitution(content); assertThat(processed, containsString("hello")); assertThat(processed, containsString("${missing}")); assertThat(processed, containsString("vert.x")); assertThat(processed, containsString("${}")); assertThat(processed, not(containsString("not"))); }
@Test public void testLinksInPostProcessedContent() throws Exception { Compiler<TestGenProcessor> compiler = buildCompiler(new TestGenProcessor(), "io.vertx.test.postprocessors.links"); compiler.assertCompile(); compiler.processor.registerPostProcessor(new PostProcessor() { @Override public String getName() { return "test"; } @Override public String process(String name, String content, String... args) { return content; } }); String content = compiler.processor.getDoc("io.vertx.test.postprocessors.links"); assertThat(content, containsString("`link:type[BaseProcessor]`")); }