Java Code Examples for org.asciidoctor.Asciidoctor#createGroup()

The following examples show how to use org.asciidoctor.Asciidoctor#createGroup() . 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: CukedoctorMojo.java    From cukedoctor with Apache License 2.0 6 votes vote down vote up
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 2
Source File: CukedoctorExtensionRegistry.java    From cukedoctor with Apache License 2.0 5 votes vote down vote up
@Override
public void register(Asciidoctor asciidoctor) {
	//null means extension is enabled (by default)
	if(System.getProperty(DISABLE_ALL_EXT_KEY) != null) {
		return;
	}

    ExtensionGroup cukedoctorExtensionGroup = asciidoctor.createGroup(CUKEDOCTOR_EXTENSION_GROUP_NAME);
	cukedoctorExtensionGroup.postprocessor(CukedoctorScriptExtension.class);

	if(System.getProperty(FILTER_DISABLE_EXT_KEY) == null){
		cukedoctorExtensionGroup.postprocessor(CukedoctorFilterExtension.class);
	}
	if(System.getProperty(MINMAX_DISABLE_EXT_KEY) == null){
		cukedoctorExtensionGroup.blockMacro("minmax", CukedoctorMinMaxExtension.class);
	}

	if(System.getProperty(THEME_DISABLE_EXT_KEY) == null){
		cukedoctorExtensionGroup.postprocessor(CukedoctorThemeExtension.class);
	}

	if(System.getProperty(FOOTER_DISABLE_EXT_KEY) == null){
		cukedoctorExtensionGroup.postprocessor(CukedoctorFooterExtension.class);
	}
	if(System.getProperty(STYLE_DISABLE_EXT_KEY) == null){
		cukedoctorExtensionGroup.postprocessor(CukedoctorStyleExtension.class);
	}

	cukedoctorExtensionGroup.register();

}
 
Example 3
Source File: CukedoctorMain.java    From cukedoctor with Apache License 2.0 4 votes vote down vote up
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;
}