Java Code Examples for org.asciidoctor.Asciidoctor#convertFile()
The following examples show how to use
org.asciidoctor.Asciidoctor#convertFile() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Swagger2ToDocTest.java From singleton with Eclipse Public License 2.0 | 6 votes |
@Test public void convertV1Doc() { Asciidoctor asciidoctor = create(); Options options = new Options(); options.setInPlace(true); options.setBackend("html5"); options.setSafe(SafeMode.SAFE); options.setToDir(baseOutputDir + "/html5/v1"); options.setMkDirs(true); options.setDocType("docbook"); Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put("toc", "left"); attributes.put("toclevels", "3"); attributes.put("generated", "./generated/v1"); options.setAttributes(attributes); asciidoctor.convertFile(new File(baseOutputDir + "/index.adoc"), options); }
Example 2
Source File: Swagger2ToDocTest.java From singleton with Eclipse Public License 2.0 | 6 votes |
@Test public void convertV2Doc() { Asciidoctor asciidoctor = create(); Options options = new Options(); options.setInPlace(true); options.setBackend("html5"); options.setSafe(SafeMode.SAFE); options.setToDir(baseOutputDir + "/html5/v2"); options.setMkDirs(true); options.setDocType("docbook"); Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put("toc", "left"); attributes.put("toclevels", "3"); attributes.put("generated", "./generated/v2"); options.setAttributes(attributes); asciidoctor.convertFile(new File(baseOutputDir + "/index.adoc"), options); }
Example 3
Source File: CukedoctorMojo.java From cukedoctor with Apache License 2.0 | 6 votes |
private void generateDocumentation(DocumentAttributes documentAttributes, File adocFile, Asciidoctor asciidoctor) { OptionsBuilder ob = OptionsBuilder.options() .safe(SafeMode.UNSAFE) .backend(documentAttributes.getBackend()) .attributes(documentAttributes.toMap()); getLog().info("Document attributes:\n"+documentAttributes.toMap()); ExtensionGroup cukedoctorExtensionGroup = asciidoctor.createGroup(CUKEDOCTOR_EXTENSION_GROUP_NAME); if ("pdf".equals(documentAttributes.getBackend())) { cukedoctorExtensionGroup.unregister(); //remove auxiliary files FileUtil.removeFile(adocFile.getParent() + "/" + outputFileName + "-theme.yml"); } asciidoctor.convertFile(adocFile, ob); getLog().info("Generated documentation at: " + adocFile.getParent()); }
Example 4
Source File: TextConverterTest.java From asciidoctorj with Apache License 2.0 | 6 votes |
@Test public void should_use_text_converter_for_conversion(@ArquillianResource Asciidoctor asciidoctor) { //tag::include[] File test_adoc = //... //end::include[] classpathResources.getResource("textconvertertest.adoc"); //tag::include[] asciidoctor.javaConverterRegistry().register(TextConverter.class); // <1> String result = asciidoctor.convertFile( test_adoc, OptionsBuilder.options() .backend("text") // <2> .toFile(false)); //end::include[] verifyResult(result); }
Example 5
Source File: GenerateDocumentation.java From inception with Apache License 2.0 | 5 votes |
private static void buildDoc(String type, Path outputDir) { Attributes attributes = AttributesBuilder.attributes() .attribute("source-dir", getInceptionDir() + "/") .attribute("include-dir", outputDir.resolve("asciidoc").resolve(type) .toString() + "/") .attribute("imagesdir", outputDir.resolve("asciidoc").resolve(type) .resolve("images").toString() + "/") .attribute("doctype", "book") .attribute("toclevels", "8") .attribute("sectanchors", "true") .attribute("docinfo1", "true") .attribute("project-version", "DEVELOPER BUILD") .attribute("revnumber", "DEVELOPER BUILD") .attribute("product-name", "INCEpTION") .attribute("product-website-url", "https://inception-project.github.io") .attribute("icons", "font") .attribute("toc", "left") .get(); OptionsBuilder options = OptionsBuilder.options() .toDir(outputDir.toFile()) .safe(SafeMode.UNSAFE) .attributes(attributes); Asciidoctor asciidoctor = Asciidoctor.Factory.create(); asciidoctor.requireLibrary("asciidoctor-diagram"); File f = new File(outputDir.resolve("asciidoc").resolve(type).toString() + ".adoc"); asciidoctor.convertFile(f , options); }
Example 6
Source File: CukedoctorPublisher.java From cucumber-living-documentation-plugin with MIT License | 5 votes |
protected synchronized void generateDocumentation(List<Feature> features, DocumentAttributes attrs, CukedoctorConfig cukedoctorConfig, String outputPath, Asciidoctor asciidoctor) { asciidoctor.unregisterAllExtensions(); if (!attrs.getBackend().equalsIgnoreCase("pdf")) { new CukedoctorExtensionRegistry().register(asciidoctor); } CukedoctorConverter converter = Cukedoctor.instance(features, attrs, cukedoctorConfig); String doc = converter.renderDocumentation(); File adocFile = FileUtil.saveFile(outputPath + "/documentation.adoc", doc); asciidoctor.convertFile(adocFile, OptionsBuilder.options().backend(attrs.getBackend()).safe(SafeMode.SAFE).asMap()); }
Example 7
Source File: GenerateDocumentation.java From webanno with Apache License 2.0 | 5 votes |
private static void buildDoc(String type, Path outputDir) { Attributes attributes = AttributesBuilder.attributes() .attribute("source-dir", getWebannoDir() + "/") .attribute("include-dir", outputDir.resolve("asciidoc").resolve(type) .toString() + "/") .attribute("imagesdir", outputDir.resolve("asciidoc").resolve(type) .resolve("images").toString() + "/") .attribute("doctype", "book") .attribute("toclevels", "8") .attribute("sectanchors", "true") .attribute("docinfo1", "true") .attribute("project-version", "DEVELOPER BUILD") .attribute("revnumber", "DEVELOPER BUILD") .attribute("product-name", "WebAnno") .attribute("product-website-url", "https://webanno.github.io/webanno/") .attribute("icons", "font") .attribute("toc", "preamble") .get(); OptionsBuilder options = OptionsBuilder.options() .toDir(outputDir.toFile()) .safe(SafeMode.UNSAFE) .attributes(attributes); Asciidoctor asciidoctor = Asciidoctor.Factory.create(); asciidoctor.requireLibrary("asciidoctor-diagram"); File f = new File(outputDir.resolve("asciidoc").resolve(type).toString() + ".adoc"); asciidoctor.convertFile(f , options); }
Example 8
Source File: AsciiDoctor.java From sqlg with MIT License | 5 votes |
private void createDocs() { String version = "2.0.0-SNAPSHOT"; 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<String, Object> 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); } }
Example 9
Source File: TextConverterTest.java From asciidoctorj with Apache License 2.0 | 5 votes |
@Test public void should_use_text_converter_for_conversion_registered_as_service_impl() throws Exception { ClassLoader oldTCCL = Thread.currentThread().getContextClassLoader(); try { URL serviceDir = classpathResources.getResource("converterregistry").toURI().toURL(); URLClassLoader tccl = new URLClassLoader(new URL[] { serviceDir }); Thread.currentThread().setContextClassLoader(tccl); Asciidoctor asciidoctor = Asciidoctor.Factory.create(); //tag::include[] File test_adoc = //... //end::include[] classpathResources.getResource("textconvertertest.adoc"); //tag::include[] String result = asciidoctor.convertFile( test_adoc, OptionsBuilder.options() .backend("text") // <1> .toFile(false)); //end::include[] verifyResult(result); } finally { Thread.currentThread().setContextClassLoader(oldTCCL); } }
Example 10
Source File: SimpleAsciidoctorRendering.java From asciidoctorj with Apache License 2.0 | 5 votes |
public static void main(String[] args) { Asciidoctor asciidoctor = Asciidoctor.Factory.create(); // <1> asciidoctor.convertFile( // <2> new File(args[0]), OptionsBuilder.options() // <3> .toFile(true) .safe(SafeMode.UNSAFE)); }
Example 11
Source File: AsciidoctorInvoker.java From asciidoctorj with Apache License 2.0 | 5 votes |
private String renderInput(Asciidoctor asciidoctor, Options options, List<File> inputFiles) { if(inputFiles.size() == 1 && "-".equals(inputFiles.get(0).getName())) { return asciidoctor.convert(readInputFromStdIn(), options); } StringBuilder output = new StringBuilder(); for (File inputFile : inputFiles) { if (inputFile.canRead()) { String renderedFile = asciidoctor .convertFile(inputFile, options); if (renderedFile != null) { output.append(renderedFile).append( System.getProperty("line.separator")); } } else { System.err.println("asciidoctor: FAILED: input file(s) '" + inputFile.getAbsolutePath() + "' missing or cannot be read"); throw new IllegalArgumentException( "asciidoctor: FAILED: input file(s) '" + inputFile.getAbsolutePath() + "' missing or cannot be read"); } } return output.toString(); }
Example 12
Source File: CukedoctorMain.java From cukedoctor with Apache License 2.0 | 4 votes |
public String execute(List<Feature> features, DocumentAttributes documentAttributes, String outputName) { if (title == null) { title = "Living Documentation"; } if (documentAttributes == null) { documentAttributes = new DocumentAttributes().docTitle(title); } if (!hasText(documentAttributes.getBackend())) { documentAttributes.backend("html5"); } if (outputName == null) { outputName = title.replaceAll(" ", "_"); } if (hideFeaturesSection != null) { System.setProperty("HIDE_FEATURES_SECTION", Boolean.toString(hideFeaturesSection)); } if (hideSummarySection != null) { System.setProperty("HIDE_SUMMARY_SECTION", Boolean.toString(hideSummarySection)); } if (hideScenarioKeyword != null) { System.setProperty("HIDE_SCENARIO_KEYWORD", Boolean.toString(hideScenarioKeyword)); } if (hideStepTime != null) { System.setProperty("HIDE_STEP_TIME", Boolean.toString(hideStepTime)); } if (hideTags != null) { System.setProperty("HIDE_TAGS", Boolean.toString(hideTags)); } CukedoctorConverter converter = Cukedoctor.instance(features, documentAttributes); String doc = converter.renderDocumentation(); File adocFile = FileUtil.saveFile(outputName, doc); Asciidoctor asciidoctor = Asciidoctor.Factory.create(); ExtensionGroup cukedoctorExtensionGroup = asciidoctor.createGroup(CUKEDOCTOR_EXTENSION_GROUP_NAME); if (documentAttributes.getBackend().equalsIgnoreCase("pdf")) { cukedoctorExtensionGroup.unregister(); } OptionsBuilder ob = OptionsBuilder.options() .safe(SafeMode.UNSAFE) .backend(documentAttributes.getBackend()) .attributes(documentAttributes.toMap()); System.out.println("Document attributes\n"+documentAttributes.toMap()); asciidoctor.convertFile(adocFile, ob); asciidoctor.shutdown(); return doc; }