-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
144704b
commit 828b855
Showing
11 changed files
with
267 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/main/java/org/asciidoctor/asciidoclet/AsciidoctorOptionsFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.asciidoctor.asciidoclet; | ||
|
||
import jdk.javadoc.doclet.Reporter; | ||
import org.asciidoctor.Asciidoctor; | ||
import org.asciidoctor.Attributes; | ||
import org.asciidoctor.AttributesBuilder; | ||
import org.asciidoctor.Options; | ||
import org.asciidoctor.OptionsBuilder; | ||
import org.asciidoctor.SafeMode; | ||
import org.asciidoctor.extension.RubyExtensionRegistry; | ||
|
||
class AsciidoctorOptionsFactory { | ||
|
||
private static final String DEFAULT_BACKEND = "html5"; | ||
|
||
private final Asciidoctor asciidoctor; | ||
private final Reporter reporter; | ||
|
||
AsciidoctorOptionsFactory(Asciidoctor asciidoctor, Reporter reporter) { | ||
this.asciidoctor = asciidoctor; | ||
this.reporter = reporter; | ||
} | ||
|
||
Options create(DocletOptions docletOptions, OutputTemplates templates) { | ||
final OptionsBuilder opts = defaultOptions(); | ||
if (docletOptions.baseDir().isPresent()) { | ||
opts.baseDir(docletOptions.baseDir().get()); | ||
} | ||
if (templates != null) { | ||
opts.templateDir(templates.templateDir().toFile()); | ||
} | ||
|
||
opts.attributes(buildAttributes(docletOptions)); | ||
if (docletOptions.requires().size() > 0) { | ||
RubyExtensionRegistry rubyExtensionRegistry = asciidoctor.rubyExtensionRegistry(); | ||
for (String require : docletOptions.requires()) { | ||
rubyExtensionRegistry.requireLibrary(require); | ||
} | ||
} | ||
return opts.get(); | ||
} | ||
|
||
private Attributes buildAttributes(DocletOptions docletOptions) { | ||
return defaultAttributes() | ||
.attributes(new AttributesLoader(asciidoctor, docletOptions, reporter).load()) | ||
.get(); | ||
} | ||
|
||
private static OptionsBuilder defaultOptions() { | ||
return Options.builder() | ||
.safe(SafeMode.SAFE) | ||
.backend(DEFAULT_BACKEND); | ||
} | ||
|
||
private static AttributesBuilder defaultAttributes() { | ||
return org.asciidoctor.Attributes.builder() | ||
.attribute("at", "@") | ||
.attribute("slash", "/") | ||
.attribute("icons", null) | ||
.attribute("idprefix", "") | ||
.attribute("idseparator", "-") | ||
.attribute("javadoc", "") | ||
.attribute("showtitle", true) | ||
.attribute("source-highlighter", "coderay") | ||
.attribute("coderay-css", "class") | ||
.attribute("env-asciidoclet") | ||
.attribute("env", "asciidoclet"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.