use of com.github.jcustenborder.kafka.connect.utils.templates.rst.RstTemplateHelper in project connect-utils by jcustenborder.
the class BaseDocumentationTest method process.
void process(Writer writer, Template template, Object input) throws IOException, TemplateException {
Map<String, Object> variables = ImmutableMap.of("input", input, "rstHelper", new RstTemplateHelper(), "markdownHelper", new MarkdownTemplateHelper());
template.process(variables, writer);
}
use of com.github.jcustenborder.kafka.connect.utils.templates.rst.RstTemplateHelper in project connect-utils by jcustenborder.
the class BaseDocumentationTest method schema.
@TestFactory
public Stream<DynamicTest> schema() throws IOException {
final File parentDirectory = new File(outputDirectory, "schemas");
if (!parentDirectory.exists()) {
parentDirectory.mkdirs();
}
List<Schema> schemas = schemas();
if (null != schemas && !schemas.isEmpty()) {
final File schemaRstPath = new File(outputDirectory, "schemas.rst");
final String schemaRst = "=======\n" + "Schemas\n" + "=======\n" + "\n" + ".. toctree::\n" + " :maxdepth: 0\n" + " :caption: Schemas:\n" + " :glob:\n" + "\n" + " schemas/*";
Files.write(schemaRst, schemaRstPath, Charsets.UTF_8);
}
final String templateName = "rst/schema.rst.ftl";
return this.schemas().stream().filter(schema -> !Strings.isNullOrEmpty(schema.name())).map(schema -> dynamicTest(String.format("%s.%s", schema.type(), schema.name()), () -> {
StringBuilder filenameBuilder = new StringBuilder().append(schema.type().toString().toLowerCase());
if (!Strings.isNullOrEmpty(schema.name())) {
filenameBuilder.append('.').append(schema.name());
}
filenameBuilder.append(".rst");
File outputFile = new File(parentDirectory, filenameBuilder.toString());
Template template = configuration.getTemplate(templateName);
log.info("Writing {}", outputFile);
try (Writer writer = Files.newWriter(outputFile, Charsets.UTF_8)) {
Map<String, Object> variables = ImmutableMap.of("input", TemplateSchema.of(schema), "helper", new RstTemplateHelper());
template.process(variables, writer);
}
}));
}
Aggregations