org.umlg.sqlg.doc.AsciiDoctor Maven / Gradle / Ivy
package org.umlg.sqlg.doc;
import org.asciidoctor.Asciidoctor;
import org.asciidoctor.Attributes;
import org.asciidoctor.OptionsBuilder;
import org.asciidoctor.SafeMode;
import org.asciidoctor.ast.Document;
import org.asciidoctor.extension.DocinfoProcessor;
import java.io.File;
import java.util.Map;
import static org.asciidoctor.Asciidoctor.Factory.create;
/**
* Date: 2016/12/14
* Time: 1:43 PM
*/
public class AsciiDoctor {
public static void main(String[] args) {
new AsciiDoctor().createDocs();
}
private void createDocs() {
// String version = "2.0.1";
String version = "2.1.6";
Asciidoctor asciidoctor = create();
try {
File file = new File("sqlg-doc/docs/" + version + "/sqlg.adoc");
File html = new File("sqlg-doc/docs/" + version + "/index.html");
Attributes attributes = new Attributes();
attributes.setBackend("html5");
attributes.setStyleSheetName("asciidoctor-default.css");
attributes.setDocType("book");
attributes.setSourceHighlighter("highlightjs");
Map options = OptionsBuilder.options()
.attributes(attributes)
.toFile(new File(html.getPath()))
.headerFooter(true)
.safe(SafeMode.SERVER)
.asMap();
options.put("location", ":footer");
Docinfo docinfo = new Docinfo(options);
asciidoctor.javaExtensionRegistry().docinfoProcessor(docinfo);
asciidoctor.convertFile(
file,
options
);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private class Docinfo extends DocinfoProcessor {
Docinfo(Map config) {
super(config);
}
@Override
public String process(Document document) {
return "\n" +
"\n" +
"\n";
}
}
}