All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.umlg.sqlg.doc.AsciiDoctor Maven / Gradle / Ivy

There is a newer version: 3.1.0
Show newest version
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";
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy