Skip to content

Commit

Permalink
add --enable-preview and sourceRelease/testRelease options
Browse files Browse the repository at this point in the history
  • Loading branch information
forax committed Oct 9, 2018
1 parent f0bc702 commit e2c8212
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public interface DocerConf {
boolean generateTestDoc();
void generateTestDoc(boolean generate);

Optional<Integer> sourceRelease();
void sourceRelease(int sourceRelease);
Optional<Integer> testRelease();
void testRelease(int sourceRelease);

boolean quiet();
void quiet(boolean quiet);

Expand All @@ -22,6 +27,9 @@ public interface DocerConf {
Optional<URI> link();
void link(URI link);

Optional<Boolean> enablePreview();
void enablePreview(boolean enablePreview);

Optional<List<String>> rawArguments();
void rawArguments(List<String> rawArguments);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ enum JavadocOption {
MODULE_PATH(actionMaybe("--module-path", Javadoc::modulePath, File.pathSeparator)),
QUIET(exists("-quiet", Javadoc::quiet)),
HTML5(exists("-html5", Javadoc::html5)),
LINK(actionMaybe("-link", Javadoc::link))
LINK(actionMaybe("-link", Javadoc::link)),
ENABLE_PREVIEW(exists("--enable-preview", Javadoc::enablePreview)),
RELEASE(actionMaybe("--release", Javadoc::release))
;

final OptionAction<Javadoc> action;
Expand All @@ -111,7 +113,7 @@ public int execute(Config config) throws IOException {
var moduleSourcePath = FileHelper.pathFromFilesThatExist(docerConf.moduleSourcePath());
var moduleSourceFinder = ModuleHelper.sourceModuleFinders(moduleSourcePath);
var errorCode = generateAll(moduleSourceFinder, docerConf.moduleDocSourcePath(),
(input, output) -> generateDoc(log, javadocTool, docerConf, input, output));
(input, output) -> generateDoc(log, javadocTool, docerConf, true, input, output));
if (errorCode != 0) {
return errorCode;
}
Expand All @@ -122,7 +124,7 @@ public int execute(Config config) throws IOException {

var moduleTestFinder = ModuleHelper.sourceModuleFinders(moduleTestPath);
return generateAll(moduleTestFinder, docerConf.moduleDocTestPath(),
(input, output) -> generateDoc(log, javadocTool, docerConf, input, output));
(input, output) -> generateDoc(log, javadocTool, docerConf, false, input, output));
}

interface Action {
Expand All @@ -139,14 +141,16 @@ private static int generateAll(ModuleFinder finder, Path output, Action action)
.reduce(0, (exitCode1, exitCode2) -> exitCode1 | exitCode2);
}

private static int generateDoc(Log log, ToolProvider javadocTool, DocerConf docerConf, Path input, Path output) {
private static int generateDoc(Log log, ToolProvider javadocTool, DocerConf docerConf, boolean main, Path input, Path output) {
var javadoc = new Javadoc(output.resolve(input.getFileName().toString()), docerConf.moduleSourcePath());
docerConf.rawArguments().ifPresent(javadoc::rawArguments);
javadoc.modulePath(docerConf.moduleDependencyPath());
docerConf.upgradeModulePath().ifPresent(javadoc::upgradeModulePath);
docerConf.rootModules().ifPresent(javadoc::rootModules);
javadoc.quiet(docerConf.quiet());
javadoc.html5(docerConf.html5());
(main? docerConf.sourceRelease(): docerConf.testRelease().or(docerConf::sourceRelease)).ifPresent(javadoc::release);
docerConf.enablePreview().ifPresent(javadoc::enablePreview);
docerConf.link().filter(url -> isLinkHostOnline(log, url)).ifPresent(javadoc::link);

var cmdLine = gatherAll(JavadocOption.class, option -> option.action).apply(javadoc, new CmdLine());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,29 @@
class Javadoc {
private final Path destination;
private final List<Path> moduleSourcePath;


private Integer release;
private boolean quiet;
private boolean html5;
private URI link;
private boolean enablePreview;
private List<Path> modulePath;
private List<Path> upgradeModulePath;
private List<String> rootModules;
private List<String> rawArguments;
private boolean quiet;
private boolean html5;
private URI link;

Javadoc(Path destination, List<Path> moduleSourcePath) {
this.destination = destination;
this.moduleSourcePath = moduleSourcePath;
}

public Optional<Integer> release() {
return Optional.ofNullable(release);
}
public void release(int release) {
this.release = release;
}

public Path destination() {
return destination;
}
Expand Down Expand Up @@ -76,4 +85,10 @@ public Optional<URI> link() {
public void link(URI link) {
this.link = Objects.requireNonNull(link);
}
public boolean enablePreview() {
return enablePreview;
}
public void enablePreview(boolean enablePreview) {
this.enablePreview = enablePreview;
}
}

0 comments on commit e2c8212

Please sign in to comment.