Added output formats for Dokka
This commit is contained in:
parent
84f14212f4
commit
adc856b1e4
6 changed files with 74 additions and 18 deletions
|
@ -50,8 +50,8 @@ public class CompileKotlinOperationBuild extends Project {
|
|||
.include(dependency("org.jetbrains.dokka", "gfm-plugin", dokka))
|
||||
.include(dependency("com.uwyn.rife2", "bld", version(1, 7, 5)));
|
||||
scope(test)
|
||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 0)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 0)))
|
||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 1)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 1)))
|
||||
.include(dependency("org.assertj", "assertj-core", version(3, 24, 2)));
|
||||
|
||||
javadocOperation()
|
||||
|
@ -90,4 +90,4 @@ public class CompileKotlinOperationBuild extends Project {
|
|||
.ruleSets("config/pmd.xml")
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,12 @@ import java.util.logging.Logger;
|
|||
*/
|
||||
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
|
||||
public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
|
||||
private final static String GFM_PLUGIN_REGEXP =
|
||||
"^.*(dokka-base|analysis-kotlin-descriptors|gfm-plugin|freemarker).*\\.jar$";
|
||||
private final static String HTML_PLUGIN_REGEXP =
|
||||
"^.*(dokka-base|analysis-kotlin-descriptors|kotlinx-html-jvm|freemarker).*\\.jar$";
|
||||
private final static String JAVADOC_PLUGIN_REGEXP =
|
||||
"^.*(dokka-base|analysis-kotlin-descriptors|javadoc-plugin|kotlin-as-java-plugin|korte-jvm).*\\.jar$";
|
||||
private final Logger LOGGER = Logger.getLogger(DokkaOperation.class.getName());
|
||||
private final Map<String, String> globalLinks_ = new ConcurrentHashMap<>();
|
||||
private final Collection<String> globalPackageOptions_ = new ArrayList<>();
|
||||
|
@ -215,12 +221,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
|
|||
@Override
|
||||
public DokkaOperation fromProject(BaseProject project) {
|
||||
project_ = project;
|
||||
var plugins = getJarList(
|
||||
project.libBldDirectory(),
|
||||
"^.*(dokka-base|analysis-kotlin-descriptors|javadoc-plugin|kotlin-as-java-plugin|korte-jvm).*\\.jar$");
|
||||
pluginsClasspath_.addAll(plugins);
|
||||
sourceSet_ = new SourceSet().src(new File(project.srcMainDirectory(), "kotlin").getAbsolutePath());
|
||||
outputDir_ = new File(project.buildDirectory(), "javadoc");
|
||||
moduleName_ = project.name();
|
||||
return this;
|
||||
}
|
||||
|
@ -426,6 +427,35 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the output directory path, {@code ./dokka} by default
|
||||
*
|
||||
* @param outputDir the output directory
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation outputDir(String outputDir) {
|
||||
outputDir_ = new File(outputDir);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Dokka {@link OutputFormat output format}.
|
||||
*
|
||||
* @param format The {@link OutputFormat output format}
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation outputFormat(OutputFormat format) {
|
||||
pluginsClasspath_.clear();
|
||||
if (format.equals(OutputFormat.JAVADOC)) {
|
||||
pluginsClasspath_.addAll(getJarList(project_.libBldDirectory(), JAVADOC_PLUGIN_REGEXP));
|
||||
} else if (format.equals(OutputFormat.HTML)) {
|
||||
pluginsClasspath_.addAll(getJarList(project_.libBldDirectory(), HTML_PLUGIN_REGEXP));
|
||||
} else if (format.equals(OutputFormat.MARKDOWN)) {
|
||||
pluginsClasspath_.addAll(getJarList(project_.libBldDirectory(), GFM_PLUGIN_REGEXP));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the configuration for Dokka plugins.
|
||||
*
|
||||
|
|
27
src/main/java/rife/bld/extension/dokka/OutputFormat.java
Normal file
27
src/main/java/rife/bld/extension/dokka/OutputFormat.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright 2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension.dokka;
|
||||
|
||||
/**
|
||||
* Dokka output formats.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public enum OutputFormat {
|
||||
JAVADOC, HTML, MARKDOWN
|
||||
}
|
|
@ -53,6 +53,7 @@ class DokkaOperationTest {
|
|||
.noSuppressObviousFunctions(true)
|
||||
.offlineMode(true)
|
||||
.outputDir(new File(examples, "build"))
|
||||
.outputFormat(OutputFormat.JAVADOC)
|
||||
.suppressInheritedMembers(true)
|
||||
.executeConstructProcessCommandList();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue