From 02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Thu, 31 Aug 2023 20:16:01 +0200 Subject: Enable explicit API mode (#3139) --- runners/maven-plugin/src/main/kotlin/DokkaMojo.kt | 80 +++++++++++----------- .../kotlin/ExternalDocumentationLinkBuilder.kt | 9 +-- .../src/main/kotlin/MavenDokkaLogger.kt | 28 ++++++-- .../maven-plugin/src/main/kotlin/PackageOptions.kt | 2 +- .../src/main/kotlin/SourceLinkMapItem.kt | 8 +-- 5 files changed, 73 insertions(+), 54 deletions(-) (limited to 'runners/maven-plugin/src/main/kotlin') diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index ef30606a..ba95e7a7 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -28,7 +28,9 @@ import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink import java.io.File import java.net.URL -abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List) : AbstractMojo() { +public abstract class AbstractDokkaMojo( + private val defaultDokkaPlugins: List +) : AbstractMojo() { @Parameter(defaultValue = "\${project}", readonly = true, required = true) protected var mavenProject: MavenProject? = null @@ -47,10 +49,10 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List = emptyList() + public var sourceDirectories: List = emptyList() /** * List of directories or files that contain sample functions which are referenced via * [@sample](https://kotlinlang.org/docs/kotlin-doc.html#sample-identifier) KDoc tag. */ @Parameter - var samples: List = emptyList() + public var samples: List = emptyList() /** * List of Markdown files that contain @@ -95,7 +97,7 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List = emptyList() + public var includes: List = emptyList() /** * Classpath for analysis and interactive samples. @@ -106,14 +108,14 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List = emptyList() + public var classpath: List = emptyList() /** * Specifies the location of the project source code on the Web. If provided, Dokka generates * "source" links for each declaration. See [SourceLinkMapItem] for more details. */ @Parameter - var sourceLinks: List = emptyList() + public var sourceLinks: List = emptyList() /** * Display name used to refer to the project/module. Used for ToC, navigation, logging, etc. @@ -121,7 +123,7 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List = emptyList() + public var perPackageOptions: List = emptyList() /** * Allows linking to Dokka/Javadoc documentation of the project's dependencies. @@ -192,7 +194,7 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List = emptyList() + public var externalDocumentationLinks: List = emptyList() /** * Whether to generate external documentation links that lead to API reference @@ -201,7 +203,7 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List = emptyList() + public var suppressedFiles: List = emptyList() /** * Set of visibility modifiers that should be documented. @@ -270,7 +272,7 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List = DokkaDefaults.documentedVisibilities + public var documentedVisibilities: Set = DokkaDefaults.documentedVisibilities // hack to set the default value for lists, didn't find any other safe way // maven seems to overwrite Kotlin's default initialization value, so it doesn't matter what you put there get() = field.ifEmpty { DokkaDefaults.documentedVisibilities } @@ -284,7 +286,7 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List = emptyList() + public var dokkaPlugins: List = emptyList() get() = field + defaultDokkaPlugins @Parameter - var cacheRoot: String? = null + public var cacheRoot: String? = null @Parameter - var platform: String = "" + public var platform: String = "" /** * Deprecated. Use [documentedVisibilities] instead. */ @Parameter - var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic + public var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic protected abstract fun getOutDir(): String @@ -493,7 +495,7 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List * ``` */ -class ExternalDocumentationLinkBuilder { +public class ExternalDocumentationLinkBuilder { /** * Root URL of documentation to link with. **Must** contain a trailing slash. @@ -48,7 +49,7 @@ class ExternalDocumentationLinkBuilder { * ``` */ @Parameter(name = "url", required = true) - var url: URL? = null + public var url: URL? = null /** * Specifies the exact location of a `package-list` instead of relying on Dokka @@ -61,7 +62,7 @@ class ExternalDocumentationLinkBuilder { * ``` */ @Parameter(name = "packageListUrl", required = true) - var packageListUrl: URL? = null + public var packageListUrl: URL? = null - fun build() = ExternalDocumentationLink(url, packageListUrl) + public fun build(): ExternalDocumentationLinkImpl = ExternalDocumentationLink(url, packageListUrl) } diff --git a/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt b/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt index bf7997d3..1bc39d10 100644 --- a/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt +++ b/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt @@ -8,7 +8,9 @@ import org.apache.maven.plugin.logging.Log import org.jetbrains.dokka.utilities.DokkaLogger import java.util.concurrent.atomic.AtomicInteger -class MavenDokkaLogger(val log: Log) : DokkaLogger { +public class MavenDokkaLogger( + public val log: Log +) : DokkaLogger { private val warningsCounter = AtomicInteger() private val errorsCounter = AtomicInteger() @@ -20,9 +22,23 @@ class MavenDokkaLogger(val log: Log) : DokkaLogger { get() = errorsCounter.get() set(value) = errorsCounter.set(value) - override fun debug(message: String) = log.debug(message) - override fun info(message: String) = log.info(message) - override fun progress(message: String) = log.info(message) - override fun warn(message: String) = log.warn(message).also { warningsCounter.incrementAndGet() } - override fun error(message: String) = log.error(message).also { errorsCounter.incrementAndGet() } + override fun debug(message: String) { + log.debug(message) + } + + override fun info(message: String) { + log.info(message) + } + + override fun progress(message: String) { + log.info(message) + } + + override fun warn(message: String) { + this.log.warn(message).also { warningsCounter.incrementAndGet() } + } + + override fun error(message: String) { + log.error(message).also { errorsCounter.incrementAndGet() } + } } diff --git a/runners/maven-plugin/src/main/kotlin/PackageOptions.kt b/runners/maven-plugin/src/main/kotlin/PackageOptions.kt index 7b761dd2..875fb047 100644 --- a/runners/maven-plugin/src/main/kotlin/PackageOptions.kt +++ b/runners/maven-plugin/src/main/kotlin/PackageOptions.kt @@ -31,7 +31,7 @@ import org.jetbrains.dokka.DokkaDefaults * * ``` */ -class PackageOptions : DokkaConfiguration.PackageOptions { +public class PackageOptions : DokkaConfiguration.PackageOptions { /** * Regular expression that is used to match the package. diff --git a/runners/maven-plugin/src/main/kotlin/SourceLinkMapItem.kt b/runners/maven-plugin/src/main/kotlin/SourceLinkMapItem.kt index 0d2ade3c..ee2354aa 100644 --- a/runners/maven-plugin/src/main/kotlin/SourceLinkMapItem.kt +++ b/runners/maven-plugin/src/main/kotlin/SourceLinkMapItem.kt @@ -23,7 +23,7 @@ import org.apache.maven.plugins.annotations.Parameter * * ``` */ -class SourceLinkMapItem { +public class SourceLinkMapItem { /** * Path to the local source directory. The path must be relative to the root of current project. @@ -35,7 +35,7 @@ class SourceLinkMapItem { * ``` */ @Parameter(name = "path", required = true) - var path: String = "" + public var path: String = "" /** * URL of source code hosting service that can be accessed by documentation readers, @@ -49,7 +49,7 @@ class SourceLinkMapItem { * ``` */ @Parameter(name = "url", required = true) - var url: String = "" + public var url: String = "" /** * Suffix used to append source code line number to the URL. This will help readers navigate @@ -65,5 +65,5 @@ class SourceLinkMapItem { * - Bitbucket: `#lines-` */ @Parameter(name = "lineSuffix") - var lineSuffix: String? = null + public var lineSuffix: String? = null } -- cgit