当前位置: 首页>>代码示例>>Java>>正文


Java Asciidoctor类代码示例

本文整理汇总了Java中org.asciidoctor.Asciidoctor的典型用法代码示例。如果您正苦于以下问题:Java Asciidoctor类的具体用法?Java Asciidoctor怎么用?Java Asciidoctor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Asciidoctor类属于org.asciidoctor包,在下文中一共展示了Asciidoctor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
private Runnable run(final List<Feature> features, final DocumentAttributes attrs, final String outputPath) {
    return new Runnable() {

        @Override
        public void run() {
            Asciidoctor asciidoctor = null;
            try {
                asciidoctor = Asciidoctor.Factory.create(CukedoctorPublisher.class.getClassLoader());
                generateDocumentation(features, attrs, outputPath, asciidoctor);
            } catch (Exception e) {
                logger.println(String.format("Unexpected error on documentation generation, message %s, cause %s", e.getMessage(), e.getCause()));
                e.printStackTrace();
            } finally {
                if (asciidoctor != null) {
                    asciidoctor.shutdown();
                }
            }
        }
    };

}
 
开发者ID:jenkinsci,项目名称:cucumber-living-documentation-plugin,代码行数:22,代码来源:CukedoctorPublisher.java

示例2: generateDocumentation

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
private void generateDocumentation(DocumentAttributes documentAttributes, File adocFile, Asciidoctor asciidoctor) {
    
    OptionsBuilder ob;
    ob = OptionsBuilder.options().backend(documentAttributes.getBackend());
    ob.safe(SafeMode.UNSAFE);

    if (allowUriRead) {
        Attributes attr = new Attributes();
        attr.setAllowUriRead(true);
        ob.attributes(attr);
    }

    
    if ("pdf".equals(documentAttributes.getBackend())) {
        asciidoctor.unregisterAllExtensions();
    }
    asciidoctor.convertFile(adocFile, ob);
    //remove auxiliary files
    if ("pdf".equals(documentAttributes.getBackend())) {
        FileUtil.removeFile(adocFile.getParent() + "/" + outputFileName + "-theme.yml");

    }

    getLog().info("Generated documentation at: " + adocFile.getParent());
}
 
开发者ID:rmpestano,项目名称:cukedoctor,代码行数:26,代码来源:CukedoctorMojo.java

示例3: register

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
@Override
public void register(Asciidoctor asciidoctor) {
	//null means extension is enabled (by default)
	asciidoctor.javaExtensionRegistry().postprocessor(CukedoctorScriptExtension.class);
	if(System.getProperty(FILTER_DISABLE_EXT_KEY) == null){
		asciidoctor.javaExtensionRegistry().postprocessor(CukedoctorFilterExtension.class);
	}
	if(System.getProperty(MINMAX_DISABLE_EXT_KEY) == null){
		asciidoctor.javaExtensionRegistry().blockMacro("minmax", CukedoctorMinMaxExtension.class);
	}

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

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

}
 
开发者ID:rmpestano,项目名称:cukedoctor,代码行数:24,代码来源:CukedoctorExtensionRegistry.java

示例4: renderFiles

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
private void renderFiles(List<String> inputFiles, ZipOutputStream zip) throws IOException {
  Asciidoctor asciidoctor = JRubyAsciidoctor.create();
  for (String inputFile : inputFiles) {
    String outName = mapInFileToOutFile(inputFile, inExt, outExt);
    File out = bazel ? new File(outName) : new File(tmpdir, outName);
    if (!bazel) {
      out.getParentFile().mkdirs();
    }
    File input = new File(inputFile);
    Options options = createOptions(basedir != null ? basedir : input.getParentFile(), out);
    asciidoctor.renderFile(input, options);
    if (zip != null) {
      zipFile(out, outName, zip);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:AsciiDoctor.java

示例5: test

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
@Test
public void test() throws IOException {
	folder.create();
	Asciidoctor asciidoctor = Asciidoctor.Factory.create();
	asciidoctor.javaExtensionRegistry().block(
			SdEditBlockProcessor.SDEDIT_BLOCK_NAME,
			SdEditBlockProcessor.class);
	asciidoctor.javaExtensionRegistry().blockMacro(
			SdEditBlockMacroProcessor.SDEDIT_BLOCK_MACRO_NAME,
			SdEditBlockMacroProcessor.class);
	File baseDir = new File("src/test/resources");
	File adoc = new File(baseDir, "sdinclude.adoc");
	File destDir = folder.newFolder();
	AttributesBuilder attributes = AttributesBuilder.attributes()
			.attribute("outdir", destDir.getAbsolutePath());
	OptionsBuilder options = OptionsBuilder.options().safe(SafeMode.UNSAFE)
			.mkDirs(true).toDir(destDir).destinationDir(destDir)
			.baseDir(baseDir).attributes(attributes);
	asciidoctor.convertFile(adoc, options.asMap());

	assertTrue(new File(destDir, "sdinclude.html").exists());
	assertTrue(new File(destDir, "testdiagram.png").exists());
	assertTrue(new File(destDir, "fromblock.svg").exists());
}
 
开发者ID:domgold,项目名称:asciidoctor-sdedit-extension,代码行数:25,代码来源:TestSdEditIncludeProcessor.java

示例6: getEngine

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
private Asciidoctor getEngine(Options options) {
    try {
        lock.readLock().lock();
        if (engine==null) {
            lock.readLock().unlock();
            try {
                lock.writeLock().lock();
                if (engine==null) {
                    LOGGER.info("Initializing Asciidoctor engine...");
                    if (options.map().containsKey(OPT_GEM_PATH)) {
                        engine = Asciidoctor.Factory.create(String.valueOf(options.map().get(OPT_GEM_PATH)));
                    } else {
                        engine = Asciidoctor.Factory.create();
                    }

                    if (options.map().containsKey(OPT_REQUIRES)) {
                        String[] requires = String.valueOf(options.map().get(OPT_REQUIRES)).split(",");
                        if (requires.length != 0) {
                            for (String require : requires) {
                                engine.requireLibrary(require);
                            }
                        }
                    }

                    LOGGER.info("Asciidoctor engine initialized.");
                }
            } finally {
                lock.readLock().lock();
                lock.writeLock().unlock();
            }
        }
    } finally {
        lock.readLock().unlock();
    }
    return engine;
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:37,代码来源:AsciidoctorEngine.java

示例7: processHeader

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
@Override
public void processHeader(final ParserContext context) {
    Options options = getAsciiDocOptionsAndAttributes(context);
    final Asciidoctor asciidoctor = getEngine(options);
    DocumentHeader header = asciidoctor.readDocumentHeader(context.getFile());
    Map<String, Object> contents = context.getContents();
    if (header.getDocumentTitle() != null) {
    	contents.put("title", header.getDocumentTitle().getCombined());
    }
    Map<String, Object> attributes = header.getAttributes();
    for (String key : attributes.keySet()) {
        if (key.startsWith("jbake-")) {
            Object val = attributes.get(key);
            if (val!=null) {
                String pKey = key.substring(6);
                contents.put(pKey, val);
            }
        }
        if (key.equals("revdate")) {
            if (attributes.get(key) != null && attributes.get(key) instanceof String) {

                DateFormat df = new SimpleDateFormat(context.getConfig().getString(Keys.DATE_FORMAT));
                Date date = null;
                try {
                    date = df.parse((String)attributes.get(key));
                    contents.put("date", date);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
        }
        if (key.equals("jbake-tags")) {
            if (attributes.get(key) != null && attributes.get(key) instanceof String) {
                contents.put("tags", ((String) attributes.get(key)).split(","));
            }
        } else {
            contents.put(key, attributes.get(key));
        }
    }
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:41,代码来源:AsciidoctorEngine.java

示例8: runAll

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
/**
 * 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 String outputPath) {
    return new Runnable() {

        @Override
        public void run() {

            Asciidoctor asciidoctor = null;
            try {
                /*
                 * this throws: ERROR: org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- jruby/java
                 * asciidoctor = Asciidoctor.Factory.create();
                 */
                asciidoctor = Asciidoctor.Factory.create(CukedoctorPublisher.class.getClassLoader());
                attrs.backend("html5");
                generateDocumentation(features, attrs, outputPath, asciidoctor);
                attrs.backend("pdf");
                generateDocumentation(features, attrs, outputPath, asciidoctor);

            } catch (Exception e) {
                logger.println(String.format("Unexpected error on documentation generation, message %s, cause %s", e.getMessage(), e.getCause()));
                e.printStackTrace();
            } finally {
                if (asciidoctor != null) {
                    asciidoctor.shutdown();
                }
            }
        }
    };

}
 
开发者ID:jenkinsci,项目名称:cucumber-living-documentation-plugin,代码行数:37,代码来源:CukedoctorPublisher.java

示例9: generateDocumentation

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
protected synchronized void generateDocumentation(List<Feature> features, DocumentAttributes attrs, String outputPath, Asciidoctor asciidoctor) {
    asciidoctor.unregisterAllExtensions();
    if (!attrs.getBackend().equalsIgnoreCase("pdf")) {
        new CukedoctorExtensionRegistry().register(asciidoctor);
    }
    CukedoctorConverter converter = Cukedoctor.instance(features, attrs);
    String doc = converter.renderDocumentation();
    File adocFile = FileUtil.saveFile(outputPath + "/documentation.adoc", doc);
    asciidoctor.convertFile(adocFile, OptionsBuilder.options().backend(attrs.getBackend()).safe(SafeMode.UNSAFE).asMap());
}
 
开发者ID:jenkinsci,项目名称:cucumber-living-documentation-plugin,代码行数:11,代码来源:CukedoctorPublisher.java

示例10: render

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
@Override
public String render(final Template template, final Model model) {
    Asciidoctor asciidoctor = Asciidoctor.Factory.create();
    final String asciidoc = template.getContent().getText();
    final String html = asciidoctor.convert(asciidoc, new HashMap<>());
    return freemarkerRenderer.renderLayout(template, html, model);
}
 
开发者ID:marcobehler,项目名称:saito,代码行数:8,代码来源:AsciidocRenderer.java

示例11: getAsciidoctor

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
/**
 * Return an Asciidoctor instance.
 *
 * Initialization is quite expensive, therefore doing it lazy.
 *
 * @return The Asciidoctor instance.
 */
private Asciidoctor getAsciidoctor() {
    if (cachedAsciidoctor == null) {
        LOGGER.debug("Loading Asciidoctor...");
        cachedAsciidoctor = Asciidoctor.Factory.create();
    }
    return cachedAsciidoctor;
}
 
开发者ID:buschmais,项目名称:jqa-core-framework,代码行数:15,代码来源:AsciiDocRuleSetReader.java

示例12: get

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:11,代码来源:MyResource.java

示例13: initAsciidoctor

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
private void initAsciidoctor(ArquillianDescriptor arquillianDescriptor) {

        for (final ExtensionDef extensionDef : arquillianDescriptor.getExtensions()) {
            if (extensionDef.getExtensionName().startsWith("asciidoctor")) {
               String gemPath = get(extensionDef.getExtensionProperties(), "gemPath", "");
               Asciidoctor asciidoctor = asciidoctorMap.get(gemPath);
               if(asciidoctor == null){
                   asciidoctor = Asciidoctor.Factory.create((File.separatorChar == '\\') ? gemPath.replaceAll("\\\\", "/") : gemPath);
                   asciidoctorMap.put(gemPath,asciidoctor);
               }
            }
        }
    }
 
开发者ID:cukespace,项目名称:arquillian-asciidoctor-extension,代码行数:14,代码来源:AsciidoctorObserver.java

示例14: register

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
@Override
public void register(final Asciidoctor asciidoctor) {
    final JavaExtensionRegistry registry = asciidoctor.javaExtensionRegistry();
    for (final String name : extensionNames) {
        register(registry, configuration.get("extension." + name + ".class"), configuration.get("extension." + name + ".block"));
    }
}
 
开发者ID:cukespace,项目名称:arquillian-asciidoctor-extension,代码行数:8,代码来源:AsciidoctorObserver.java

示例15: register

import org.asciidoctor.Asciidoctor; //导入依赖的package包/类
@Override
public void register(Asciidoctor asciidoctor) {
	RubyExtensionRegistry rubyExtensionRegistry = asciidoctor
			.rubyExtensionRegistry();
	rubyExtensionRegistry
			.loadClass(
					this.getClass()
							.getResourceAsStream(
									"gherkinblockmacro.rb"))
			.blockMacro("gherkin", "GherkinBlockMacroProcessor");
}
 
开发者ID:domgold,项目名称:asciidoctor-gherkin-extension,代码行数:12,代码来源:GherkinExtensionRegistry.java


注:本文中的org.asciidoctor.Asciidoctor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。