Java Code Examples for org.asciidoctor.Asciidoctor#shutdown()
The following examples show how to use
org.asciidoctor.Asciidoctor#shutdown() .
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: CukedoctorPublisher.java From cucumber-living-documentation-plugin with MIT License | 6 votes |
private Runnable run(final List<Feature> features, final DocumentAttributes attrs, final CukedoctorConfig cukedoctorConfig, final String outputPath) { return new Runnable() { @Override public void run() { Asciidoctor asciidoctor = null; try { asciidoctor = Asciidoctor.Factory.create(CukedoctorPublisher.class.getClassLoader()); generateDocumentation(features, attrs, cukedoctorConfig, outputPath, asciidoctor); } catch (Exception e) { e.printStackTrace(); final String errorMessage = String.format("Unexpected error on documentation generation, message %s, cause %s", e.getMessage(), e.getCause()); throw new RuntimeException(errorMessage); } finally { if (asciidoctor != null) { asciidoctor.shutdown(); } } } }; }
Example 2
Source File: CukedoctorPublisher.java From cucumber-living-documentation-plugin with MIT License | 5 votes |
/** * generates html and PDF documentation 'inlined' otherwise if we execute them in separated threads * only the last thread content is rendered (cause they work on the same adoc file) * * @return */ private Runnable runAll(final List<Feature> features, final DocumentAttributes attrs, final CukedoctorConfig cukedoctorConfig, final String outputPath) { return new Runnable() { @Override public void run() { Asciidoctor asciidoctor = null; try { asciidoctor = Asciidoctor.Factory.create(CukedoctorPublisher.class.getClassLoader()); attrs.backend("html5"); generateDocumentation(features, attrs, cukedoctorConfig, outputPath, asciidoctor); attrs.backend("pdf"); generateDocumentation(features, attrs, cukedoctorConfig, outputPath, asciidoctor); } catch (Exception e) { e.printStackTrace(); final String errorMessage = String.format("Unexpected error on documentation generation, message %s, cause %s", e.getMessage(), e.getCause()); throw new RuntimeException(errorMessage); } finally { if (asciidoctor != null) { asciidoctor.shutdown(); } } } }; }
Example 3
Source File: MyResource.java From thorntail with Apache License 2.0 | 5 votes |
@GET @Produces(MediaType.TEXT_HTML) public String get() { Asciidoctor asciidoctor = Asciidoctor.Factory.create(); try { return asciidoctor.render("Hello World\n-----------", Collections.emptyMap()); } finally { asciidoctor.shutdown(); } }
Example 4
Source File: AsciidoctorTestObserver.java From asciidoctorj with Apache License 2.0 | 5 votes |
public void afterTestShutdownUnsharedAsciidoctorInstance(@Observes After after) { Asciidoctor asciidoctor = scopedAsciidoctor.get().getUnsharedAsciidoctor(); if (asciidoctor != null) { asciidoctor.shutdown(); scopedAsciidoctor.get().setUnsharedAsciidoctor(null); } }
Example 5
Source File: AsciidoctorTestObserver.java From asciidoctorj with Apache License 2.0 | 5 votes |
public void afterTestClassShutdownSharedAsciidoctorInstance(@Observes AfterClass afterClass) { Asciidoctor asciidoctor = scopedAsciidoctor.get().getSharedAsciidoctor(); if (asciidoctor != null) { asciidoctor.shutdown(); scopedAsciidoctor.get().setSharedAsciidoctor(null); } }
Example 6
Source File: AsciidoctorInterface.java From asciidoctorj with Apache License 2.0 | 5 votes |
@Test public void destroyAsciidoctorInstance() { //tag::shutdown[] Asciidoctor asciidoctor = Asciidoctor.Factory.create(); asciidoctor.shutdown(); //end::shutdown[] }
Example 7
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; }