Skip to content

Commit

Permalink
Cleaned up API to match bld operations and options APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
ethauvin committed Aug 28, 2024
1 parent fdee178 commit 61d41e2
Show file tree
Hide file tree
Showing 8 changed files with 634 additions and 44 deletions.
6 changes: 6 additions & 0 deletions .idea/bld.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions .idea/runConfigurations/Run Tests.xml

This file was deleted.

4 changes: 2 additions & 2 deletions examples/lib/bld/bld-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true
bld.downloadLocation=
bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.0
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.0
bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.1-SNAPSHOT
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.1-SNAPSHOT
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.sourceDirectories=
bld.version=2.0.1
2 changes: 1 addition & 1 deletion src/bld/java/rife/bld/extension/DokkaOperationBuild.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class DokkaOperationBuild extends Project {
public DokkaOperationBuild() {
pkg = "rife.bld.extension";
name = "bld-dokka";
version = version(1, 0, 0);
version = version(1, 0, 1, "SNAPSHOT");

javaRelease = 17;

Expand Down
152 changes: 138 additions & 14 deletions src/main/java/rife/bld/extension/DokkaOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@

import java.io.File;
import java.io.IOException;
import java.util.*;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -446,8 +450,7 @@ public DokkaOperation globalSrcLink(Collection<String> links) {
* @return this operation instance
*/
public DokkaOperation includes(File... files) {
includes_.addAll(List.of(files));
return this;
return includes(List.of(files));
}

/**
Expand All @@ -461,10 +464,24 @@ public DokkaOperation includes(File... files) {
* @return this operation instance
*/
public DokkaOperation includes(String... files) {
includes_.addAll(Arrays.stream(files).map(File::new).toList());
return this;
return includesStrings(List.of(files));
}

/**
* Sets the Markdown files that contain module and package documentation.
* <p>
* The contents of specified files are parsed and embedded into documentation as module and package descriptions.
* <p>
* This can be configured on per-package basis.
*
* @param files one or more files
* @return this operation instance
*/
public DokkaOperation includes(Path... files) {
return includesPaths(List.of(files));
}


/**
* Retrieves the markdown files that contain the module and package documentation.
*
Expand All @@ -489,6 +506,36 @@ public DokkaOperation includes(Collection<File> files) {
return this;
}

/**
* Sets the Markdown files that contain module and package documentation.
* <p>
* The contents of specified files are parsed and embedded into documentation as module and package descriptions.
* <p>
* This can be configured on per-package basis.
*
* @param files the markdown files
* @return this operation instance
*/
public DokkaOperation includesPaths(Collection<Path> files) {
includes_.addAll(files.stream().map(Path::toFile).toList());
return this;
}

/**
* Sets the Markdown files that contain module and package documentation.
* <p>
* The contents of specified files are parsed and embedded into documentation as module and package descriptions.
* <p>
* This can be configured on per-package basis.
*
* @param files the markdown files
* @return this operation instance
*/
public DokkaOperation includesStrings(Collection<String> files) {
includes_.addAll(files.stream().map(File::new).toList());
return this;
}

/**
* JSON configuration file path.
*
Expand All @@ -499,6 +546,33 @@ public DokkaOperation json(File configuration) {
return this;
}

/**
* JSON configuration file path.
*
* @param configuration the configuration file path
*/
public DokkaOperation json(Path configuration) {
return json(configuration.toFile());
}

/**
* Retrieves the JSON configuration file path.
*
* @return the configuration file path
*/
public File json() {
return json_;
}

/**
* JSON configuration file path.
*
* @param configuration the configuration file path
*/
public DokkaOperation json(String configuration) {
return json(new File(configuration));
}

/**
* Sets the logging level.
*
Expand Down Expand Up @@ -589,6 +663,15 @@ public DokkaOperation outputDir(File outputDir) {
return this;
}

/**
* Retrieves the output directory path.
*
* @return the output directory
*/
public File outputDir() {
return outputDir_;
}

/**
* Sets the output directory path, {@code ./dokka} by default.
* <p>
Expand All @@ -598,8 +681,19 @@ public DokkaOperation outputDir(File outputDir) {
* @return this operation instance
*/
public DokkaOperation outputDir(String outputDir) {
outputDir_ = new File(outputDir);
return this;
return outputDir(new File(outputDir));
}

/**
* Sets the output directory path, {@code ./dokka} by default.
* <p>
* The directory to where documentation is generated, regardless of output format.
*
* @param outputDir the output directory
* @return this operation instance
*/
public DokkaOperation outputDir(Path outputDir) {
return outputDir(outputDir.toFile());
}

/**
Expand Down Expand Up @@ -641,12 +735,12 @@ public DokkaOperation pluginConfigurations(String name, String jsonConfiguration
/**
* Sets the configuration for Dokka plugins.
*
* @param pluginConfiguratione the map of configurations
* @param pluginConfigurations the map of configurations
* @return this operation instance
* @see #pluginConfigurations(String, String)
*/
public DokkaOperation pluginConfigurations(Map<String, String> pluginConfiguratione) {
pluginsConfiguration_.putAll(pluginConfiguratione);
public DokkaOperation pluginConfigurations(Map<String, String> pluginConfigurations) {
pluginsConfiguration_.putAll(pluginConfigurations);
return this;
}

Expand All @@ -666,8 +760,7 @@ public Map<String, String> pluginConfigurations() {
* @return this operation instance
*/
public DokkaOperation pluginsClasspath(File... jars) {
pluginsClasspath_.addAll(List.of(jars));
return this;
return pluginsClasspath(List.of(jars));
}

/**
Expand All @@ -677,8 +770,17 @@ public DokkaOperation pluginsClasspath(File... jars) {
* @return this operation instance
*/
public DokkaOperation pluginsClasspath(String... jars) {
pluginsClasspath_.addAll(Arrays.stream(jars).map(File::new).toList());
return this;
return pluginsClasspathStrings(List.of(jars));
}

/**
* Sets the jars for Dokka plugins and their dependencies.
*
* @param jars one or more jars
* @return this operation instance
*/
public DokkaOperation pluginsClasspath(Path... jars) {
return pluginsClasspathPaths(List.of(jars));
}

/**
Expand All @@ -701,6 +803,28 @@ public DokkaOperation pluginsClasspath(Collection<File> jars) {
return this;
}

/**
* Sets the jars for Dokka plugins and their dependencies.
*
* @param jars the jars
* @return this operation instance
*/
public DokkaOperation pluginsClasspathPaths(Collection<Path> jars) {
pluginsClasspath_.addAll(jars.stream().map(Path::toFile).toList());
return this;
}

/**
* Sets the jars for Dokka plugins and their dependencies.
*
* @param jars the jars
* @return this operation instance
*/
public DokkaOperation pluginsClasspathStrings(Collection<String> jars) {
pluginsClasspath_.addAll(jars.stream().map(File::new).toList());
return this;
}

/**
* Sets the configurations for a source set.
* <p>
Expand Down
Loading

0 comments on commit 61d41e2

Please sign in to comment.