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


Java OptionsBuilder类代码示例

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


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

示例1: options

import org.asciidoctor.OptionsBuilder; //导入依赖的package包/类
protected Options options() {
    this.asciidocTemplates.mkdirs();

    String imagesOutputDirectory = generatedDocsDirectory.getAbsolutePath();

    Map<String, Object> attributes = new HashMap<>();
    attributes.put("imagesoutdir", imagesOutputDirectory);
    attributes.put("outdir", imagesOutputDirectory);

    return OptionsBuilder.options()
            .backend("html5")
            .safe(UNSAFE)
            .baseDir(generatedDocsDirectory)
            .templateDirs(asciidocTemplates)
            .attributes(attributes)
            .get();
}
 
开发者ID:jboz,项目名称:living-documentation,代码行数:18,代码来源:AbstractAsciidoctorMojo.java

示例2: options

import org.asciidoctor.OptionsBuilder; //导入依赖的package包/类
private static Options options(Path templatesFolder, Path baseFolder, Path generatedAssetsTargetFolder) {
    if (!exists(templatesFolder)) {
        throw new RuntimeException("templateDir folder does not exist");
    }

    if (!isDirectory(templatesFolder)) {
        throw new RuntimeException("templateDir folder is not a folder");
    }

    Map<String, Object> attributes = new HashMap<>();
    attributes.put("imagesoutdir", generatedAssetsTargetFolder.toString());
    attributes.put("outdir", generatedAssetsTargetFolder.toString());

    return OptionsBuilder.options()
            .backend("xhtml5")
            .safe(UNSAFE)
            .baseDir(baseFolder.toFile())
            .templateDirs(templatesFolder.toFile())
            .attributes(attributes)
            .get();
}
 
开发者ID:alainsahli,项目名称:confluence-publisher,代码行数:22,代码来源:AsciidocConfluencePage.java

示例3: setDestinationPaths

import org.asciidoctor.OptionsBuilder; //导入依赖的package包/类
private void setDestinationPaths(final OptionsBuilder optionsBuilder, final File sourceFile,
                                 final boolean preserveDirectories, final File outputDir,
                                 final boolean relativeBaseDir, final String baseDir, final File sourceDir) {
    try {
        if (baseDir != null) {
            optionsBuilder.baseDir(new File(baseDir));
        } else {
            if (relativeBaseDir) {
                optionsBuilder.baseDir(sourceFile.getParentFile());
            } else {
                optionsBuilder.baseDir(sourceDir);
            }
        }
        if (preserveDirectories) {
            String propostalPath = sourceFile.getParentFile().getCanonicalPath().substring(sourceDir.getCanonicalPath().length());
            File relativePath = new File(outputDir.getCanonicalPath() + propostalPath);
            optionsBuilder.toDir(relativePath).destinationDir(relativePath);
        } else {
            optionsBuilder.toDir(outputDir).destinationDir(outputDir);
        }
    } catch (final IOException e) {
        throw new IllegalStateException("Unable to locate output directory", e);
    }
}
 
开发者ID:cukespace,项目名称:arquillian-asciidoctor-extension,代码行数:25,代码来源:AsciidoctorObserver.java

示例4: compile

import org.asciidoctor.OptionsBuilder; //导入依赖的package包/类
public Entry compile(final String name, final String fileContent) {
    try {
        final DocumentHeader documentHeader = asciidoctor.readDocumentHeader(fileContent);
        final String headline = documentHeader.getDocumentTitle().getMain();
        String docDateTime = documentHeader.getAttributes().get(DOC_DATE_TIME_ATTR).toString();
        final LocalDateTime date = formatter.parse(docDateTime, LocalDateTime::from);

        final StructuredDocument structuredDocument = asciidoctor.readDocumentStructure(fileContent, new HashMap<>());
        final String abstractContent = structuredDocument.getPartById(ABSTRACT_CONTENT_ID).getContent();

        OptionsBuilder options = OptionsBuilder.options()
                .attributes(attributes()
                        .sourceHighlighter("coderay")
                        .get())
                .toFile(false);
        final String content = asciidoctor.convert(fileContent, options);

        return new Entry(name, headline, date, abstractContent, content);
    } catch (Exception e) {
        logger.log(Level.WARNING, "Could not compile entry " + name, e);
        return null;
    }
}
 
开发者ID:sdaschner,项目名称:asciiblog,代码行数:24,代码来源:EntryCompiler.java

示例5: parameters

import org.asciidoctor.OptionsBuilder; //导入依赖的package包/类
/**
    * Create the Map in order to configure the converter.
    * @param optsBuilder
 * @param converter
 * @param outputFilename
    * @return
    */
private Map<String, Object> parameters(OptionsBuilder optsBuilder, Converter converter,
									   String outputFilename){
       OptionsBuilder opts = optsBuilder
			.backend(converter.toString())
			.safe(SafeMode.UNSAFE).headerFooter(true);
               //.inPlace(true);
       if (outputFilename != null) {
		opts.toFile(new File(outputDir + outputFilename + converter.getFilenameExtension()));
	}
	//For now the PDF converter can only write to a file
	else if (outputFilename == null && converter == Converter.pdf) {
		opts.toFile(new File(outputDir + "temp.pdf"));
	} else {
		opts.toFile(false);
       }

       return  opts.asMap();
   }
 
开发者ID:adoc-editor,项目名称:editor-backend,代码行数:26,代码来源:AsciidoctorProcessor.java

示例6: generateDocumentation

import org.asciidoctor.OptionsBuilder; //导入依赖的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

示例7: createOptions

import org.asciidoctor.OptionsBuilder; //导入依赖的package包/类
private Options createOptions(File base, File outputFile) {
  OptionsBuilder optionsBuilder = OptionsBuilder.options();

  optionsBuilder
      .backend(backend)
      .docType(DOCTYPE)
      .eruby(ERUBY)
      .safe(SafeMode.UNSAFE)
      .baseDir(base)
      .toFile(outputFile);

  AttributesBuilder attributesBuilder = AttributesBuilder.attributes();
  attributesBuilder.attributes(getAttributes());
  if (revnumber != null) {
    attributesBuilder.attribute(REVNUMBER_NAME, revnumber);
  }
  optionsBuilder.attributes(attributesBuilder.get());

  return optionsBuilder.get();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:AsciiDoctor.java

示例8: testProcessIndex

import org.asciidoctor.OptionsBuilder; //导入依赖的package包/类
@Test
public void testProcessIndex() throws URISyntaxException, IOException {
    final File file = TestUtils.getResourceFile("/asciidoc/index/index.adoc");
    final File baseDir = TestUtils.getResourceFile("/asciidoc/index/");
    final File templateDir = TestUtils.getResourceFile("/templates/");

    asciidoctor.convertFile(file, OptionsBuilder.options().baseDir(baseDir).templateDir(templateDir));

    final Path expectedFile = TestUtils.getResourceFile("/asciidoc/index/expectedIndex.html").toPath();
    final Path actualFile = TestUtils.getResourceFile("/asciidoc/index/index.html").toPath();

    final String expectedOutput = Files.lines(expectedFile).collect(Collectors.joining());
    final String actualOutput = Files.lines(actualFile).collect(Collectors.joining());

    assertEquals(expectedOutput, actualOutput);
}
 
开发者ID:sdaschner,项目名称:asciidoctor-blog-extension,代码行数:17,代码来源:BlogEntriesProcessorTest.java

示例9: testProcessEntries

import org.asciidoctor.OptionsBuilder; //导入依赖的package包/类
@Test
public void testProcessEntries() throws URISyntaxException, IOException {
    final File file = TestUtils.getResourceFile("/asciidoc/index/entries.adoc");
    final File baseDir = TestUtils.getResourceFile("/asciidoc/index/");
    final File templateDir = TestUtils.getResourceFile("/templates/");

    asciidoctor.convertFile(file, OptionsBuilder.options().baseDir(baseDir).templateDir(templateDir));

    final Path expectedFile = TestUtils.getResourceFile("/asciidoc/index/expectedEntries.html").toPath();
    final Path actualFile = TestUtils.getResourceFile("/asciidoc/index/entries.html").toPath();

    final String expectedOutput = Files.lines(expectedFile).collect(Collectors.joining());
    final String actualOutput = Files.lines(actualFile).collect(Collectors.joining());

    assertEquals(expectedOutput, actualOutput);
}
 
开发者ID:sdaschner,项目名称:asciidoctor-blog-extension,代码行数:17,代码来源:BlogEntriesProcessorTest.java

示例10: test

import org.asciidoctor.OptionsBuilder; //导入依赖的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

示例11: generateDocumentation

import org.asciidoctor.OptionsBuilder; //导入依赖的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

示例12: shouldAddCustomCssToRenderedHtml

import org.asciidoctor.OptionsBuilder; //导入依赖的package包/类
@Test
public void shouldAddCustomCssToRenderedHtml(){
    File sampleAdoc = loadTestFile("sample.adoc");
    assertThat(sampleAdoc).exists();
    String customCssPath = Paths.get("").toAbsolutePath() + "/target/cukedoctor.css";
    FileUtil.copyFileFromClassPath("/cukedoctor-test.css", customCssPath);
    asciidoctor.convertFile(sampleAdoc, OptionsBuilder.options().safe(SafeMode.UNSAFE).asMap());

    String sampleHtml = readFileContent(loadTestFile("sample.html"));
    assertThat(sampleHtml).isNotEmpty().
            containsOnlyOnce("<style> body #toctitle {    color: green;}body.book {    background: #444;}</style>");

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

示例13: shouldDisableStyleExtension

import org.asciidoctor.OptionsBuilder; //导入依赖的package包/类
@Test
public void shouldDisableStyleExtension(){
    System.setProperty(STYLE_DISABLE_EXT_KEY,"anyValue");
    File sampleAdoc = loadTestFile("sample.adoc");
    assertThat(sampleAdoc).exists();
    asciidoctor.convertFile(sampleAdoc, OptionsBuilder.options().safe(SafeMode.UNSAFE).asMap());

    String sampleHtml = readFileContent(loadTestFile("sample.html"));
    assertThat(sampleHtml).isNotEmpty().
            doesNotContain(".sidebarblock, .sectionbody, .content{overflow:auto!important;}");
}
 
开发者ID:rmpestano,项目名称:cukedoctor,代码行数:12,代码来源:StyleExtensionTest.java

示例14: shouldAddFooterToRenderedHtml

import org.asciidoctor.OptionsBuilder; //导入依赖的package包/类
@Test
public void shouldAddFooterToRenderedHtml(){
    File sampleAdoc = loadTestFile("sample.adoc");
    assertThat(sampleAdoc).exists();
    System.setProperty("cukedoctor.stopwatch",String.valueOf(System.currentTimeMillis()));
    asciidoctor.convertFile(sampleAdoc, OptionsBuilder.options().safe(SafeMode.UNSAFE).asMap());

    String sampleHtml = readFileContent(loadTestFile("sample.html"));
    assertThat(sampleHtml.replaceAll("\n","").replace("\t","")).isNotEmpty().
            containsOnlyOnce("Generated by    <a href=\"https://github.com/rmpestano/cukedoctor\" target=\"_blank\"> Cukedoctor").
        containsOnlyOnce("Execution time: ");

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

示例15: shouldNotAddFooterToRenderedHtmlWhenExtensionDisabled

import org.asciidoctor.OptionsBuilder; //导入依赖的package包/类
@Test
public void shouldNotAddFooterToRenderedHtmlWhenExtensionDisabled(){
    System.setProperty(FOOTER_DISABLE_EXT_KEY,"anyValue");
    File sampleAdoc = loadTestFile("sample.adoc");
    assertThat(sampleAdoc).exists();
    System.setProperty("cukedoctor.stopwatch",String.valueOf(System.currentTimeMillis()));
    asciidoctor.convertFile(sampleAdoc, OptionsBuilder.options().safe(SafeMode.UNSAFE).asMap());

    String sampleHtml = readFileContent(loadTestFile("sample.html"));
    assertThat(sampleHtml.replaceAll("\n","").replace("\t","")).isNotEmpty().
        doesNotContain("Generated by    <a href=\"https://github.com/rmpestano/cukedoctor\" target=\"_blank\"> Cukedoctor").
        doesNotContain("Execution time: ");
}
 
开发者ID:rmpestano,项目名称:cukedoctor,代码行数:14,代码来源:FooterExtensionTest.java


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