本文整理汇总了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();
}
示例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();
}
示例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);
}
}
示例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;
}
}
示例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();
}
示例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());
}
示例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();
}
示例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);
}
示例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);
}
示例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());
}
示例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());
}
示例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>");
}
示例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;}");
}
示例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: ");
}
示例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: ");
}