diff options
Diffstat (limited to 'core/src/main')
61 files changed, 917 insertions, 827 deletions
diff --git a/core/src/main/kotlin/ConfigurationJsonUtils.kt b/core/src/main/kotlin/ConfigurationJsonUtils.kt index 9e03b906..e693f4ef 100644 --- a/core/src/main/kotlin/ConfigurationJsonUtils.kt +++ b/core/src/main/kotlin/ConfigurationJsonUtils.kt @@ -9,15 +9,15 @@ import org.jetbrains.dokka.utilities.parseJson import org.jetbrains.dokka.utilities.serializeAsCompactJson import org.jetbrains.dokka.utilities.serializeAsPrettyJson -fun DokkaConfigurationImpl(json: String): DokkaConfigurationImpl = parseJson(json) +public fun DokkaConfigurationImpl(json: String): DokkaConfigurationImpl = parseJson(json) -fun GlobalDokkaConfiguration(json: String): GlobalDokkaConfiguration = parseJson(json) +public fun GlobalDokkaConfiguration(json: String): GlobalDokkaConfiguration = parseJson(json) @Deprecated("Renamed to better distinguish between compact/pretty prints", ReplaceWith("this.toCompactJsonString()")) -fun DokkaConfiguration.toJsonString(): String = this.toCompactJsonString() +public fun DokkaConfiguration.toJsonString(): String = this.toCompactJsonString() @Deprecated("Renamed to better distinguish between compact/pretty prints", ReplaceWith("this.toCompactJsonString()")) -fun <T : ConfigurableBlock> T.toJsonString(): String = this.toCompactJsonString() +public fun <T : ConfigurableBlock> T.toJsonString(): String = this.toCompactJsonString() /** * Serializes [DokkaConfiguration] as a machine-readable and compact JSON string. @@ -25,7 +25,7 @@ fun <T : ConfigurableBlock> T.toJsonString(): String = this.toCompactJsonString( * The returned string is not very human friendly as it will be difficult to parse by eyes due to it * being compact and in one line. If you want to show the output to a human being, see [toPrettyJsonString]. */ -fun DokkaConfiguration.toCompactJsonString(): String = serializeAsCompactJson(this) +public fun DokkaConfiguration.toCompactJsonString(): String = serializeAsCompactJson(this) /** * Serializes [DokkaConfiguration] as a human-readable (pretty printed) JSON string. @@ -34,7 +34,7 @@ fun DokkaConfiguration.toCompactJsonString(): String = serializeAsCompactJson(th * desirable when passing this value between API consumers/producers. If you want * a machine-readable and compact json string, see [toCompactJsonString]. */ -fun DokkaConfiguration.toPrettyJsonString(): String = serializeAsPrettyJson(this) +public fun DokkaConfiguration.toPrettyJsonString(): String = serializeAsPrettyJson(this) /** * Serializes a [ConfigurableBlock] as a machine-readable and compact JSON string. @@ -42,7 +42,7 @@ fun DokkaConfiguration.toPrettyJsonString(): String = serializeAsPrettyJson(this * The returned string is not very human friendly as it will be difficult to parse by eyes due to it * being compact and in one line. If you want to show the output to a human being, see [toPrettyJsonString]. */ -fun <T : ConfigurableBlock> T.toCompactJsonString(): String = serializeAsCompactJson(this) +public fun <T : ConfigurableBlock> T.toCompactJsonString(): String = serializeAsCompactJson(this) /** * Serializes a [ConfigurableBlock] as a human-readable (pretty printed) JSON string. @@ -51,4 +51,4 @@ fun <T : ConfigurableBlock> T.toCompactJsonString(): String = serializeAsCompact * desirable when passing this value between API consumers/producers. If you want * a machine-readable and compact json string, see [toCompactJsonString]. */ -fun <T : ConfigurableBlock> T.toPrettyJsonString(): String = serializeAsCompactJson(this) +public fun <T : ConfigurableBlock> T.toPrettyJsonString(): String = serializeAsCompactJson(this) diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt index d689d102..ca2504e2 100644 --- a/core/src/main/kotlin/CoreExtensions.kt +++ b/core/src/main/kotlin/CoreExtensions.kt @@ -16,17 +16,25 @@ import org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator import org.jetbrains.dokka.validity.PreGenerationChecker import kotlin.reflect.KProperty -object CoreExtensions { - - val preGenerationCheck by coreExtensionPoint<PreGenerationChecker>() - val generation by coreExtensionPoint<Generation>() - val sourceToDocumentableTranslator by coreExtensionPoint<SourceToDocumentableTranslator>() - val documentableMerger by coreExtensionPoint<DocumentableMerger>() - val documentableTransformer by coreExtensionPoint<DocumentableTransformer>() - val documentableToPageTranslator by coreExtensionPoint<DocumentableToPageTranslator>() - val pageTransformer by coreExtensionPoint<PageTransformer>() - val renderer by coreExtensionPoint<Renderer>() - val postActions by coreExtensionPoint<PostAction>() +public object CoreExtensions { + + public val preGenerationCheck: ExtensionPoint<PreGenerationChecker> by coreExtensionPoint<PreGenerationChecker>() + + public val generation: ExtensionPoint<Generation> by coreExtensionPoint<Generation>() + + public val sourceToDocumentableTranslator: ExtensionPoint<SourceToDocumentableTranslator> by coreExtensionPoint<SourceToDocumentableTranslator>() + + public val documentableMerger: ExtensionPoint<DocumentableMerger> by coreExtensionPoint<DocumentableMerger>() + + public val documentableTransformer: ExtensionPoint<DocumentableTransformer> by coreExtensionPoint<DocumentableTransformer>() + + public val documentableToPageTranslator: ExtensionPoint<DocumentableToPageTranslator> by coreExtensionPoint<DocumentableToPageTranslator>() + + public val pageTransformer: ExtensionPoint<PageTransformer> by coreExtensionPoint<PageTransformer>() + + public val renderer: ExtensionPoint<Renderer> by coreExtensionPoint<Renderer>() + + public val postActions: ExtensionPoint<PostAction> by coreExtensionPoint<PostAction>() private fun <T : Any> coreExtensionPoint() = object { operator fun provideDelegate(thisRef: CoreExtensions, property: KProperty<*>): Lazy<ExtensionPoint<T>> = diff --git a/core/src/main/kotlin/DokkaBootstrap.kt b/core/src/main/kotlin/DokkaBootstrap.kt index 13cc9ded..d3d82e39 100644 --- a/core/src/main/kotlin/DokkaBootstrap.kt +++ b/core/src/main/kotlin/DokkaBootstrap.kt @@ -6,10 +6,10 @@ package org.jetbrains.dokka import java.util.function.BiConsumer -interface DokkaBootstrap { +public interface DokkaBootstrap { @Throws(Throwable::class) - fun configure(serializedConfigurationJSON: String, logger: BiConsumer<String, String>) + public fun configure(serializedConfigurationJSON: String, logger: BiConsumer<String, String>) @Throws(Throwable::class) - fun generate() + public fun generate() } diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index c0af9a41..65f0ef72 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -13,9 +13,11 @@ import java.util.function.BiConsumer * Accessed with reflection */ @Suppress("unused") -class DokkaBootstrapImpl : DokkaBootstrap { +public class DokkaBootstrapImpl : DokkaBootstrap { - class DokkaProxyLogger(val consumer: BiConsumer<String, String>) : DokkaLogger { + public class DokkaProxyLogger( + public val consumer: BiConsumer<String, String> + ) : DokkaLogger { private val warningsCounter = AtomicInteger() private val errorsCounter = AtomicInteger() @@ -50,14 +52,18 @@ class DokkaBootstrapImpl : DokkaBootstrap { private lateinit var generator: DokkaGenerator - fun configure(logger: DokkaLogger, configuration: DokkaConfigurationImpl) { + public fun configure(logger: DokkaLogger, configuration: DokkaConfigurationImpl) { generator = DokkaGenerator(configuration, logger) } - override fun configure(serializedConfigurationJSON: String, logger: BiConsumer<String, String>) = configure( - DokkaProxyLogger(logger), - DokkaConfigurationImpl(serializedConfigurationJSON) - ) + override fun configure(serializedConfigurationJSON: String, logger: BiConsumer<String, String>) { + configure( + DokkaProxyLogger(logger), + DokkaConfigurationImpl(serializedConfigurationJSON) + ) + } - override fun generate() = generator.generate() + override fun generate() { + generator.generate() + } } diff --git a/core/src/main/kotlin/DokkaException.kt b/core/src/main/kotlin/DokkaException.kt index cc487175..f16a2649 100644 --- a/core/src/main/kotlin/DokkaException.kt +++ b/core/src/main/kotlin/DokkaException.kt @@ -4,4 +4,4 @@ package org.jetbrains.dokka -open class DokkaException(message: String) : RuntimeException(message) +public open class DokkaException(message: String) : RuntimeException(message) diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index 6132b92f..9ae3adb4 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -18,33 +18,35 @@ import org.jetbrains.dokka.utilities.DokkaLogger * * [generate] method has been split into submethods for test reasons */ -class DokkaGenerator( +public class DokkaGenerator( private val configuration: DokkaConfiguration, private val logger: DokkaLogger ) { - fun generate() = timed(logger) { - report("Initializing plugins") - val context = initializePlugins(configuration, logger) + public fun generate() { + timed(logger) { + report("Initializing plugins") + val context = initializePlugins(configuration, logger) - runCatching { - context.single(CoreExtensions.generation).run { - logger.progress("Dokka is performing: $generationName") - generate() + runCatching { + context.single(CoreExtensions.generation).run { + logger.progress("Dokka is performing: $generationName") + generate() + } + }.exceptionOrNull()?.let { e -> + finalizeCoroutines() + throw e } - }.exceptionOrNull()?.let { e -> - finalizeCoroutines() - throw e - } - finalizeCoroutines() - }.dump("\n\n === TIME MEASUREMENT ===\n") + finalizeCoroutines() + }.dump("\n\n === TIME MEASUREMENT ===\n") + } - fun initializePlugins( + public fun initializePlugins( configuration: DokkaConfiguration, logger: DokkaLogger, additionalPlugins: List<DokkaPlugin> = emptyList() - ) = DokkaContext.create(configuration, logger, additionalPlugins) + ): DokkaContext = DokkaContext.create(configuration, logger, additionalPlugins) @OptIn(DelicateCoroutinesApi::class) private fun finalizeCoroutines() { @@ -54,15 +56,15 @@ class DokkaGenerator( } } -class Timer internal constructor(startTime: Long, private val logger: DokkaLogger?) { +public class Timer internal constructor(startTime: Long, private val logger: DokkaLogger?) { private val steps = mutableListOf("" to startTime) - fun report(name: String) { + public fun report(name: String) { logger?.progress(name) steps += (name to System.currentTimeMillis()) } - fun dump(prefix: String = "") { + public fun dump(prefix: String = "") { logger?.info(prefix) val namePad = steps.map { it.first.length }.maxOrNull() ?: 0 val timePad = steps.windowed(2).map { (p1, p2) -> p2.second - p1.second }.maxOrNull()?.toString()?.length ?: 0 diff --git a/core/src/main/kotlin/DokkaVersion.kt b/core/src/main/kotlin/DokkaVersion.kt index 37ce77ba..d846988b 100644 --- a/core/src/main/kotlin/DokkaVersion.kt +++ b/core/src/main/kotlin/DokkaVersion.kt @@ -6,8 +6,8 @@ package org.jetbrains.dokka import java.util.* -object DokkaVersion { - val version: String by lazy { +public object DokkaVersion { + public val version: String by lazy { javaClass.getResourceAsStream("/META-INF/dokka/dokka-version.properties").use { stream -> Properties().apply { load(stream) }.getProperty("dokka-version") } diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt index 9cbc6ea2..65035d04 100644 --- a/core/src/main/kotlin/configuration.kt +++ b/core/src/main/kotlin/configuration.kt @@ -9,53 +9,55 @@ import java.io.File import java.io.Serializable import java.net.URL -object DokkaDefaults { - val moduleName: String = "root" - val moduleVersion: String? = null - val outputDir = File("./dokka") - const val failOnWarning: Boolean = false - const val suppressObviousFunctions = true - const val suppressInheritedMembers = false - const val offlineMode: Boolean = false +public object DokkaDefaults { + public val moduleName: String = "root" + public val moduleVersion: String? = null + public val outputDir: File = File("./dokka") + public const val failOnWarning: Boolean = false + public const val suppressObviousFunctions: Boolean = true + public const val suppressInheritedMembers: Boolean = false + public const val offlineMode: Boolean = false - const val sourceSetDisplayName = "JVM" - const val sourceSetName = "main" - val analysisPlatform: Platform = Platform.DEFAULT + public const val sourceSetDisplayName: String = "JVM" + public const val sourceSetName: String = "main" + public val analysisPlatform: Platform = Platform.DEFAULT - const val suppress: Boolean = false - const val suppressGeneratedFiles: Boolean = true + public const val suppress: Boolean = false + public const val suppressGeneratedFiles: Boolean = true - const val skipEmptyPackages: Boolean = true - const val skipDeprecated: Boolean = false + public const val skipEmptyPackages: Boolean = true + public const val skipDeprecated: Boolean = false - const val reportUndocumented: Boolean = false + public const val reportUndocumented: Boolean = false - const val noStdlibLink: Boolean = false - const val noAndroidSdkLink: Boolean = false - const val noJdkLink: Boolean = false - const val jdkVersion: Int = 8 + public const val noStdlibLink: Boolean = false + public const val noAndroidSdkLink: Boolean = false + public const val noJdkLink: Boolean = false + public const val jdkVersion: Int = 8 - const val includeNonPublic: Boolean = false - val documentedVisibilities: Set<DokkaConfiguration.Visibility> = setOf(DokkaConfiguration.Visibility.PUBLIC) + public const val includeNonPublic: Boolean = false + public val documentedVisibilities: Set<DokkaConfiguration.Visibility> = setOf(DokkaConfiguration.Visibility.PUBLIC) - val pluginsConfiguration = mutableListOf<PluginConfigurationImpl>() + public val pluginsConfiguration: List<PluginConfigurationImpl> = mutableListOf() - const val delayTemplateSubstitution: Boolean = false + public const val delayTemplateSubstitution: Boolean = false - val cacheRoot: File? = null + public val cacheRoot: File? = null } -enum class Platform(val key: String) { +public enum class Platform( + public val key: String +) { jvm("jvm"), js("js"), wasm("wasm"), native("native"), common("common"); - companion object { - val DEFAULT = jvm + public companion object { + public val DEFAULT: Platform = jvm - fun fromString(key: String): Platform { + public fun fromString(key: String): Platform { return when (key.toLowerCase()) { jvm.key -> jvm js.key -> js @@ -70,14 +72,13 @@ enum class Platform(val key: String) { } } -fun interface DokkaConfigurationBuilder<T : Any> { - fun build(): T +public fun interface DokkaConfigurationBuilder<T : Any> { + public fun build(): T } -fun <T : Any> Iterable<DokkaConfigurationBuilder<T>>.build(): List<T> = this.map { it.build() } +public fun <T : Any> Iterable<DokkaConfigurationBuilder<T>>.build(): List<T> = this.map { it.build() } - -data class DokkaSourceSetID( +public data class DokkaSourceSetID( /** * Unique identifier of the scope that this source set is placed in. * Each scope provide only unique source set names. @@ -102,13 +103,13 @@ data class DokkaSourceSetID( * * @see [apply] to learn how to apply global configuration */ -data class GlobalDokkaConfiguration( +public data class GlobalDokkaConfiguration( val perPackageOptions: List<PackageOptionsImpl>?, val externalDocumentationLinks: List<ExternalDocumentationLinkImpl>?, val sourceLinks: List<SourceLinkDefinitionImpl>? ) -fun DokkaConfiguration.apply(globals: GlobalDokkaConfiguration): DokkaConfiguration = this.apply { +public fun DokkaConfiguration.apply(globals: GlobalDokkaConfiguration): DokkaConfiguration = this.apply { sourceSets.forEach { it.perPackageOptions.cast<MutableList<DokkaConfiguration.PackageOptions>>() .addAll(globals.perPackageOptions ?: emptyList()) @@ -124,21 +125,21 @@ fun DokkaConfiguration.apply(globals: GlobalDokkaConfiguration): DokkaConfigurat } } -interface DokkaConfiguration : Serializable { - val moduleName: String - val moduleVersion: String? - val outputDir: File - val cacheRoot: File? - val offlineMode: Boolean - val failOnWarning: Boolean - val sourceSets: List<DokkaSourceSet> - val modules: List<DokkaModuleDescription> - val pluginsClasspath: List<File> - val pluginsConfiguration: List<PluginConfiguration> - val delayTemplateSubstitution: Boolean - val suppressObviousFunctions: Boolean - val includes: Set<File> - val suppressInheritedMembers: Boolean +public interface DokkaConfiguration : Serializable { + public val moduleName: String + public val moduleVersion: String? + public val outputDir: File + public val cacheRoot: File? + public val offlineMode: Boolean + public val failOnWarning: Boolean + public val sourceSets: List<DokkaSourceSet> + public val modules: List<DokkaModuleDescription> + public val pluginsClasspath: List<File> + public val pluginsConfiguration: List<PluginConfiguration> + public val delayTemplateSubstitution: Boolean + public val suppressObviousFunctions: Boolean + public val includes: Set<File> + public val suppressInheritedMembers: Boolean /** * Whether coroutines dispatchers should be shutdown after @@ -157,46 +158,46 @@ interface DokkaConfiguration : Serializable { * and closing it down will leave the build in an inoperable state. * One such example is unit tests, for which finalization should be disabled. */ - val finalizeCoroutines: Boolean + public val finalizeCoroutines: Boolean - enum class SerializationFormat : Serializable { + public enum class SerializationFormat : Serializable { JSON, XML } - interface PluginConfiguration : Serializable { - val fqPluginName: String - val serializationFormat: SerializationFormat - val values: String + public interface PluginConfiguration : Serializable { + public val fqPluginName: String + public val serializationFormat: SerializationFormat + public val values: String } - interface DokkaSourceSet : Serializable { - val sourceSetID: DokkaSourceSetID - val displayName: String - val classpath: List<File> - val sourceRoots: Set<File> - val dependentSourceSets: Set<DokkaSourceSetID> - val samples: Set<File> - val includes: Set<File> + public interface DokkaSourceSet : Serializable { + public val sourceSetID: DokkaSourceSetID + public val displayName: String + public val classpath: List<File> + public val sourceRoots: Set<File> + public val dependentSourceSets: Set<DokkaSourceSetID> + public val samples: Set<File> + public val includes: Set<File> @Deprecated(message = "Use [documentedVisibilities] property for a more flexible control over documented visibilities") - val includeNonPublic: Boolean - val reportUndocumented: Boolean - val skipEmptyPackages: Boolean - val skipDeprecated: Boolean - val jdkVersion: Int - val sourceLinks: Set<SourceLinkDefinition> - val perPackageOptions: List<PackageOptions> - val externalDocumentationLinks: Set<ExternalDocumentationLink> - val languageVersion: String? - val apiVersion: String? - val noStdlibLink: Boolean - val noJdkLink: Boolean - val suppressedFiles: Set<File> - val analysisPlatform: Platform - val documentedVisibilities: Set<Visibility> + public val includeNonPublic: Boolean + public val reportUndocumented: Boolean + public val skipEmptyPackages: Boolean + public val skipDeprecated: Boolean + public val jdkVersion: Int + public val sourceLinks: Set<SourceLinkDefinition> + public val perPackageOptions: List<PackageOptions> + public val externalDocumentationLinks: Set<ExternalDocumentationLink> + public val languageVersion: String? + public val apiVersion: String? + public val noStdlibLink: Boolean + public val noJdkLink: Boolean + public val suppressedFiles: Set<File> + public val analysisPlatform: Platform + public val documentedVisibilities: Set<Visibility> } - enum class Visibility { + public enum class Visibility { /** * `public` modifier for Java, default visibility for Kotlin */ @@ -222,45 +223,45 @@ interface DokkaConfiguration : Serializable { */ PACKAGE; - companion object { - fun fromString(value: String) = valueOf(value.toUpperCase()) + public companion object { + public fun fromString(value: String): Visibility = valueOf(value.toUpperCase()) } } - interface SourceLinkDefinition : Serializable { - val localDirectory: String - val remoteUrl: URL - val remoteLineSuffix: String? + public interface SourceLinkDefinition : Serializable { + public val localDirectory: String + public val remoteUrl: URL + public val remoteLineSuffix: String? } - interface DokkaModuleDescription : Serializable { - val name: String - val relativePathToOutputDirectory: File - val sourceOutputDirectory: File - val includes: Set<File> + public interface DokkaModuleDescription : Serializable { + public val name: String + public val relativePathToOutputDirectory: File + public val sourceOutputDirectory: File + public val includes: Set<File> } - interface PackageOptions : Serializable { - val matchingRegex: String + public interface PackageOptions : Serializable { + public val matchingRegex: String @Deprecated("Use [documentedVisibilities] property for a more flexible control over documented visibilities") - val includeNonPublic: Boolean - val reportUndocumented: Boolean? - val skipDeprecated: Boolean - val suppress: Boolean - val documentedVisibilities: Set<Visibility> + public val includeNonPublic: Boolean + public val reportUndocumented: Boolean? + public val skipDeprecated: Boolean + public val suppress: Boolean + public val documentedVisibilities: Set<Visibility> } - interface ExternalDocumentationLink : Serializable { - val url: URL - val packageListUrl: URL + public interface ExternalDocumentationLink : Serializable { + public val url: URL + public val packageListUrl: URL - companion object + public companion object } } @Suppress("FunctionName") -fun ExternalDocumentationLink( +public fun ExternalDocumentationLink( url: URL? = null, packageListUrl: URL? = null ): ExternalDocumentationLinkImpl { @@ -273,7 +274,7 @@ fun ExternalDocumentationLink( } @Suppress("FunctionName") -fun ExternalDocumentationLink( +public fun ExternalDocumentationLink( url: String, packageListUrl: String? = null ): ExternalDocumentationLinkImpl = ExternalDocumentationLink(url.let(::URL), packageListUrl?.let(::URL)) diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt index 2ea5e0ef..f858d8c0 100644 --- a/core/src/main/kotlin/defaultConfiguration.kt +++ b/core/src/main/kotlin/defaultConfiguration.kt @@ -8,7 +8,7 @@ import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import java.io.File import java.net.URL -data class DokkaConfigurationImpl( +public data class DokkaConfigurationImpl( override val moduleName: String = DokkaDefaults.moduleName, override val moduleVersion: String? = DokkaDefaults.moduleVersion, override val outputDir: File = DokkaDefaults.outputDir, @@ -26,14 +26,14 @@ data class DokkaConfigurationImpl( override val finalizeCoroutines: Boolean = true, ) : DokkaConfiguration -data class PluginConfigurationImpl( +public data class PluginConfigurationImpl( override val fqPluginName: String, override val serializationFormat: DokkaConfiguration.SerializationFormat, override val values: String ) : DokkaConfiguration.PluginConfiguration -data class DokkaSourceSetImpl( +public data class DokkaSourceSetImpl( override val displayName: String = DokkaDefaults.sourceSetDisplayName, override val sourceSetID: DokkaSourceSetID, override val classpath: List<File> = emptyList(), @@ -59,20 +59,21 @@ data class DokkaSourceSetImpl( override val documentedVisibilities: Set<DokkaConfiguration.Visibility> = DokkaDefaults.documentedVisibilities, ) : DokkaSourceSet -data class DokkaModuleDescriptionImpl( +public data class DokkaModuleDescriptionImpl( override val name: String, override val relativePathToOutputDirectory: File, override val includes: Set<File>, override val sourceOutputDirectory: File ) : DokkaConfiguration.DokkaModuleDescription -data class SourceLinkDefinitionImpl( +public data class SourceLinkDefinitionImpl( override val localDirectory: String, override val remoteUrl: URL, override val remoteLineSuffix: String?, ) : DokkaConfiguration.SourceLinkDefinition { - companion object { - fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinitionImpl { + + public companion object { + public fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinitionImpl { val (path, urlAndLine) = srcLink.split('=') return SourceLinkDefinitionImpl( localDirectory = File(path).canonicalPath, @@ -82,7 +83,7 @@ data class SourceLinkDefinitionImpl( } } -data class PackageOptionsImpl( +public data class PackageOptionsImpl( override val matchingRegex: String, @Deprecated("Use [documentedVisibilities] property for a more flexible control over documented visibilities") override val includeNonPublic: Boolean, @@ -93,7 +94,7 @@ data class PackageOptionsImpl( ) : DokkaConfiguration.PackageOptions -data class ExternalDocumentationLinkImpl( +public data class ExternalDocumentationLinkImpl( override val url: URL, override val packageListUrl: URL, ) : DokkaConfiguration.ExternalDocumentationLink diff --git a/core/src/main/kotlin/defaultExternalLinks.kt b/core/src/main/kotlin/defaultExternalLinks.kt index 8d3b9655..26e3e0ae 100644 --- a/core/src/main/kotlin/defaultExternalLinks.kt +++ b/core/src/main/kotlin/defaultExternalLinks.kt @@ -8,7 +8,7 @@ import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink import java.net.URL -fun ExternalDocumentationLink.Companion.jdk(jdkVersion: Int): ExternalDocumentationLinkImpl = +public fun ExternalDocumentationLink.Companion.jdk(jdkVersion: Int): ExternalDocumentationLinkImpl = ExternalDocumentationLink( url = if (jdkVersion < 11) "https://docs.oracle.com/javase/${jdkVersion}/docs/api/" @@ -19,15 +19,15 @@ fun ExternalDocumentationLink.Companion.jdk(jdkVersion: Int): ExternalDocumentat ) -fun ExternalDocumentationLink.Companion.kotlinStdlib(): ExternalDocumentationLinkImpl = +public fun ExternalDocumentationLink.Companion.kotlinStdlib(): ExternalDocumentationLinkImpl = ExternalDocumentationLink("https://kotlinlang.org/api/latest/jvm/stdlib/") -fun ExternalDocumentationLink.Companion.androidSdk(): ExternalDocumentationLinkImpl = +public fun ExternalDocumentationLink.Companion.androidSdk(): ExternalDocumentationLinkImpl = ExternalDocumentationLink("https://developer.android.com/reference/kotlin/") -fun ExternalDocumentationLink.Companion.androidX(): ExternalDocumentationLinkImpl = ExternalDocumentationLink( +public fun ExternalDocumentationLink.Companion.androidX(): ExternalDocumentationLinkImpl = ExternalDocumentationLink( url = URL("https://developer.android.com/reference/kotlin/"), packageListUrl = URL("https://developer.android.com/reference/kotlin/androidx/package-list") ) diff --git a/core/src/main/kotlin/generation/Generation.kt b/core/src/main/kotlin/generation/Generation.kt index 185b00f8..9f14912f 100644 --- a/core/src/main/kotlin/generation/Generation.kt +++ b/core/src/main/kotlin/generation/Generation.kt @@ -6,14 +6,14 @@ package org.jetbrains.dokka.generation import org.jetbrains.dokka.Timer -interface Generation { - fun Timer.generate() - val generationName: String +public interface Generation { + public fun Timer.generate() + public val generationName: String } // This needs to be public for now but in the future it should be replaced with system of checks provided by EP -fun exitGenerationGracefully(reason: String): Nothing { +public fun exitGenerationGracefully(reason: String): Nothing { throw GracefulGenerationExit(reason) } -class GracefulGenerationExit(val reason: String) : Throwable() +public class GracefulGenerationExit(public val reason: String) : Throwable() diff --git a/core/src/main/kotlin/links/DRI.kt b/core/src/main/kotlin/links/DRI.kt index bcd0198b..180d9eb8 100644 --- a/core/src/main/kotlin/links/DRI.kt +++ b/core/src/main/kotlin/links/DRI.kt @@ -12,7 +12,7 @@ import com.fasterxml.jackson.module.kotlin.readValue /** * [DRI] stands for DokkaResourceIdentifier */ -data class DRI( +public data class DRI( val packageName: String? = null, val classNames: String? = null, val callable: Callable? = null, @@ -23,47 +23,47 @@ data class DRI( "${packageName.orEmpty()}/${classNames.orEmpty()}/${callable?.name.orEmpty()}/${callable?.signature() .orEmpty()}/$target/${extra.orEmpty()}" - companion object { - val topLevel = DRI() - + public companion object { + public val topLevel: DRI = DRI() } } -object EnumEntryDRIExtra: DRIExtraProperty<EnumEntryDRIExtra>() +public object EnumEntryDRIExtra: DRIExtraProperty<EnumEntryDRIExtra>() -abstract class DRIExtraProperty<T> { - val key: String = this::class.qualifiedName +public abstract class DRIExtraProperty<T> { + public val key: String = this::class.qualifiedName ?: (this.javaClass.let { it.`package`.name + "." + it.simpleName.ifEmpty { "anonymous" } }) } -class DRIExtraContainer(val data: String? = null) { - val map: MutableMap<String, Any> = if (data != null) OBJECT_MAPPER.readValue(data) else mutableMapOf() - inline operator fun <reified T> get(prop: DRIExtraProperty<T>): T? = +public class DRIExtraContainer(public val data: String? = null) { + public val map: MutableMap<String, Any> = if (data != null) OBJECT_MAPPER.readValue(data) else mutableMapOf() + public inline operator fun <reified T> get(prop: DRIExtraProperty<T>): T? = map[prop.key]?.let { prop as? T } - inline operator fun <reified T> set(prop: DRIExtraProperty<T>, value: T) = - value.also { map[prop.key] = it as Any } + public inline operator fun <reified T> set(prop: DRIExtraProperty<T>, value: T) { + map[prop.key] = value as Any + } - fun encode(): String = OBJECT_MAPPER.writeValueAsString(map) + public fun encode(): String = OBJECT_MAPPER.writeValueAsString(map) private companion object { private val OBJECT_MAPPER = ObjectMapper() } } -val DriOfUnit = DRI("kotlin", "Unit") -val DriOfAny = DRI("kotlin", "Any") +public val DriOfUnit: DRI = DRI("kotlin", "Unit") +public val DriOfAny: DRI = DRI("kotlin", "Any") -fun DRI.withClass(name: String) = copy(classNames = if (classNames.isNullOrBlank()) name else "$classNames.$name") +public fun DRI.withClass(name: String): DRI = copy(classNames = if (classNames.isNullOrBlank()) name else "$classNames.$name") -fun DRI.withTargetToDeclaration() = copy(target = PointingToDeclaration) +public fun DRI.withTargetToDeclaration(): DRI = copy(target = PointingToDeclaration) -fun DRI.withEnumEntryExtra() = copy( +public fun DRI.withEnumEntryExtra(): DRI = copy( extra = DRIExtraContainer(this.extra).also { it[EnumEntryDRIExtra] = EnumEntryDRIExtra }.encode() ) -val DRI.parent: DRI +public val DRI.parent: DRI get() = when { extra != null -> when { DRIExtraContainer(extra)[EnumEntryDRIExtra] != null -> copy( @@ -78,68 +78,68 @@ val DRI.parent: DRI else -> DRI.topLevel } -val DRI.sureClassNames +public val DRI.sureClassNames: String get() = classNames ?: throw IllegalStateException("Malformed DRI. It requires classNames in this context.") -data class Callable( +public data class Callable( val name: String, val receiver: TypeReference? = null, val params: List<TypeReference> ) { - fun signature() = "${receiver?.toString().orEmpty()}#${params.joinToString("#")}" + public fun signature(): String = "${receiver?.toString().orEmpty()}#${params.joinToString("#")}" - companion object + public companion object } @JsonTypeInfo(use = CLASS) -sealed class TypeReference { - companion object +public sealed class TypeReference { + public companion object } -data class JavaClassReference(val name: String) : TypeReference() { +public data class JavaClassReference(val name: String) : TypeReference() { override fun toString(): String = name } -data class TypeParam(val bounds: List<TypeReference>) : TypeReference() +public data class TypeParam(val bounds: List<TypeReference>) : TypeReference() -data class TypeConstructor( +public data class TypeConstructor( val fullyQualifiedName: String, val params: List<TypeReference> ) : TypeReference() { - override fun toString() = fullyQualifiedName + + override fun toString(): String = fullyQualifiedName + (if (params.isNotEmpty()) "[${params.joinToString(",")}]" else "") } -data class RecursiveType(val rank: Int): TypeReference() { - override fun toString() = "^".repeat(rank + 1) +public data class RecursiveType(val rank: Int): TypeReference() { + override fun toString(): String = "^".repeat(rank + 1) } -data class Nullable(val wrapped: TypeReference) : TypeReference() { - override fun toString() = "$wrapped?" +public data class Nullable(val wrapped: TypeReference) : TypeReference() { + override fun toString(): String = "$wrapped?" } -object StarProjection : TypeReference() { - override fun toString() = "*" +public object StarProjection : TypeReference() { + override fun toString(): String = "*" } @JsonTypeInfo(use = CLASS) -sealed class DriTarget { +public sealed class DriTarget { override fun toString(): String = this.javaClass.simpleName - companion object + public companion object } -data class PointingToGenericParameters(val parameterIndex: Int) : DriTarget() { +public data class PointingToGenericParameters(val parameterIndex: Int) : DriTarget() { override fun toString(): String = "PointingToGenericParameters($parameterIndex)" } -object PointingToDeclaration : DriTarget() +public object PointingToDeclaration : DriTarget() -data class PointingToCallableParameters(val parameterIndex: Int) : DriTarget() { +public data class PointingToCallableParameters(val parameterIndex: Int) : DriTarget() { override fun toString(): String = "PointingToCallableParameters($parameterIndex)" } -fun DriTarget.nextTarget(): DriTarget = when (this) { +public fun DriTarget.nextTarget(): DriTarget = when (this) { is PointingToGenericParameters -> PointingToGenericParameters(this.parameterIndex + 1) is PointingToCallableParameters -> PointingToCallableParameters(this.parameterIndex + 1) else -> this diff --git a/core/src/main/kotlin/model/CompositeSourceSetID.kt b/core/src/main/kotlin/model/CompositeSourceSetID.kt index 36318633..af7d1a5d 100644 --- a/core/src/main/kotlin/model/CompositeSourceSetID.kt +++ b/core/src/main/kotlin/model/CompositeSourceSetID.kt @@ -32,15 +32,15 @@ public data class CompositeSourceSetID( public val all: Set<DokkaSourceSetID> = setOf(merged, *children.toTypedArray()) - operator fun contains(sourceSetId: DokkaSourceSetID): Boolean { + public operator fun contains(sourceSetId: DokkaSourceSetID): Boolean { return sourceSetId in all } - operator fun contains(sourceSet: DokkaConfiguration.DokkaSourceSet): Boolean { + public operator fun contains(sourceSet: DokkaConfiguration.DokkaSourceSet): Boolean { return sourceSet.sourceSetID in this } - operator fun plus(other: DokkaSourceSetID): CompositeSourceSetID { + public operator fun plus(other: DokkaSourceSetID): CompositeSourceSetID { return copy(children = children + other) } } diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index d96b051c..c6109f47 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -10,92 +10,95 @@ import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.model.properties.WithExtraProperties -interface AnnotationTarget +public interface AnnotationTarget -abstract class Documentable : WithChildren<Documentable>, +public abstract class Documentable : WithChildren<Documentable>, AnnotationTarget { - abstract val name: String? - abstract val dri: DRI - abstract val documentation: SourceSetDependent<DocumentationNode> - abstract val sourceSets: Set<DokkaSourceSet> - abstract val expectPresentInSet: DokkaSourceSet? + public abstract val name: String? + public abstract val dri: DRI + public abstract val documentation: SourceSetDependent<DocumentationNode> + public abstract val sourceSets: Set<DokkaSourceSet> + public abstract val expectPresentInSet: DokkaSourceSet? abstract override val children: List<Documentable> override fun toString(): String = "${javaClass.simpleName}($dri)" - override fun equals(other: Any?) = + override fun equals(other: Any?): Boolean = other is Documentable && this.dri == other.dri // TODO: https://github.com/Kotlin/dokka/pull/667#discussion_r382555806 - override fun hashCode() = dri.hashCode() + override fun hashCode(): Int = dri.hashCode() } -typealias SourceSetDependent<T> = Map<DokkaSourceSet, T> +public typealias SourceSetDependent<T> = Map<DokkaSourceSet, T> -interface WithSources { - val sources: SourceSetDependent<DocumentableSource> +public interface WithSources { + public val sources: SourceSetDependent<DocumentableSource> } -interface WithScope { - val functions: List<DFunction> - val properties: List<DProperty> - val classlikes: List<DClasslike> +public interface WithScope { + public val functions: List<DFunction> + public val properties: List<DProperty> + public val classlikes: List<DClasslike> } -interface WithVisibility { - val visibility: SourceSetDependent<Visibility> +public interface WithVisibility { + public val visibility: SourceSetDependent<Visibility> } -interface WithType { - val type: Bound +public interface WithType { + public val type: Bound } -interface WithAbstraction { - val modifier: SourceSetDependent<Modifier> +public interface WithAbstraction { + public val modifier: SourceSetDependent<Modifier> } -sealed class Modifier(val name: String) -sealed class KotlinModifier(name: String) : Modifier(name) { - object Abstract : KotlinModifier("abstract") - object Open : KotlinModifier("open") - object Final : KotlinModifier("final") - object Sealed : KotlinModifier("sealed") - object Empty : KotlinModifier("") +public sealed class Modifier( + public val name: String +) + +public sealed class KotlinModifier(name: String) : Modifier(name) { + public object Abstract : KotlinModifier("abstract") + public object Open : KotlinModifier("open") + public object Final : KotlinModifier("final") + public object Sealed : KotlinModifier("sealed") + public object Empty : KotlinModifier("") } -sealed class JavaModifier(name: String) : Modifier(name) { - object Abstract : JavaModifier("abstract") - object Final : JavaModifier("final") - object Empty : JavaModifier("") +public sealed class JavaModifier(name: String) : Modifier(name) { + public object Abstract : JavaModifier("abstract") + public object Final : JavaModifier("final") + public object Empty : JavaModifier("") } -interface WithCompanion { - val companion: DObject? +public interface WithCompanion { + public val companion: DObject? } -interface WithConstructors { - val constructors: List<DFunction> +public interface WithConstructors { + public val constructors: List<DFunction> } -interface WithGenerics { - val generics: List<DTypeParameter> +public interface WithGenerics { + public val generics: List<DTypeParameter> } -interface WithSupertypes { - val supertypes: SourceSetDependent<List<TypeConstructorWithKind>> +public interface WithSupertypes { + public val supertypes: SourceSetDependent<List<TypeConstructorWithKind>> } -interface WithIsExpectActual { - val isExpectActual: Boolean +public interface WithIsExpectActual { + public val isExpectActual: Boolean } -interface Callable : WithVisibility, WithType, WithAbstraction, WithSources, WithIsExpectActual { - val receiver: DParameter? +public interface Callable : WithVisibility, WithType, WithAbstraction, WithSources, WithIsExpectActual { + public val receiver: DParameter? } -sealed class DClasslike : Documentable(), WithScope, WithVisibility, WithSources, WithIsExpectActual +public sealed class DClasslike : Documentable(), WithScope, WithVisibility, WithSources, WithIsExpectActual -data class DModule( +public data class DModule( override val name: String, val packages: List<DPackage>, override val documentation: SourceSetDependent<DocumentationNode>, @@ -107,10 +110,10 @@ data class DModule( override val children: List<Documentable> get() = packages - override fun withNewExtras(newExtras: PropertyContainer<DModule>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DModule>): DModule = copy(extra = newExtras) } -data class DPackage( +public data class DPackage( override val dri: DRI, override val functions: List<DFunction>, override val properties: List<DProperty>, @@ -134,10 +137,10 @@ data class DPackage( override val children: List<Documentable> = properties + functions + classlikes + typealiases - override fun withNewExtras(newExtras: PropertyContainer<DPackage>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DPackage>): DPackage = copy(extra = newExtras) } -data class DClass( +public data class DClass( override val dri: DRI, override val name: String, override val constructors: List<DFunction>, @@ -161,10 +164,10 @@ data class DClass( override val children: List<Documentable> get() = (functions + properties + classlikes + constructors) - override fun withNewExtras(newExtras: PropertyContainer<DClass>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DClass>): DClass = copy(extra = newExtras) } -data class DEnum( +public data class DEnum( override val dri: DRI, override val name: String, val entries: List<DEnumEntry>, @@ -185,10 +188,10 @@ data class DEnum( override val children: List<Documentable> get() = (entries + functions + properties + classlikes + constructors) - override fun withNewExtras(newExtras: PropertyContainer<DEnum>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DEnum>): DEnum = copy(extra = newExtras) } -data class DEnumEntry( +public data class DEnumEntry( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent<DocumentationNode>, @@ -202,10 +205,10 @@ data class DEnumEntry( override val children: List<Documentable> get() = (functions + properties + classlikes) - override fun withNewExtras(newExtras: PropertyContainer<DEnumEntry>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DEnumEntry>): DEnumEntry = copy(extra = newExtras) } -data class DFunction( +public data class DFunction( override val dri: DRI, override val name: String, val isConstructor: Boolean, @@ -225,10 +228,10 @@ data class DFunction( override val children: List<Documentable> get() = parameters - override fun withNewExtras(newExtras: PropertyContainer<DFunction>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DFunction>): DFunction = copy(extra = newExtras) } -data class DInterface( +public data class DInterface( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent<DocumentationNode>, @@ -248,10 +251,10 @@ data class DInterface( override val children: List<Documentable> get() = (functions + properties + classlikes) - override fun withNewExtras(newExtras: PropertyContainer<DInterface>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DInterface>): DInterface = copy(extra = newExtras) } -data class DObject( +public data class DObject( override val name: String?, override val dri: DRI, override val documentation: SourceSetDependent<DocumentationNode>, @@ -269,10 +272,10 @@ data class DObject( override val children: List<Documentable> get() = (functions + properties + classlikes) - override fun withNewExtras(newExtras: PropertyContainer<DObject>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DObject>): DObject = copy(extra = newExtras) } -data class DAnnotation( +public data class DAnnotation( override val name: String, override val dri: DRI, override val documentation: SourceSetDependent<DocumentationNode>, @@ -292,10 +295,10 @@ data class DAnnotation( override val children: List<Documentable> get() = (functions + properties + classlikes + constructors) - override fun withNewExtras(newExtras: PropertyContainer<DAnnotation>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DAnnotation>): DAnnotation = copy(extra = newExtras) } -data class DProperty( +public data class DProperty( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent<DocumentationNode>, @@ -315,11 +318,11 @@ data class DProperty( override val children: List<Nothing> get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer<DProperty>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DProperty>): DProperty = copy(extra = newExtras) } // TODO: treat named Parameters and receivers differently -data class DParameter( +public data class DParameter( override val dri: DRI, override val name: String?, override val documentation: SourceSetDependent<DocumentationNode>, @@ -331,10 +334,10 @@ data class DParameter( override val children: List<Nothing> get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer<DParameter>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DParameter>): DParameter = copy(extra = newExtras) } -data class DTypeParameter( +public data class DTypeParameter( val variantTypeParameter: Variance<TypeParameter>, override val documentation: SourceSetDependent<DocumentationNode>, override val expectPresentInSet: DokkaSourceSet?, @@ -343,7 +346,7 @@ data class DTypeParameter( override val extra: PropertyContainer<DTypeParameter> = PropertyContainer.empty() ) : Documentable(), WithExtraProperties<DTypeParameter> { - constructor( + public constructor( dri: DRI, name: String, presentableName: String?, @@ -367,10 +370,10 @@ data class DTypeParameter( override val children: List<Nothing> get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer<DTypeParameter>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DTypeParameter>): DTypeParameter = copy(extra = newExtras) } -data class DTypeAlias( +public data class DTypeAlias( override val dri: DRI, override val name: String, override val type: Bound, @@ -386,12 +389,12 @@ data class DTypeAlias( override val children: List<Nothing> get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer<DTypeAlias>) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer<DTypeAlias>): DTypeAlias = copy(extra = newExtras) } -sealed class Projection -sealed class Bound : Projection() -data class TypeParameter( +public sealed class Projection +public sealed class Bound : Projection() +public data class TypeParameter( val dri: DRI, val name: String, val presentableName: String? = null, @@ -401,13 +404,13 @@ data class TypeParameter( copy(extra = extra) } -sealed class TypeConstructor : Bound(), AnnotationTarget { - abstract val dri: DRI - abstract val projections: List<Projection> - abstract val presentableName: String? +public sealed class TypeConstructor : Bound(), AnnotationTarget { + public abstract val dri: DRI + public abstract val projections: List<Projection> + public abstract val presentableName: String? } -data class GenericTypeConstructor( +public data class GenericTypeConstructor( override val dri: DRI, override val projections: List<Projection>, override val presentableName: String? = null, @@ -417,7 +420,7 @@ data class GenericTypeConstructor( copy(extra = newExtras) } -data class FunctionalTypeConstructor( +public data class FunctionalTypeConstructor( override val dri: DRI, override val projections: List<Projection>, val isExtensionFunction: Boolean = false, @@ -430,7 +433,7 @@ data class FunctionalTypeConstructor( } // kotlin.annotation.AnnotationTarget.TYPEALIAS -data class TypeAliased( +public data class TypeAliased( val typeAlias: Bound, val inner: Bound, override val extra: PropertyContainer<TypeAliased> = PropertyContainer.empty() @@ -439,7 +442,7 @@ data class TypeAliased( copy(extra = newExtras) } -data class PrimitiveJavaType( +public data class PrimitiveJavaType( val name: String, override val extra: PropertyContainer<PrimitiveJavaType> = PropertyContainer.empty() ) : Bound(), AnnotationTarget, WithExtraProperties<PrimitiveJavaType> { @@ -447,13 +450,13 @@ data class PrimitiveJavaType( copy(extra = newExtras) } -data class JavaObject(override val extra: PropertyContainer<JavaObject> = PropertyContainer.empty()) : +public data class JavaObject(override val extra: PropertyContainer<JavaObject> = PropertyContainer.empty()) : Bound(), AnnotationTarget, WithExtraProperties<JavaObject> { override fun withNewExtras(newExtras: PropertyContainer<JavaObject>): JavaObject = copy(extra = newExtras) } -data class UnresolvedBound( +public data class UnresolvedBound( val name: String, override val extra: PropertyContainer<UnresolvedBound> = PropertyContainer.empty() ) : Bound(), AnnotationTarget, WithExtraProperties<UnresolvedBound> { @@ -462,66 +465,67 @@ data class UnresolvedBound( } // The following Projections are not AnnotationTargets; they cannot be annotated. -data class Nullable(val inner: Bound) : Bound() +public data class Nullable(val inner: Bound) : Bound() /** * It introduces [definitely non-nullable types](https://github.com/Kotlin/KEEP/blob/c72601cf35c1e95a541bb4b230edb474a6d1d1a8/proposals/definitely-non-nullable-types.md) */ -data class DefinitelyNonNullable(val inner: Bound) : Bound() +public data class DefinitelyNonNullable(val inner: Bound) : Bound() -sealed class Variance<out T : Bound> : Projection() { - abstract val inner: T +public sealed class Variance<out T : Bound> : Projection() { + public abstract val inner: T } -data class Covariance<out T : Bound>(override val inner: T) : Variance<T>() { - override fun toString() = "out" +public data class Covariance<out T : Bound>(override val inner: T) : Variance<T>() { + override fun toString(): String = "out" } -data class Contravariance<out T : Bound>(override val inner: T) : Variance<T>() { - override fun toString() = "in" +public data class Contravariance<out T : Bound>(override val inner: T) : Variance<T>() { + override fun toString(): String = "in" } -data class Invariance<out T : Bound>(override val inner: T) : Variance<T>() { - override fun toString() = "" +public data class Invariance<out T : Bound>(override val inner: T) : Variance<T>() { + override fun toString(): String = "" } -object Star : Projection() +public object Star : Projection() -object Void : Bound() -object Dynamic : Bound() +public object Void : Bound() +public object Dynamic : Bound() -fun Variance<TypeParameter>.withDri(dri: DRI) = when (this) { +public fun Variance<TypeParameter>.withDri(dri: DRI): Variance<TypeParameter> = when (this) { is Contravariance -> Contravariance(TypeParameter(dri, inner.name, inner.presentableName)) is Covariance -> Covariance(TypeParameter(dri, inner.name, inner.presentableName)) is Invariance -> Invariance(TypeParameter(dri, inner.name, inner.presentableName)) } -fun Documentable.dfs(predicate: (Documentable) -> Boolean): Documentable? = +public fun Documentable.dfs(predicate: (Documentable) -> Boolean): Documentable? = if (predicate(this)) { this } else { this.children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull() } -sealed class Visibility(val name: String) -sealed class KotlinVisibility(name: String) : Visibility(name) { - object Public : KotlinVisibility("public") - object Private : KotlinVisibility("private") - object Protected : KotlinVisibility("protected") - object Internal : KotlinVisibility("internal") +public sealed class Visibility(public val name: String) + +public sealed class KotlinVisibility(name: String) : Visibility(name) { + public object Public : KotlinVisibility("public") + public object Private : KotlinVisibility("private") + public object Protected : KotlinVisibility("protected") + public object Internal : KotlinVisibility("internal") } -sealed class JavaVisibility(name: String) : Visibility(name) { - object Public : JavaVisibility("public") - object Private : JavaVisibility("private") - object Protected : JavaVisibility("protected") - object Default : JavaVisibility("") +public sealed class JavaVisibility(name: String) : Visibility(name) { + public object Public : JavaVisibility("public") + public object Private : JavaVisibility("private") + public object Protected : JavaVisibility("protected") + public object Default : JavaVisibility("") } -fun <T> SourceSetDependent<T>?.orEmpty(): SourceSetDependent<T> = this ?: emptyMap() +public fun <T> SourceSetDependent<T>?.orEmpty(): SourceSetDependent<T> = this ?: emptyMap() -interface DocumentableSource { - val path: String +public interface DocumentableSource { + public val path: String /** * Computes the first line number of the documentable's declaration/signature/identifier. @@ -530,7 +534,7 @@ interface DocumentableSource { * * May return null if the sources could not be found - for example, for synthetic/generated declarations. */ - fun computeLineNumber(): Int? + public fun computeLineNumber(): Int? } -data class TypeConstructorWithKind(val typeConstructor: TypeConstructor, val kind: ClassKind) +public data class TypeConstructorWithKind(val typeConstructor: TypeConstructor, val kind: ClassKind) diff --git a/core/src/main/kotlin/model/JvmField.kt b/core/src/main/kotlin/model/JvmField.kt index 38829ef5..a2b641c9 100644 --- a/core/src/main/kotlin/model/JvmField.kt +++ b/core/src/main/kotlin/model/JvmField.kt @@ -6,9 +6,9 @@ package org.jetbrains.dokka.model import org.jetbrains.dokka.links.DRI -const val JVM_FIELD_PACKAGE_NAME = "kotlin.jvm" -const val JVM_FIELD_CLASS_NAMES = "JvmField" +public const val JVM_FIELD_PACKAGE_NAME: String = "kotlin.jvm" +public const val JVM_FIELD_CLASS_NAMES: String = "JvmField" -fun DRI.isJvmField(): Boolean = packageName == JVM_FIELD_PACKAGE_NAME && classNames == JVM_FIELD_CLASS_NAMES +public fun DRI.isJvmField(): Boolean = packageName == JVM_FIELD_PACKAGE_NAME && classNames == JVM_FIELD_CLASS_NAMES -fun Annotations.Annotation.isJvmField(): Boolean = dri.isJvmField() +public fun Annotations.Annotation.isJvmField(): Boolean = dri.isJvmField() diff --git a/core/src/main/kotlin/model/WithChildren.kt b/core/src/main/kotlin/model/WithChildren.kt index 01e69fd0..f73a5aa0 100644 --- a/core/src/main/kotlin/model/WithChildren.kt +++ b/core/src/main/kotlin/model/WithChildren.kt @@ -4,39 +4,39 @@ package org.jetbrains.dokka.model -interface WithChildren<out T> { - val children: List<T> +public interface WithChildren<out T> { + public val children: List<T> } -inline fun <reified T> WithChildren<*>.firstChildOfTypeOrNull(): T? = +public inline fun <reified T> WithChildren<*>.firstChildOfTypeOrNull(): T? = children.filterIsInstance<T>().firstOrNull() -inline fun <reified T> WithChildren<*>.firstChildOfTypeOrNull(predicate: (T) -> Boolean): T? = +public inline fun <reified T> WithChildren<*>.firstChildOfTypeOrNull(predicate: (T) -> Boolean): T? = children.filterIsInstance<T>().firstOrNull(predicate) -inline fun <reified T> WithChildren<*>.firstChildOfType(): T = +public inline fun <reified T> WithChildren<*>.firstChildOfType(): T = children.filterIsInstance<T>().first() -inline fun <reified T> WithChildren<*>.childrenOfType(): List<T> = +public inline fun <reified T> WithChildren<*>.childrenOfType(): List<T> = children.filterIsInstance<T>() -inline fun <reified T> WithChildren<*>.firstChildOfType(predicate: (T) -> Boolean): T = +public inline fun <reified T> WithChildren<*>.firstChildOfType(predicate: (T) -> Boolean): T = children.filterIsInstance<T>().first(predicate) -inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType(): T where T : WithChildren<*> { +public inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType(): T where T : WithChildren<*> { return withDescendants().filterIsInstance<T>().first() } -inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType( +public inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType( predicate: (T) -> Boolean ): T where T : WithChildren<*> = withDescendants().filterIsInstance<T>().first(predicate) -inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfTypeOrNull(): T? where T : WithChildren<*> { +public inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfTypeOrNull(): T? where T : WithChildren<*> { return withDescendants().filterIsInstance<T>().firstOrNull() } -fun <T> T.withDescendants(): Sequence<T> where T : WithChildren<T> { +public fun <T> T.withDescendants(): Sequence<T> where T : WithChildren<T> { return sequence { yield(this@withDescendants) children.forEach { child -> @@ -46,7 +46,7 @@ fun <T> T.withDescendants(): Sequence<T> where T : WithChildren<T> { } @JvmName("withDescendantsProjection") -fun WithChildren<*>.withDescendants(): Sequence<Any?> { +public fun WithChildren<*>.withDescendants(): Sequence<Any?> { return sequence { yield(this@withDescendants) children.forEach { child -> @@ -58,7 +58,7 @@ fun WithChildren<*>.withDescendants(): Sequence<Any?> { } @JvmName("withDescendantsAny") -fun WithChildren<Any>.withDescendants(): Sequence<Any> { +public fun WithChildren<Any>.withDescendants(): Sequence<Any> { return sequence { yield(this@withDescendants) children.forEach { child -> @@ -69,13 +69,13 @@ fun WithChildren<Any>.withDescendants(): Sequence<Any> { } } -fun <T> T.dfs(predicate: (T) -> Boolean): T? where T : WithChildren<T> = if (predicate(this)) { +public fun <T> T.dfs(predicate: (T) -> Boolean): T? where T : WithChildren<T> = if (predicate(this)) { this } else { children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull() } -fun <T : WithChildren<T>> T.asPrintableTree( +public fun <T : WithChildren<T>> T.asPrintableTree( nodeNameBuilder: Appendable.(T) -> Unit = { append(it.toString()) } ): String { fun Appendable.append(element: T, ownPrefix: String, childPrefix: String) { diff --git a/core/src/main/kotlin/model/additionalExtras.kt b/core/src/main/kotlin/model/additionalExtras.kt index 64c1e315..1db8e59d 100644 --- a/core/src/main/kotlin/model/additionalExtras.kt +++ b/core/src/main/kotlin/model/additionalExtras.kt @@ -8,8 +8,11 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy -class AdditionalModifiers(val content: SourceSetDependent<Set<ExtraModifiers>>) : ExtraProperty<Documentable> { - companion object : ExtraProperty.Key<Documentable, AdditionalModifiers> { +public class AdditionalModifiers( + public val content: SourceSetDependent<Set<ExtraModifiers>> +) : ExtraProperty<Documentable> { + + public companion object : ExtraProperty.Key<Documentable, AdditionalModifiers> { override fun mergeStrategyFor( left: AdditionalModifiers, right: AdditionalModifiers @@ -19,23 +22,23 @@ class AdditionalModifiers(val content: SourceSetDependent<Set<ExtraModifiers>>) override fun equals(other: Any?): Boolean = if (other is AdditionalModifiers) other.content == content else false - override fun hashCode() = content.hashCode() + override fun hashCode(): Int = content.hashCode() override val key: ExtraProperty.Key<Documentable, *> = AdditionalModifiers } -fun SourceSetDependent<Set<ExtraModifiers>>.toAdditionalModifiers() = AdditionalModifiers(this) +public fun SourceSetDependent<Set<ExtraModifiers>>.toAdditionalModifiers(): AdditionalModifiers = AdditionalModifiers(this) -data class Annotations( +public data class Annotations( private val myContent: SourceSetDependent<List<Annotation>> ) : ExtraProperty<AnnotationTarget> { - companion object : ExtraProperty.Key<AnnotationTarget, Annotations> { + public companion object : ExtraProperty.Key<AnnotationTarget, Annotations> { override fun mergeStrategyFor(left: Annotations, right: Annotations): MergeStrategy<AnnotationTarget> = MergeStrategy.Replace(Annotations(left.myContent + right.myContent)) } override val key: ExtraProperty.Key<AnnotationTarget, *> = Annotations - data class Annotation( + public data class Annotation( val dri: DRI, val params: Map<String, AnnotationParameterValue>, val mustBeDocumented: Boolean = false, @@ -64,51 +67,60 @@ data class Annotations( else Pair(key, withoutFileLevel) }.toMap() - enum class AnnotationScope { + public enum class AnnotationScope { DIRECT, FILE, GETTER, SETTER } } -fun SourceSetDependent<List<Annotations.Annotation>>.toAnnotations() = Annotations(this) +public fun SourceSetDependent<List<Annotations.Annotation>>.toAnnotations(): Annotations = Annotations(this) + +public sealed class AnnotationParameterValue + +public data class AnnotationValue(val annotation: Annotations.Annotation) : AnnotationParameterValue() + +public data class ArrayValue(val value: List<AnnotationParameterValue>) : AnnotationParameterValue() + +public data class EnumValue(val enumName: String, val enumDri: DRI) : AnnotationParameterValue() + +public data class ClassValue(val className: String, val classDRI: DRI) : AnnotationParameterValue() -sealed class AnnotationParameterValue -data class AnnotationValue(val annotation: Annotations.Annotation) : AnnotationParameterValue() -data class ArrayValue(val value: List<AnnotationParameterValue>) : AnnotationParameterValue() -data class EnumValue(val enumName: String, val enumDri: DRI) : AnnotationParameterValue() -data class ClassValue(val className: String, val classDRI: DRI) : AnnotationParameterValue() -abstract class LiteralValue : AnnotationParameterValue() { - abstract fun text() : String +public abstract class LiteralValue : AnnotationParameterValue() { + public abstract fun text() : String } -data class IntValue(val value: Int) : LiteralValue() { +public data class IntValue(val value: Int) : LiteralValue() { override fun text(): String = value.toString() } -data class LongValue(val value: Long) : LiteralValue() { +public data class LongValue(val value: Long) : LiteralValue() { override fun text(): String = value.toString() } -data class FloatValue(val value: Float) : LiteralValue() { + +public data class FloatValue(val value: Float) : LiteralValue() { override fun text(): String = value.toString() } -data class DoubleValue(val value: Double) : LiteralValue() { + +public data class DoubleValue(val value: Double) : LiteralValue() { override fun text(): String = value.toString() } -object NullValue : LiteralValue() { + +public object NullValue : LiteralValue() { override fun text(): String = "null" } -data class BooleanValue(val value: Boolean) : LiteralValue() { + +public data class BooleanValue(val value: Boolean) : LiteralValue() { override fun text(): String = value.toString() } -data class StringValue(val value: String) : LiteralValue() { + +public data class StringValue(val value: String) : LiteralValue() { override fun text(): String = value override fun toString(): String = value } - -object PrimaryConstructorExtra : ExtraProperty<DFunction>, ExtraProperty.Key<DFunction, PrimaryConstructorExtra> { +public object PrimaryConstructorExtra : ExtraProperty<DFunction>, ExtraProperty.Key<DFunction, PrimaryConstructorExtra> { override val key: ExtraProperty.Key<DFunction, *> = this } -data class ActualTypealias( +public data class ActualTypealias( val typeAlias: DTypeAlias ) : ExtraProperty<DClasslike> { @@ -117,11 +129,11 @@ data class ActualTypealias( val underlyingType: SourceSetDependent<Bound> get() = typeAlias.underlyingType - companion object : ExtraProperty.Key<DClasslike, ActualTypealias> { + public companion object : ExtraProperty.Key<DClasslike, ActualTypealias> { override fun mergeStrategyFor( left: ActualTypealias, right: ActualTypealias - ) = MergeStrategy.Fail { + ): MergeStrategy<DClasslike> = MergeStrategy.Fail { throw IllegalStateException("Adding [ActualTypealias] should be after merging all documentables") } } diff --git a/core/src/main/kotlin/model/ancestryNode.kt b/core/src/main/kotlin/model/ancestryNode.kt index da469eec..7203ab18 100644 --- a/core/src/main/kotlin/model/ancestryNode.kt +++ b/core/src/main/kotlin/model/ancestryNode.kt @@ -4,12 +4,12 @@ package org.jetbrains.dokka.model -data class AncestryNode( +public data class AncestryNode( val typeConstructor: TypeConstructor, val superclass: AncestryNode?, val interfaces: List<AncestryNode>, ) { - fun allImplementedInterfaces(): List<TypeConstructor> { + public fun allImplementedInterfaces(): List<TypeConstructor> { fun traverseInterfaces(ancestry: AncestryNode): List<TypeConstructor> = ancestry.interfaces.flatMap { listOf(it.typeConstructor) + traverseInterfaces(it) } + (ancestry.superclass?.let(::traverseInterfaces) ?: emptyList()) diff --git a/core/src/main/kotlin/model/classKinds.kt b/core/src/main/kotlin/model/classKinds.kt index 7c9461cc..25256022 100644 --- a/core/src/main/kotlin/model/classKinds.kt +++ b/core/src/main/kotlin/model/classKinds.kt @@ -4,9 +4,9 @@ package org.jetbrains.dokka.model -interface ClassKind +public interface ClassKind -enum class KotlinClassKindTypes : ClassKind { +public enum class KotlinClassKindTypes : ClassKind { CLASS, INTERFACE, ENUM_CLASS, @@ -15,7 +15,7 @@ enum class KotlinClassKindTypes : ClassKind { OBJECT; } -enum class JavaClassKindTypes : ClassKind { +public enum class JavaClassKindTypes : ClassKind { CLASS, INTERFACE, ENUM_CLASS, diff --git a/core/src/main/kotlin/model/defaultValues.kt b/core/src/main/kotlin/model/defaultValues.kt index 6d4b2ac0..426954fb 100644 --- a/core/src/main/kotlin/model/defaultValues.kt +++ b/core/src/main/kotlin/model/defaultValues.kt @@ -7,12 +7,15 @@ package org.jetbrains.dokka.model import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy -class DefaultValue(val expression: SourceSetDependent<Expression>): ExtraProperty<Documentable> { +public class DefaultValue( + public val expression: SourceSetDependent<Expression> +): ExtraProperty<Documentable> { @Deprecated("Use `expression` property that depends on source set", ReplaceWith("this.expression.values.first()")) - val value: Expression + public val value: Expression get() = expression.values.first() - companion object : ExtraProperty.Key<Documentable, DefaultValue> { + + public companion object : ExtraProperty.Key<Documentable, DefaultValue> { override fun mergeStrategyFor(left: DefaultValue, right: DefaultValue): MergeStrategy<Documentable> = MergeStrategy.Replace(DefaultValue(left.expression + right.expression)) @@ -22,10 +25,10 @@ class DefaultValue(val expression: SourceSetDependent<Expression>): ExtraPropert get() = Companion } -interface Expression -data class ComplexExpression(val value: String) : Expression -data class IntegerConstant(val value: Long) : Expression -data class StringConstant(val value: String) : Expression -data class DoubleConstant(val value: Double) : Expression -data class FloatConstant(val value: Float) : Expression -data class BooleanConstant(val value: Boolean) : Expression +public interface Expression +public data class ComplexExpression(val value: String) : Expression +public data class IntegerConstant(val value: Long) : Expression +public data class StringConstant(val value: String) : Expression +public data class DoubleConstant(val value: Double) : Expression +public data class FloatConstant(val value: Float) : Expression +public data class BooleanConstant(val value: Boolean) : Expression diff --git a/core/src/main/kotlin/model/doc/DocTag.kt b/core/src/main/kotlin/model/doc/DocTag.kt index ead64774..f4cb9b33 100644 --- a/core/src/main/kotlin/model/doc/DocTag.kt +++ b/core/src/main/kotlin/model/doc/DocTag.kt @@ -7,363 +7,366 @@ package org.jetbrains.dokka.model.doc import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.WithChildren -sealed class DocTag : WithChildren<DocTag> { - abstract val params: Map<String, String> +public sealed class DocTag : WithChildren<DocTag> { + public abstract val params: Map<String, String> - companion object { - fun contentTypeParam(type: String): Map<String, String> = mapOf("content-type" to type) + public companion object { + public fun contentTypeParam(type: String): Map<String, String> = mapOf("content-type" to type) } } -data class A( +public data class A( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Big( +public data class Big( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class B( +public data class B( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class BlockQuote( +public data class BlockQuote( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -object Br : DocTag() { - override val params = emptyMap<String, String>() - override val children = emptyList<DocTag>() +public object Br : DocTag() { + override val children: List<DocTag> = emptyList() + override val params: Map<String, String> = emptyMap() } -data class Cite( +public data class Cite( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -sealed class Code : DocTag() +public sealed class Code : DocTag() -data class CodeInline( +public data class CodeInline( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : Code() -data class CodeBlock( +public data class CodeBlock( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : Code() -data class CustomDocTag( +public data class CustomDocTag( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap(), val name: String ) : DocTag() -data class Dd( +public data class Dd( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Dfn( +public data class Dfn( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Dir( +public data class Dir( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Div( +public data class Div( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Dl( +public data class Dl( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class DocumentationLink( +public data class DocumentationLink( val dri: DRI, override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Dt( +public data class Dt( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Em( +public data class Em( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Font( +public data class Font( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Footer( +public data class Footer( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Frame( +public data class Frame( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class FrameSet( +public data class FrameSet( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class H1( +public data class H1( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class H2( +public data class H2( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class H3( +public data class H3( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class H4( +public data class H4( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class H5( +public data class H5( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class H6( +public data class H6( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Head( +public data class Head( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Header( +public data class Header( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -object HorizontalRule : DocTag() { - override val params = emptyMap<String, String>() - override val children = emptyList<DocTag>() +public object HorizontalRule : DocTag() { + override val children: List<DocTag> = emptyList() + override val params: Map<String, String> = emptyMap() } -data class Html( +public data class Html( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class I( +public data class I( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class IFrame( +public data class IFrame( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Img( +public data class Img( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Index( +public data class Index( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Input( +public data class Input( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Li( +public data class Li( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Link( +public data class Link( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Listing( +public data class Listing( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Main( +public data class Main( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Menu( +public data class Menu( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Meta( +public data class Meta( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Nav( +public data class Nav( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class NoFrames( +public data class NoFrames( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class NoScript( +public data class NoScript( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Ol( +public data class Ol( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class P( +public data class P( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Pre( +public data class Pre( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Script( +public data class Script( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Section( +public data class Section( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Small( +public data class Small( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Span( +public data class Span( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Strikethrough( +public data class Strikethrough( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Strong( +public data class Strong( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Sub( +public data class Sub( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Sup( +public data class Sup( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Table( +public data class Table( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Text( +public data class Text( val body: String = "", override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class TBody( +public data class TBody( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Td( +public data class Td( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class TFoot( +public data class TFoot( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Th( +public data class Th( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class THead( +public data class THead( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Title( +public data class Title( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Tr( +public data class Tr( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Tt( +public data class Tt( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class U(override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap()) : - DocTag() +public data class U( + override val children: List<DocTag> = emptyList(), + override val params: Map<String, String> = emptyMap() +) : DocTag() -data class Ul( +public data class Ul( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Var( +public data class Var( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() -data class Caption( +public data class Caption( override val children: List<DocTag> = emptyList(), override val params: Map<String, String> = emptyMap() ) : DocTag() + diff --git a/core/src/main/kotlin/model/doc/DocumentationNode.kt b/core/src/main/kotlin/model/doc/DocumentationNode.kt index 1066d941..9c270f79 100644 --- a/core/src/main/kotlin/model/doc/DocumentationNode.kt +++ b/core/src/main/kotlin/model/doc/DocumentationNode.kt @@ -6,4 +6,4 @@ package org.jetbrains.dokka.model.doc import org.jetbrains.dokka.model.WithChildren -data class DocumentationNode(override val children: List<TagWrapper>): WithChildren<TagWrapper> +public data class DocumentationNode(override val children: List<TagWrapper>): WithChildren<TagWrapper> diff --git a/core/src/main/kotlin/model/doc/TagWrapper.kt b/core/src/main/kotlin/model/doc/TagWrapper.kt index 45a0b61a..e3eaffb7 100644 --- a/core/src/main/kotlin/model/doc/TagWrapper.kt +++ b/core/src/main/kotlin/model/doc/TagWrapper.kt @@ -7,29 +7,30 @@ package org.jetbrains.dokka.model.doc import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.WithChildren -sealed class TagWrapper : WithChildren<DocTag> { - abstract val root: DocTag +public sealed class TagWrapper : WithChildren<DocTag> { + public abstract val root: DocTag + override val children: List<DocTag> get() = root.children } -sealed class NamedTagWrapper : TagWrapper() { - abstract val name: String +public sealed class NamedTagWrapper : TagWrapper() { + public abstract val name: String } -data class Description(override val root: DocTag) : TagWrapper() -data class Author(override val root: DocTag) : TagWrapper() -data class Version(override val root: DocTag) : TagWrapper() -data class Since(override val root: DocTag) : TagWrapper() -data class See(override val root: DocTag, override val name: String, val address: DRI?) : NamedTagWrapper() -data class Param(override val root: DocTag, override val name: String) : NamedTagWrapper() -data class Return(override val root: DocTag) : TagWrapper() -data class Receiver(override val root: DocTag) : TagWrapper() -data class Constructor(override val root: DocTag) : TagWrapper() +public data class Description(override val root: DocTag) : TagWrapper() +public data class Author(override val root: DocTag) : TagWrapper() +public data class Version(override val root: DocTag) : TagWrapper() +public data class Since(override val root: DocTag) : TagWrapper() +public data class See(override val root: DocTag, override val name: String, val address: DRI?) : NamedTagWrapper() +public data class Param(override val root: DocTag, override val name: String) : NamedTagWrapper() +public data class Return(override val root: DocTag) : TagWrapper() +public data class Receiver(override val root: DocTag) : TagWrapper() +public data class Constructor(override val root: DocTag) : TagWrapper() //TODO this naming is confusing since kotlin has Throws annotation -data class Throws(override val root: DocTag, override val name: String, val exceptionAddress: DRI?) : NamedTagWrapper() -data class Sample(override val root: DocTag, override val name: String) : NamedTagWrapper() -data class Deprecated(override val root: DocTag) : TagWrapper() -data class Property(override val root: DocTag, override val name: String) : NamedTagWrapper() -data class Suppress(override val root: DocTag) : TagWrapper() -data class CustomTagWrapper(override val root: DocTag, override val name: String) : NamedTagWrapper() +public data class Throws(override val root: DocTag, override val name: String, val exceptionAddress: DRI?) : NamedTagWrapper() +public data class Sample(override val root: DocTag, override val name: String) : NamedTagWrapper() +public data class Deprecated(override val root: DocTag) : TagWrapper() +public data class Property(override val root: DocTag, override val name: String) : NamedTagWrapper() +public data class Suppress(override val root: DocTag) : TagWrapper() +public data class CustomTagWrapper(override val root: DocTag, override val name: String) : NamedTagWrapper() diff --git a/core/src/main/kotlin/model/documentableProperties.kt b/core/src/main/kotlin/model/documentableProperties.kt index dc6456f8..b0ebb6ef 100644 --- a/core/src/main/kotlin/model/documentableProperties.kt +++ b/core/src/main/kotlin/model/documentableProperties.kt @@ -9,37 +9,37 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy -data class InheritedMember(val inheritedFrom: SourceSetDependent<DRI?>) : ExtraProperty<Documentable> { - companion object : ExtraProperty.Key<Documentable, InheritedMember> { - override fun mergeStrategyFor(left: InheritedMember, right: InheritedMember) = MergeStrategy.Replace( +public data class InheritedMember(val inheritedFrom: SourceSetDependent<DRI?>) : ExtraProperty<Documentable> { + public companion object : ExtraProperty.Key<Documentable, InheritedMember> { + override fun mergeStrategyFor(left: InheritedMember, right: InheritedMember): MergeStrategy<Documentable> = MergeStrategy.Replace( InheritedMember(left.inheritedFrom + right.inheritedFrom) ) } - fun isInherited(sourceSetDependent: DokkaSourceSet): Boolean = inheritedFrom[sourceSetDependent] != null + public fun isInherited(sourceSetDependent: DokkaSourceSet): Boolean = inheritedFrom[sourceSetDependent] != null override val key: ExtraProperty.Key<Documentable, *> = InheritedMember } -data class ImplementedInterfaces(val interfaces: SourceSetDependent<List<TypeConstructor>>) : ExtraProperty<Documentable> { - companion object : ExtraProperty.Key<Documentable, ImplementedInterfaces> { - override fun mergeStrategyFor(left: ImplementedInterfaces, right: ImplementedInterfaces) = +public data class ImplementedInterfaces(val interfaces: SourceSetDependent<List<TypeConstructor>>) : ExtraProperty<Documentable> { + public companion object : ExtraProperty.Key<Documentable, ImplementedInterfaces> { + override fun mergeStrategyFor(left: ImplementedInterfaces, right: ImplementedInterfaces): MergeStrategy<Documentable> = MergeStrategy.Replace(ImplementedInterfaces(left.interfaces + right.interfaces)) } override val key: ExtraProperty.Key<Documentable, *> = ImplementedInterfaces } -data class ExceptionInSupertypes(val exceptions: SourceSetDependent<List<TypeConstructor>>): ExtraProperty<Documentable> { - companion object : ExtraProperty.Key<Documentable, ExceptionInSupertypes> { - override fun mergeStrategyFor(left: ExceptionInSupertypes, right: ExceptionInSupertypes) = +public data class ExceptionInSupertypes(val exceptions: SourceSetDependent<List<TypeConstructor>>): ExtraProperty<Documentable> { + public companion object : ExtraProperty.Key<Documentable, ExceptionInSupertypes> { + override fun mergeStrategyFor(left: ExceptionInSupertypes, right: ExceptionInSupertypes): MergeStrategy<Documentable> = MergeStrategy.Replace(ExceptionInSupertypes(left.exceptions + right.exceptions)) } override val key: ExtraProperty.Key<Documentable, *> = ExceptionInSupertypes } -object ObviousMember : ExtraProperty<Documentable>, ExtraProperty.Key<Documentable, ObviousMember> { +public object ObviousMember : ExtraProperty<Documentable>, ExtraProperty.Key<Documentable, ObviousMember> { override val key: ExtraProperty.Key<Documentable, *> = this } @@ -49,12 +49,12 @@ object ObviousMember : ExtraProperty<Documentable>, ExtraProperty.Key<Documentab * In case of properties that came from `Java`, [IsVar] is added if * the java field has no accessors at all (plain field) or has a setter */ -object IsVar : ExtraProperty<DProperty>, ExtraProperty.Key<DProperty, IsVar> { +public object IsVar : ExtraProperty<DProperty>, ExtraProperty.Key<DProperty, IsVar> { override val key: ExtraProperty.Key<DProperty, *> = this } -data class IsAlsoParameter(val inSourceSets: List<DokkaSourceSet>) : ExtraProperty<DProperty> { - companion object : ExtraProperty.Key<DProperty, IsAlsoParameter> { +public data class IsAlsoParameter(val inSourceSets: List<DokkaSourceSet>) : ExtraProperty<DProperty> { + public companion object : ExtraProperty.Key<DProperty, IsAlsoParameter> { override fun mergeStrategyFor(left: IsAlsoParameter, right: IsAlsoParameter): MergeStrategy<DProperty> = MergeStrategy.Replace(IsAlsoParameter(left.inSourceSets + right.inSourceSets)) } @@ -62,9 +62,9 @@ data class IsAlsoParameter(val inSourceSets: List<DokkaSourceSet>) : ExtraProper override val key: ExtraProperty.Key<DProperty, *> = IsAlsoParameter } -data class CheckedExceptions(val exceptions: SourceSetDependent<List<DRI>>) : ExtraProperty<Documentable>, ExtraProperty.Key<Documentable, ObviousMember> { - companion object : ExtraProperty.Key<Documentable, CheckedExceptions> { - override fun mergeStrategyFor(left: CheckedExceptions, right: CheckedExceptions) = +public data class CheckedExceptions(val exceptions: SourceSetDependent<List<DRI>>) : ExtraProperty<Documentable>, ExtraProperty.Key<Documentable, ObviousMember> { + public companion object : ExtraProperty.Key<Documentable, CheckedExceptions> { + override fun mergeStrategyFor(left: CheckedExceptions, right: CheckedExceptions): MergeStrategy<Documentable> = MergeStrategy.Replace(CheckedExceptions(left.exceptions + right.exceptions)) } override val key: ExtraProperty.Key<Documentable, *> = CheckedExceptions diff --git a/core/src/main/kotlin/model/documentableUtils.kt b/core/src/main/kotlin/model/documentableUtils.kt index 5f08a2ce..c9d75bf4 100644 --- a/core/src/main/kotlin/model/documentableUtils.kt +++ b/core/src/main/kotlin/model/documentableUtils.kt @@ -6,10 +6,10 @@ package org.jetbrains.dokka.model import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet -fun <T> SourceSetDependent<T>.filtered(sourceSets: Set<DokkaSourceSet>) = filter { it.key in sourceSets } -fun DokkaSourceSet?.filtered(sourceSets: Set<DokkaSourceSet>) = takeIf { this in sourceSets } +public fun <T> SourceSetDependent<T>.filtered(sourceSets: Set<DokkaSourceSet>): SourceSetDependent<T> = filter { it.key in sourceSets } +public fun DokkaSourceSet?.filtered(sourceSets: Set<DokkaSourceSet>): DokkaSourceSet? = takeIf { this in sourceSets } -fun DTypeParameter.filter(filteredSet: Set<DokkaSourceSet>) = +public fun DTypeParameter.filter(filteredSet: Set<DokkaSourceSet>): DTypeParameter? = if (filteredSet.containsAll(sourceSets)) this else { val intersection = filteredSet.intersect(sourceSets) @@ -24,4 +24,4 @@ fun DTypeParameter.filter(filteredSet: Set<DokkaSourceSet>) = ) } -fun Documentable.isExtension() = this is Callable && receiver != null +public fun Documentable.isExtension(): Boolean = this is Callable && receiver != null diff --git a/core/src/main/kotlin/model/extraModifiers.kt b/core/src/main/kotlin/model/extraModifiers.kt index 4eb2a01b..f1193070 100644 --- a/core/src/main/kotlin/model/extraModifiers.kt +++ b/core/src/main/kotlin/model/extraModifiers.kt @@ -4,40 +4,40 @@ package org.jetbrains.dokka.model -sealed class ExtraModifiers(val name: String) { +public sealed class ExtraModifiers(public val name: String) { - sealed class KotlinOnlyModifiers(name: String) : ExtraModifiers(name) { - object Inline : KotlinOnlyModifiers("inline") - object Value : KotlinOnlyModifiers("value") - object Infix : KotlinOnlyModifiers("infix") - object External : KotlinOnlyModifiers("external") - object Suspend : KotlinOnlyModifiers("suspend") - object Reified : KotlinOnlyModifiers("reified") - object CrossInline : KotlinOnlyModifiers("crossinline") - object NoInline : KotlinOnlyModifiers("noinline") - object Override : KotlinOnlyModifiers("override") - object Data : KotlinOnlyModifiers("data") - object Const : KotlinOnlyModifiers("const") - object Inner : KotlinOnlyModifiers("inner") - object LateInit : KotlinOnlyModifiers("lateinit") - object Operator : KotlinOnlyModifiers("operator") - object TailRec : KotlinOnlyModifiers("tailrec") - object VarArg : KotlinOnlyModifiers("vararg") - object Fun : KotlinOnlyModifiers("fun") + public sealed class KotlinOnlyModifiers(name: String) : ExtraModifiers(name) { + public object Inline : KotlinOnlyModifiers("inline") + public object Value : KotlinOnlyModifiers("value") + public object Infix : KotlinOnlyModifiers("infix") + public object External : KotlinOnlyModifiers("external") + public object Suspend : KotlinOnlyModifiers("suspend") + public object Reified : KotlinOnlyModifiers("reified") + public object CrossInline : KotlinOnlyModifiers("crossinline") + public object NoInline : KotlinOnlyModifiers("noinline") + public object Override : KotlinOnlyModifiers("override") + public object Data : KotlinOnlyModifiers("data") + public object Const : KotlinOnlyModifiers("const") + public object Inner : KotlinOnlyModifiers("inner") + public object LateInit : KotlinOnlyModifiers("lateinit") + public object Operator : KotlinOnlyModifiers("operator") + public object TailRec : KotlinOnlyModifiers("tailrec") + public object VarArg : KotlinOnlyModifiers("vararg") + public object Fun : KotlinOnlyModifiers("fun") } - sealed class JavaOnlyModifiers(name: String) : ExtraModifiers(name) { - object Static : JavaOnlyModifiers("static") - object Native : JavaOnlyModifiers("native") - object Synchronized : JavaOnlyModifiers("synchronized") - object StrictFP : JavaOnlyModifiers("strictfp") - object Transient : JavaOnlyModifiers("transient") - object Volatile : JavaOnlyModifiers("volatile") - object Transitive : JavaOnlyModifiers("transitive") + public sealed class JavaOnlyModifiers(name: String) : ExtraModifiers(name) { + public object Static : JavaOnlyModifiers("static") + public object Native : JavaOnlyModifiers("native") + public object Synchronized : JavaOnlyModifiers("synchronized") + public object StrictFP : JavaOnlyModifiers("strictfp") + public object Transient : JavaOnlyModifiers("transient") + public object Volatile : JavaOnlyModifiers("volatile") + public object Transitive : JavaOnlyModifiers("transitive") } - companion object { - fun valueOf(str: String) = when (str) { + public companion object { + public fun valueOf(str: String): ExtraModifiers = when (str) { "inline" -> KotlinOnlyModifiers.Inline "value" -> KotlinOnlyModifiers.Value "infix" -> KotlinOnlyModifiers.Infix diff --git a/core/src/main/kotlin/model/jvmName.kt b/core/src/main/kotlin/model/jvmName.kt index 67df9148..8fd7ccd9 100644 --- a/core/src/main/kotlin/model/jvmName.kt +++ b/core/src/main/kotlin/model/jvmName.kt @@ -6,6 +6,6 @@ package org.jetbrains.dokka.model import org.jetbrains.dokka.links.DRI -fun DRI.isJvmName(): Boolean = packageName == "kotlin.jvm" && classNames == "JvmName" +public fun DRI.isJvmName(): Boolean = packageName == "kotlin.jvm" && classNames == "JvmName" -fun Annotations.Annotation.isJvmName(): Boolean = dri.isJvmName() +public fun Annotations.Annotation.isJvmName(): Boolean = dri.isJvmName() diff --git a/core/src/main/kotlin/model/properties/PropertyContainer.kt b/core/src/main/kotlin/model/properties/PropertyContainer.kt index 24577bd5..7f5bb2f0 100644 --- a/core/src/main/kotlin/model/properties/PropertyContainer.kt +++ b/core/src/main/kotlin/model/properties/PropertyContainer.kt @@ -4,43 +4,44 @@ package org.jetbrains.dokka.model.properties -data class PropertyContainer<C : Any> internal constructor( +public data class PropertyContainer<C : Any> internal constructor( @PublishedApi internal val map: Map<ExtraProperty.Key<C, *>, ExtraProperty<C>> ) { - operator fun <D : C> plus(prop: ExtraProperty<D>): PropertyContainer<D> = + public operator fun <D : C> plus(prop: ExtraProperty<D>): PropertyContainer<D> = PropertyContainer(map + (prop.key to prop)) // TODO: Add logic for caching calculated properties - inline operator fun <reified T : Any> get(key: ExtraProperty.Key<C, T>): T? = when (val prop = map[key]) { + public inline operator fun <reified T : Any> get(key: ExtraProperty.Key<C, T>): T? = when (val prop = map[key]) { is T? -> prop else -> throw ClassCastException("Property for $key stored under not matching key type.") } - inline fun <reified T : Any> allOfType(): List<T> = map.values.filterIsInstance<T>() - fun <D : C> addAll(extras: Collection<ExtraProperty<D>>): PropertyContainer<D> = + public inline fun <reified T : Any> allOfType(): List<T> = map.values.filterIsInstance<T>() + + public fun <D : C> addAll(extras: Collection<ExtraProperty<D>>): PropertyContainer<D> = PropertyContainer(map + extras.map { p -> p.key to p }) - operator fun <D : C> minus(prop: ExtraProperty.Key<C, *>): PropertyContainer<D> = + public operator fun <D : C> minus(prop: ExtraProperty.Key<C, *>): PropertyContainer<D> = PropertyContainer(map.filterNot { it.key == prop }) - companion object { - fun <T : Any> empty(): PropertyContainer<T> = PropertyContainer(emptyMap()) - fun <T : Any> withAll(vararg extras: ExtraProperty<T>?) = empty<T>().addAll(extras.filterNotNull()) - fun <T : Any> withAll(extras: Collection<ExtraProperty<T>>) = empty<T>().addAll(extras) + public companion object { + public fun <T : Any> empty(): PropertyContainer<T> = PropertyContainer(emptyMap()) + public fun <T : Any> withAll(vararg extras: ExtraProperty<T>?): PropertyContainer<T> = empty<T>().addAll(extras.filterNotNull()) + public fun <T : Any> withAll(extras: Collection<ExtraProperty<T>>): PropertyContainer<T> = empty<T>().addAll(extras) } } -operator fun <D: Any> PropertyContainer<D>.plus(prop: ExtraProperty<D>?): PropertyContainer<D> = +public operator fun <D: Any> PropertyContainer<D>.plus(prop: ExtraProperty<D>?): PropertyContainer<D> = if (prop == null) this else PropertyContainer(map + (prop.key to prop)) -interface WithExtraProperties<C : Any> { - val extra: PropertyContainer<C> +public interface WithExtraProperties<C : Any> { + public val extra: PropertyContainer<C> - fun withNewExtras(newExtras: PropertyContainer<C>): C + public fun withNewExtras(newExtras: PropertyContainer<C>): C } -fun <C> C.mergeExtras(left: C, right: C): C where C : Any, C : WithExtraProperties<C> { +public fun <C> C.mergeExtras(left: C, right: C): C where C : Any, C : WithExtraProperties<C> { val aggregatedExtras: List<List<ExtraProperty<C>>> = (left.extra.map.values + right.extra.map.values) .groupBy { it.key } diff --git a/core/src/main/kotlin/model/properties/properties.kt b/core/src/main/kotlin/model/properties/properties.kt index e15a1668..ea76dc72 100644 --- a/core/src/main/kotlin/model/properties/properties.kt +++ b/core/src/main/kotlin/model/properties/properties.kt @@ -4,23 +4,33 @@ package org.jetbrains.dokka.model.properties -interface ExtraProperty<in C : Any> { - interface Key<in C : Any, T : Any> { - fun mergeStrategyFor(left: T, right: T): MergeStrategy<C> = MergeStrategy.Fail { +public interface ExtraProperty<in C : Any> { + public interface Key<in C : Any, T : Any> { + public fun mergeStrategyFor(left: T, right: T): MergeStrategy<C> = MergeStrategy.Fail { throw NotImplementedError("Property merging for $this is not implemented") } } - val key: Key<C, *> + public val key: Key<C, *> } -interface CalculatedProperty<in C : Any, T : Any> : ExtraProperty.Key<C, T> { - fun calculate(subject: C): T +public interface CalculatedProperty<in C : Any, T : Any> : ExtraProperty.Key<C, T> { + public fun calculate(subject: C): T } -sealed class MergeStrategy<in C> { - class Replace<in C : Any>(val newProperty: ExtraProperty<C>) : MergeStrategy<C>() - object Remove : MergeStrategy<Any>() - class Full<C : Any>(val merger: (preMerged: C, left: C, right: C) -> C) : MergeStrategy<C>() - class Fail(val error: () -> Nothing) : MergeStrategy<Any>() +public sealed class MergeStrategy<in C> { + + public class Replace<in C : Any>( + public val newProperty: ExtraProperty<C> + ) : MergeStrategy<C>() + + public object Remove : MergeStrategy<Any>() + + public class Full<C : Any>( + public val merger: (preMerged: C, left: C, right: C) -> C + ) : MergeStrategy<C>() + + public class Fail( + public val error: () -> Nothing + ) : MergeStrategy<Any>() } diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt index 87178277..96f43205 100644 --- a/core/src/main/kotlin/pages/ContentNodes.kt +++ b/core/src/main/kotlin/pages/ContentNodes.kt @@ -10,25 +10,25 @@ import org.jetbrains.dokka.model.WithChildren import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.model.properties.WithExtraProperties -data class DCI(val dri: Set<DRI>, val kind: Kind) { - override fun toString() = "$dri[$kind]" +public data class DCI(val dri: Set<DRI>, val kind: Kind) { + override fun toString(): String = "$dri[$kind]" } -interface ContentNode : WithExtraProperties<ContentNode>, WithChildren<ContentNode> { - val dci: DCI - val sourceSets: Set<DisplaySourceSet> - val style: Set<Style> +public interface ContentNode : WithExtraProperties<ContentNode>, WithChildren<ContentNode> { + public val dci: DCI + public val sourceSets: Set<DisplaySourceSet> + public val style: Set<Style> - fun hasAnyContent(): Boolean + public fun hasAnyContent(): Boolean - fun withSourceSets(sourceSets: Set<DisplaySourceSet>): ContentNode + public fun withSourceSets(sourceSets: Set<DisplaySourceSet>): ContentNode override val children: List<ContentNode> get() = emptyList() } /** Simple text */ -data class ContentText( +public data class ContentText( val text: String, override val dci: DCI, override val sourceSets: Set<DisplaySourceSet>, @@ -40,7 +40,7 @@ data class ContentText( override fun hasAnyContent(): Boolean = text.isNotBlank() } -data class ContentBreakLine( +public data class ContentBreakLine( override val sourceSets: Set<DisplaySourceSet>, override val dci: DCI = DCI(emptySet(), ContentKind.Empty), override val style: Set<Style> = emptySet(), @@ -52,7 +52,7 @@ data class ContentBreakLine( } /** Headers */ -data class ContentHeader( +public data class ContentHeader( override val children: List<ContentNode>, val level: Int, override val dci: DCI, @@ -60,7 +60,7 @@ data class ContentHeader( override val style: Set<Style>, override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty() ) : ContentComposite { - constructor(level: Int, c: ContentComposite) : this(c.children, level, c.dci, c.sourceSets, c.style, c.extra) + public constructor(level: Int, c: ContentComposite) : this(c.children, level, c.dci, c.sourceSets, c.style, c.extra) override fun withNewExtras(newExtras: PropertyContainer<ContentNode>): ContentHeader = copy(extra = newExtras) @@ -71,10 +71,10 @@ data class ContentHeader( copy(sourceSets = sourceSets) } -interface ContentCode : ContentComposite +public interface ContentCode : ContentComposite /** Code blocks */ -data class ContentCodeBlock( +public data class ContentCodeBlock( override val children: List<ContentNode>, val language: String, override val dci: DCI, @@ -92,7 +92,7 @@ data class ContentCodeBlock( } -data class ContentCodeInline( +public data class ContentCodeInline( override val children: List<ContentNode>, val language: String, override val dci: DCI, @@ -111,10 +111,10 @@ data class ContentCodeInline( } /** Union type replacement */ -interface ContentLink : ContentComposite +public interface ContentLink : ContentComposite /** All links to classes, packages, etc. that have te be resolved */ -data class ContentDRILink( +public data class ContentDRILink( override val children: List<ContentNode>, val address: DRI, override val dci: DCI, @@ -133,7 +133,7 @@ data class ContentDRILink( } /** All links that do not need to be resolved */ -data class ContentResolvedLink( +public data class ContentResolvedLink( override val children: List<ContentNode>, val address: String, override val dci: DCI, @@ -152,7 +152,7 @@ data class ContentResolvedLink( } /** Embedded resources like images */ -data class ContentEmbeddedResource( +public data class ContentEmbeddedResource( override val children: List<ContentNode> = emptyList(), val address: String, val altText: String?, @@ -172,18 +172,18 @@ data class ContentEmbeddedResource( } /** Logical grouping of [ContentNode]s */ -interface ContentComposite : ContentNode { +public interface ContentComposite : ContentNode { override val children: List<ContentNode> // overwrite to make it abstract once again override val sourceSets: Set<DisplaySourceSet> get() = children.flatMap { it.sourceSets }.toSet() - fun transformChildren(transformer: (ContentNode) -> ContentNode): ContentComposite + public fun transformChildren(transformer: (ContentNode) -> ContentNode): ContentComposite override fun hasAnyContent(): Boolean = children.any { it.hasAnyContent() } } /** Tables */ -data class ContentTable( +public data class ContentTable( val header: List<ContentGroup>, val caption: ContentGroup? = null, override val children: List<ContentGroup>, @@ -203,7 +203,7 @@ data class ContentTable( } /** Lists */ -data class ContentList( +public data class ContentList( override val children: List<ContentNode>, val ordered: Boolean, override val dci: DCI, @@ -221,7 +221,7 @@ data class ContentList( } /** Default group, eg. for blocks of Functions, Properties, etc. **/ -data class ContentGroup( +public data class ContentGroup( override val children: List<ContentNode>, override val dci: DCI, override val sourceSets: Set<DisplaySourceSet>, @@ -240,7 +240,7 @@ data class ContentGroup( /** * @property groupID is used for finding and copying [ContentDivergentInstance]s when merging [ContentPage]s */ -data class ContentDivergentGroup( +public data class ContentDivergentGroup( override val children: List<ContentDivergentInstance>, override val dci: DCI, override val style: Set<Style>, @@ -248,7 +248,7 @@ data class ContentDivergentGroup( val groupID: GroupID, val implicitlySourceSetHinted: Boolean = true ) : ContentComposite { - data class GroupID(val name: String) + public data class GroupID(val name: String) override val sourceSets: Set<DisplaySourceSet> get() = children.flatMap { it.sourceSets }.distinct().toSet() @@ -263,7 +263,7 @@ data class ContentDivergentGroup( } /** Instance of a divergent content */ -data class ContentDivergentInstance( +public data class ContentDivergentInstance( val before: ContentNode?, val divergent: ContentNode, val after: ContentNode?, @@ -290,11 +290,11 @@ data class ContentDivergentInstance( } -data class PlatformHintedContent( +public data class PlatformHintedContent( val inner: ContentNode, override val sourceSets: Set<DisplaySourceSet> ) : ContentComposite { - override val children = listOf(inner) + override val children: List<ContentNode> = listOf(inner) override val dci: DCI get() = inner.dci @@ -305,7 +305,7 @@ data class PlatformHintedContent( override val style: Set<Style> get() = inner.style - override fun withNewExtras(newExtras: PropertyContainer<ContentNode>) = + override fun withNewExtras(newExtras: PropertyContainer<ContentNode>): ContentNode = throw UnsupportedOperationException("This method should not be called on this PlatformHintedContent") override fun transformChildren(transformer: (ContentNode) -> ContentNode): PlatformHintedContent = @@ -316,14 +316,14 @@ data class PlatformHintedContent( } -interface Style -interface Kind +public interface Style +public interface Kind /** * [ContentKind] represents a grouping of content of one kind that can can be rendered * as part of a composite page (one tab/block within a class's page, for instance). */ -enum class ContentKind : Kind { +public enum class ContentKind : Kind { /** * Marks all sorts of signatures. Can contain sub-kinds marked as [SymbolContentKind] @@ -344,7 +344,7 @@ enum class ContentKind : Kind { */ Deprecation; - companion object { + public companion object { private val platformTagged = setOf( Constructors, @@ -358,14 +358,14 @@ enum class ContentKind : Kind { Extensions ) - fun shouldBePlatformTagged(kind: Kind): Boolean = kind in platformTagged + public fun shouldBePlatformTagged(kind: Kind): Boolean = kind in platformTagged } } /** * Content kind for [ContentKind.Symbol] content, which is essentially about signatures */ -enum class SymbolContentKind : Kind { +public enum class SymbolContentKind : Kind { /** * Marks constructor/function parameters, everything in-between parentheses. * @@ -385,17 +385,17 @@ enum class SymbolContentKind : Kind { Parameter, } -enum class TokenStyle : Style { +public enum class TokenStyle : Style { Keyword, Punctuation, Function, Operator, Annotation, Number, String, Boolean, Constant } -enum class TextStyle : Style { +public enum class TextStyle : Style { Bold, Italic, Strong, Strikethrough, Paragraph, Block, Span, Monospace, Indented, Cover, UnderCoverText, BreakableAfter, Breakable, InlineComment, Quotation, FloatingRight, Var, Underlined } -enum class ContentStyle : Style { +public enum class ContentStyle : Style { RowTitle, /** * The style is used only for HTML. It is applied only for [ContentGroup]. @@ -407,7 +407,7 @@ enum class ContentStyle : Style { Wrapped, Indented, KDocTag, Footnote } -enum class ListStyle : Style { +public enum class ListStyle : Style { /** * Represents a list of groups of [DescriptionTerm] and [DescriptionDetails]. * Common uses for this element are to implement a glossary or to display @@ -429,8 +429,8 @@ enum class ListStyle : Style { DescriptionDetails } -object CommentTable : Style +public object CommentTable : Style -object MultimoduleTable : Style +public object MultimoduleTable : Style -fun ContentNode.hasStyle(style: Style) = this.style.contains(style) +public fun ContentNode.hasStyle(style: Style): Boolean = this.style.contains(style) diff --git a/core/src/main/kotlin/pages/PageNodes.kt b/core/src/main/kotlin/pages/PageNodes.kt index 8233464c..cfaf2347 100644 --- a/core/src/main/kotlin/pages/PageNodes.kt +++ b/core/src/main/kotlin/pages/PageNodes.kt @@ -9,28 +9,28 @@ import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.WithChildren import java.util.* -interface PageNode : WithChildren<PageNode> { - val name: String +public interface PageNode : WithChildren<PageNode> { + public val name: String override val children: List<PageNode> - fun modified( + public fun modified( name: String = this.name, children: List<PageNode> = this.children ): PageNode } -interface ContentPage : PageNode { - val content: ContentNode - val dri: Set<DRI> - val embeddedResources: List<String> +public interface ContentPage : PageNode { + public val content: ContentNode + public val dri: Set<DRI> + public val embeddedResources: List<String> @Deprecated("Deprecated. Remove its usages from your code.", ReplaceWith("this.documentables.firstOrNull()") ) - val documentable: Documentable? + public val documentable: Documentable? get() = if (this is WithDocumentables) this.documentables.firstOrNull() else null - fun modified( + public fun modified( name: String = this.name, content: ContentNode = this.content, dri: Set<DRI> = this.dri, @@ -39,12 +39,14 @@ interface ContentPage : PageNode { ): ContentPage } -interface WithDocumentables { - val documentables: List<Documentable> +public interface WithDocumentables { + public val documentables: List<Documentable> } -abstract class RootPageNode(val forceTopLevelName: Boolean = false) : PageNode { - val parentMap: Map<PageNode, PageNode> by lazy { +public abstract class RootPageNode( + public val forceTopLevelName: Boolean = false +) : PageNode { + public val parentMap: Map<PageNode, PageNode> by lazy { IdentityHashMap<PageNode, PageNode>().apply { fun process(parent: PageNode) { parent.children.forEach { child -> @@ -56,10 +58,10 @@ abstract class RootPageNode(val forceTopLevelName: Boolean = false) : PageNode { } } - fun transformPageNodeTree(operation: (PageNode) -> PageNode) = + public fun transformPageNodeTree(operation: (PageNode) -> PageNode): RootPageNode = this.transformNode(operation) as RootPageNode - fun transformContentPagesTree(operation: (ContentPage) -> ContentPage) = transformPageNodeTree { + public fun transformContentPagesTree(operation: (ContentPage) -> ContentPage): RootPageNode = transformPageNodeTree { if (it is ContentPage) operation(it) else it } @@ -74,7 +76,7 @@ abstract class RootPageNode(val forceTopLevelName: Boolean = false) : PageNode { ): RootPageNode } -class ModulePageNode( +public class ModulePageNode( override val name: String, override val content: ContentNode, override val documentables: List<Documentable> = listOf(), @@ -97,7 +99,7 @@ class ModulePageNode( else ModulePageNode(name, content, documentables, children, embeddedResources) } -class PackagePageNode( +public class PackagePageNode( override val name: String, override val content: ContentNode, override val dri: Set<DRI>, @@ -124,7 +126,7 @@ class PackagePageNode( else PackagePageNode(name, content, dri, documentables, children, embeddedResources) } -class ClasslikePageNode( +public class ClasslikePageNode( override val name: String, override val content: ContentNode, override val dri: Set<DRI>, @@ -146,7 +148,7 @@ class ClasslikePageNode( else ClasslikePageNode(name, content, dri, documentables, children, embeddedResources) } -class MemberPageNode( +public class MemberPageNode( override val name: String, override val content: ContentNode, override val dri: Set<DRI>, @@ -169,12 +171,12 @@ class MemberPageNode( } -class MultimoduleRootPageNode( +public class MultimoduleRootPageNode( override val dri: Set<DRI>, override val content: ContentNode, override val embeddedResources: List<String> = emptyList() ) : RootPageNode(forceTopLevelName = true), MultimoduleRootPage { - override val name = "All modules" + override val name: String = "All modules" override val children: List<PageNode> = emptyList() @@ -187,12 +189,12 @@ class MultimoduleRootPageNode( dri: Set<DRI>, embeddedResources: List<String>, children: List<PageNode> - ) = + ): ContentPage = if (name == this.name && content === this.content && embeddedResources === this.embeddedResources && children shallowEq this.children) this else MultimoduleRootPageNode(dri, content, embeddedResources) } -inline fun <reified T : PageNode> PageNode.children() = children.filterIsInstance<T>() +public inline fun <reified T : PageNode> PageNode.children(): List<T> = children.filterIsInstance<T>() private infix fun <T> List<T>.shallowEq(other: List<T>) = this === other || (this.size == other.size && (this zip other).all { (a, b) -> a === b }) diff --git a/core/src/main/kotlin/pages/Pages.kt b/core/src/main/kotlin/pages/Pages.kt index ae305de7..0bf225c9 100644 --- a/core/src/main/kotlin/pages/Pages.kt +++ b/core/src/main/kotlin/pages/Pages.kt @@ -4,12 +4,12 @@ package org.jetbrains.dokka.pages -interface MultimoduleRootPage : ContentPage +public interface MultimoduleRootPage : ContentPage -interface ModulePage : ContentPage, WithDocumentables +public interface ModulePage : ContentPage, WithDocumentables -interface PackagePage : ContentPage, WithDocumentables +public interface PackagePage : ContentPage, WithDocumentables -interface ClasslikePage : ContentPage, WithDocumentables +public interface ClasslikePage : ContentPage, WithDocumentables -interface MemberPage : ContentPage, WithDocumentables +public interface MemberPage : ContentPage, WithDocumentables diff --git a/core/src/main/kotlin/pages/RendererSpecificPage.kt b/core/src/main/kotlin/pages/RendererSpecificPage.kt index c8661ae5..701886b7 100644 --- a/core/src/main/kotlin/pages/RendererSpecificPage.kt +++ b/core/src/main/kotlin/pages/RendererSpecificPage.kt @@ -9,14 +9,14 @@ import org.jetbrains.dokka.model.DisplaySourceSet import org.jetbrains.dokka.renderers.Renderer import kotlin.reflect.KClass -fun interface DriResolver: (DRI, Set<DisplaySourceSet>) -> String? -fun interface PageResolver: (PageNode, PageNode?) -> String? +public fun interface DriResolver: (DRI, Set<DisplaySourceSet>) -> String? +public fun interface PageResolver: (PageNode, PageNode?) -> String? -interface RendererSpecificPage : PageNode { - val strategy: RenderingStrategy +public interface RendererSpecificPage : PageNode { + public val strategy: RenderingStrategy } -class RendererSpecificRootPage( +public class RendererSpecificRootPage( override val name: String, override val children: List<PageNode>, override val strategy: RenderingStrategy @@ -25,7 +25,7 @@ class RendererSpecificRootPage( RendererSpecificRootPage(name, children, strategy) } -class RendererSpecificResourcePage( +public class RendererSpecificResourcePage( override val name: String, override val children: List<PageNode>, override val strategy: RenderingStrategy @@ -34,18 +34,19 @@ class RendererSpecificResourcePage( RendererSpecificResourcePage(name, children, strategy) } -sealed class RenderingStrategy { - class Callback(val instructions: Renderer.(PageNode) -> String): RenderingStrategy() - data class Copy(val from: String) : RenderingStrategy() - data class Write(val text: String) : RenderingStrategy() - data class DriLocationResolvableWrite(val contentToResolve: (DriResolver) -> String) : RenderingStrategy() - data class PageLocationResolvableWrite(val contentToResolve: (PageResolver) -> String) : RenderingStrategy() - object DoNothing : RenderingStrategy() - - companion object { - inline operator fun <reified T: Renderer> invoke(crossinline instructions: T.(PageNode) -> String) = - Callback { if (this is T) instructions(it) else throw WrongRendererTypeException(T::class) } +public sealed class RenderingStrategy { + public class Callback(public val instructions: Renderer.(PageNode) -> String): RenderingStrategy() + public data class Copy(val from: String) : RenderingStrategy() + public data class Write(val text: String) : RenderingStrategy() + public data class DriLocationResolvableWrite(val contentToResolve: (DriResolver) -> String) : RenderingStrategy() + public data class PageLocationResolvableWrite(val contentToResolve: (PageResolver) -> String) : RenderingStrategy() + public object DoNothing : RenderingStrategy() + + public companion object { + public inline operator fun <reified T: Renderer> invoke(crossinline instructions: T.(PageNode) -> String): RenderingStrategy { + return Callback { if (this is T) instructions(it) else throw WrongRendererTypeException(T::class) } + } } } -data class WrongRendererTypeException(val expectedType: KClass<*>): Exception() +public data class WrongRendererTypeException(val expectedType: KClass<*>): Exception() diff --git a/core/src/main/kotlin/pages/contentNodeProperties.kt b/core/src/main/kotlin/pages/contentNodeProperties.kt index 0a400165..64f19572 100644 --- a/core/src/main/kotlin/pages/contentNodeProperties.kt +++ b/core/src/main/kotlin/pages/contentNodeProperties.kt @@ -6,29 +6,32 @@ package org.jetbrains.dokka.pages import org.jetbrains.dokka.model.properties.ExtraProperty -class SimpleAttr(val extraKey: String, val extraValue: String) : ExtraProperty<ContentNode> { - data class SimpleAttrKey(val key: String) : ExtraProperty.Key<ContentNode, SimpleAttr> +public class SimpleAttr( + public val extraKey: String, + public val extraValue: String +) : ExtraProperty<ContentNode> { + public data class SimpleAttrKey(val key: String) : ExtraProperty.Key<ContentNode, SimpleAttr> override val key: ExtraProperty.Key<ContentNode, SimpleAttr> = SimpleAttrKey(extraKey) } -enum class BasicTabbedContentType : TabbedContentType { +public enum class BasicTabbedContentType : TabbedContentType { TYPE, CONSTRUCTOR, FUNCTION, PROPERTY, ENTRY, EXTENSION_PROPERTY, EXTENSION_FUNCTION } /** * It is used only to mark content for tabs in HTML format */ -interface TabbedContentType +public interface TabbedContentType /** * @see TabbedContentType */ -class TabbedContentTypeExtra(val value: TabbedContentType) : ExtraProperty<ContentNode> { - companion object : ExtraProperty.Key<ContentNode, TabbedContentTypeExtra> +public class TabbedContentTypeExtra(public val value: TabbedContentType) : ExtraProperty<ContentNode> { + public companion object : ExtraProperty.Key<ContentNode, TabbedContentTypeExtra> override val key: ExtraProperty.Key<ContentNode, TabbedContentTypeExtra> = TabbedContentTypeExtra } -object HtmlContent : ExtraProperty<ContentNode>, ExtraProperty.Key<ContentNode, HtmlContent> { +public object HtmlContent : ExtraProperty<ContentNode>, ExtraProperty.Key<ContentNode, HtmlContent> { override val key: ExtraProperty.Key<ContentNode, *> = this } diff --git a/core/src/main/kotlin/pages/utils.kt b/core/src/main/kotlin/pages/utils.kt index 6aa0b5f7..6c416e24 100644 --- a/core/src/main/kotlin/pages/utils.kt +++ b/core/src/main/kotlin/pages/utils.kt @@ -6,10 +6,10 @@ package org.jetbrains.dokka.pages import kotlin.reflect.KClass -inline fun <reified T : ContentNode, R : ContentNode> R.mapTransform(noinline operation: (T) -> T): R = +public inline fun <reified T : ContentNode, R : ContentNode> R.mapTransform(noinline operation: (T) -> T): R = mapTransform(T::class, operation) -inline fun <reified T : ContentNode, R : ContentNode> R.recursiveMapTransform(noinline operation: (T) -> T): R = +public inline fun <reified T : ContentNode, R : ContentNode> R.recursiveMapTransform(noinline operation: (T) -> T): R = recursiveMapTransform(T::class, operation) @PublishedApi diff --git a/core/src/main/kotlin/plugability/DefaultExtensions.kt b/core/src/main/kotlin/plugability/DefaultExtensions.kt deleted file mode 100644 index 4dd61777..00000000 --- a/core/src/main/kotlin/plugability/DefaultExtensions.kt +++ /dev/null @@ -1,4 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - diff --git a/core/src/main/kotlin/plugability/DokkaContext.kt b/core/src/main/kotlin/plugability/DokkaContext.kt index faf5f0c1..1287e58b 100644 --- a/core/src/main/kotlin/plugability/DokkaContext.kt +++ b/core/src/main/kotlin/plugability/DokkaContext.kt @@ -12,20 +12,20 @@ import java.util.* import kotlin.reflect.KClass import kotlin.reflect.full.createInstance -interface DokkaContext { - fun <T : DokkaPlugin> plugin(kclass: KClass<T>): T? +public interface DokkaContext { + public fun <T : DokkaPlugin> plugin(kclass: KClass<T>): T? - operator fun <T, E> get(point: E): List<T> + public operator fun <T, E> get(point: E): List<T> where T : Any, E : ExtensionPoint<T> - fun <T, E> single(point: E): T where T : Any, E : ExtensionPoint<T> + public fun <T, E> single(point: E): T where T : Any, E : ExtensionPoint<T> - val logger: DokkaLogger - val configuration: DokkaConfiguration - val unusedPoints: Collection<ExtensionPoint<*>> + public val logger: DokkaLogger + public val configuration: DokkaConfiguration + public val unusedPoints: Collection<ExtensionPoint<*>> - companion object { - fun create( + public companion object { + public fun create( configuration: DokkaConfiguration, logger: DokkaLogger, pluginOverrides: List<DokkaPlugin> @@ -44,11 +44,11 @@ interface DokkaContext { } } -inline fun <reified T : DokkaPlugin> DokkaContext.plugin(): T = plugin(T::class) +public inline fun <reified T : DokkaPlugin> DokkaContext.plugin(): T = plugin(T::class) ?: throw java.lang.IllegalStateException("Plugin ${T::class.qualifiedName} is not present in context.") -fun interface DokkaContextConfiguration { - fun installExtension(extension: Extension<*, *, *>) +public fun interface DokkaContextConfiguration { + public fun installExtension(extension: Extension<*, *, *>) } private class DokkaContextConfigurationImpl( diff --git a/core/src/main/kotlin/plugability/DokkaJavaPlugin.kt b/core/src/main/kotlin/plugability/DokkaJavaPlugin.kt index bbea9632..3c2f5e65 100644 --- a/core/src/main/kotlin/plugability/DokkaJavaPlugin.kt +++ b/core/src/main/kotlin/plugability/DokkaJavaPlugin.kt @@ -6,17 +6,19 @@ package org.jetbrains.dokka.plugability import org.jetbrains.dokka.DokkaConfiguration -class ExtensionBuilderStart internal constructor(){ - fun <T: Any> extensionPoint(ext: ExtensionPoint<T>): ProvidedExtension<T> = ProvidedExtension(ext) +public class ExtensionBuilderStart internal constructor(){ + public fun <T: Any> extensionPoint(ext: ExtensionPoint<T>): ProvidedExtension<T> = ProvidedExtension(ext) } -class ProvidedExtension<T: Any> internal constructor(val ext: ExtensionPoint<T>){ - fun fromInstance(inst: T): ExtensionBuilder<T> = createBuilder( +public class ProvidedExtension<T: Any> internal constructor( + public val ext: ExtensionPoint<T> +) { + public fun fromInstance(inst: T): ExtensionBuilder<T> = createBuilder( LazyEvaluated.fromInstance( inst ) ) - fun fromRecipe(recipe: (DokkaContext) -> T): ExtensionBuilder<T> = createBuilder( + public fun fromRecipe(recipe: (DokkaContext) -> T): ExtensionBuilder<T> = createBuilder( LazyEvaluated.fromRecipe(recipe) ) @@ -28,7 +30,7 @@ class ProvidedExtension<T: Any> internal constructor(val ext: ExtensionPoint<T>) OverrideKind.None, emptyList()) } -data class ExtensionBuilder<T: Any> internal constructor( +public data class ExtensionBuilder<T: Any> internal constructor( private val name: String, private val ext: ExtensionPoint<T>, private val action: LazyEvaluated<T>, @@ -37,7 +39,7 @@ data class ExtensionBuilder<T: Any> internal constructor( private val override: OverrideKind = OverrideKind.None, private val conditions: List<(DokkaConfiguration) -> Boolean> ){ - fun build(): Extension<T, *, *> = Extension( + public fun build(): Extension<T, *, *> = Extension( ext, javaClass.name, name, @@ -50,27 +52,27 @@ data class ExtensionBuilder<T: Any> internal constructor( conditions ) - fun overrideExtension(extension: Extension<T, *, *>) = copy(override = OverrideKind.Present(listOf(extension))) + public fun overrideExtension(extension: Extension<T, *, *>): ExtensionBuilder<T> = copy(override = OverrideKind.Present(listOf(extension))) - fun newOrdering(before: Array<out Extension<*, *, *>>, after: Array<out Extension<*, *, *>>) = + public fun newOrdering(before: Array<out Extension<*, *, *>>, after: Array<out Extension<*, *, *>>): ExtensionBuilder<T> = copy(before = this.before + before, after = this.after + after) - fun before(vararg exts: Extension<*, *, *>) = copy(before = this.before + exts) + public fun before(vararg exts: Extension<*, *, *>): ExtensionBuilder<T> = copy(before = this.before + exts) - fun after(vararg exts: Extension<*, *, *>) = copy(after = this.after + exts) + public fun after(vararg exts: Extension<*, *, *>): ExtensionBuilder<T> = copy(after = this.after + exts) - fun addCondition(c: (DokkaConfiguration) -> Boolean) = copy(conditions = conditions + c) + public fun addCondition(c: (DokkaConfiguration) -> Boolean): ExtensionBuilder<T> = copy(conditions = conditions + c) - fun name(name: String) = copy(name = name) + public fun name(name: String): ExtensionBuilder<T> = copy(name = name) } -abstract class DokkaJavaPlugin: DokkaPlugin() { +public abstract class DokkaJavaPlugin: DokkaPlugin() { - fun <T: DokkaPlugin> plugin(clazz: Class<T>): T = + public fun <T: DokkaPlugin> plugin(clazz: Class<T>): T = context?.plugin(clazz.kotlin) ?: throwIllegalQuery() - fun <T: Any> extend(func: (ExtensionBuilderStart) -> ExtensionBuilder<T>): Lazy<Extension<T, *, *>> = + public fun <T: Any> extend(func: (ExtensionBuilderStart) -> ExtensionBuilder<T>): Lazy<Extension<T, *, *>> = lazy { func(ExtensionBuilderStart()).build() }.also { unsafeInstall(it) } } diff --git a/core/src/main/kotlin/plugability/DokkaPlugin.kt b/core/src/main/kotlin/plugability/DokkaPlugin.kt index 521404e2..7e15c325 100644 --- a/core/src/main/kotlin/plugability/DokkaPlugin.kt +++ b/core/src/main/kotlin/plugability/DokkaPlugin.kt @@ -22,16 +22,16 @@ import kotlin.reflect.KProperty1 ) @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.FIELD) @Retention(AnnotationRetention.BINARY) -annotation class DokkaPluginApiPreview +public annotation class DokkaPluginApiPreview /** * Acknowledgement for empty methods that inform users about [DokkaPluginApiPreview] * Also, it allows to not propagates the annotation in IDE by default when a user autogenerate methods. */ @DokkaPluginApiPreview -object PluginApiPreviewAcknowledgement +public object PluginApiPreviewAcknowledgement -abstract class DokkaPlugin { +public abstract class DokkaPlugin { private val extensionDelegates = mutableListOf<KProperty<*>>() private val unsafePlugins = mutableListOf<Lazy<Extension<*, *, *>>>() @@ -47,29 +47,36 @@ abstract class DokkaPlugin { protected abstract fun pluginApiPreviewAcknowledgement(): PluginApiPreviewAcknowledgement protected inline fun <reified T : DokkaPlugin> plugin(): T = context?.plugin(T::class) ?: throwIllegalQuery() - protected fun <T : Any> extensionPoint() = ReadOnlyProperty<DokkaPlugin, ExtensionPoint<T>> { thisRef, property -> - ExtensionPoint( - thisRef::class.qualifiedName ?: throw AssertionError("Plugin must be named class"), - property.name - ) + protected fun <T : Any> extensionPoint(): ReadOnlyProperty<DokkaPlugin, ExtensionPoint<T>> { + return ReadOnlyProperty { thisRef, property -> + ExtensionPoint( + thisRef::class.qualifiedName ?: throw AssertionError("Plugin must be named class"), + property.name + ) + } + } + protected fun <T : Any> extending(definition: ExtendingDSL.() -> Extension<T, *, *>): ExtensionProvider<T> { + return ExtensionProvider(definition) } - protected fun <T : Any> extending(definition: ExtendingDSL.() -> Extension<T, *, *>) = ExtensionProvider(definition) protected class ExtensionProvider<T : Any> internal constructor( private val definition: ExtendingDSL.() -> Extension<T, *, *> ) { - operator fun provideDelegate(thisRef: DokkaPlugin, property: KProperty<*>) = lazy { - ExtendingDSL( - thisRef::class.qualifiedName ?: throw AssertionError("Plugin must be named class"), - property.name - ).definition() - }.also { thisRef.extensionDelegates += property } + public operator fun provideDelegate(thisRef: DokkaPlugin, property: KProperty<*>): Lazy<Extension<T, *, *>> { + return lazy { + ExtendingDSL( + thisRef::class.qualifiedName ?: throw AssertionError("Plugin must be named class"), + property.name + ).definition() + }.also { thisRef.extensionDelegates += property } + } } internal fun internalInstall(ctx: DokkaContextConfiguration, configuration: DokkaConfiguration) { val extensionsToInstall = extensionDelegates.asSequence() .filterIsInstance<KProperty1<DokkaPlugin, Extension<*, *, *>>>() // should be always true .map { it.get(this) } + unsafePlugins.map { it.value } + extensionsToInstall.forEach { if (configuration.(it.condition)()) ctx.installExtension(it) } } @@ -78,22 +85,22 @@ abstract class DokkaPlugin { } } -interface WithUnsafeExtensionSuppression { - val extensionsSuppressed: List<Extension<*, *, *>> +public interface WithUnsafeExtensionSuppression { + public val extensionsSuppressed: List<Extension<*, *, *>> } -interface ConfigurableBlock +public interface ConfigurableBlock -inline fun <reified P : DokkaPlugin, reified E : Any> P.query(extension: P.() -> ExtensionPoint<E>): List<E> = +public inline fun <reified P : DokkaPlugin, reified E : Any> P.query(extension: P.() -> ExtensionPoint<E>): List<E> = context?.let { it[extension()] } ?: throwIllegalQuery() -inline fun <reified P : DokkaPlugin, reified E : Any> P.querySingle(extension: P.() -> ExtensionPoint<E>): E = +public inline fun <reified P : DokkaPlugin, reified E : Any> P.querySingle(extension: P.() -> ExtensionPoint<E>): E = context?.single(extension()) ?: throwIllegalQuery() -fun throwIllegalQuery(): Nothing = +public fun throwIllegalQuery(): Nothing = throw IllegalStateException("Querying about plugins is only possible with dokka context initialised") -inline fun <reified T : DokkaPlugin, reified R : ConfigurableBlock> configuration(context: DokkaContext): R? = +public inline fun <reified T : DokkaPlugin, reified R : ConfigurableBlock> configuration(context: DokkaContext): R? = context.configuration.pluginsConfiguration.firstOrNull { it.fqPluginName == T::class.qualifiedName } ?.let { configuration -> when (configuration.serializationFormat) { diff --git a/core/src/main/kotlin/plugability/extensions.kt b/core/src/main/kotlin/plugability/extensions.kt index 813f81b1..04212d1a 100644 --- a/core/src/main/kotlin/plugability/extensions.kt +++ b/core/src/main/kotlin/plugability/extensions.kt @@ -6,24 +6,29 @@ package org.jetbrains.dokka.plugability import org.jetbrains.dokka.DokkaConfiguration -data class ExtensionPoint<T : Any> internal constructor( +public data class ExtensionPoint<T : Any> internal constructor( internal val pluginClass: String, internal val pointName: String ) { - override fun toString() = "ExtensionPoint: $pluginClass/$pointName" + override fun toString(): String = "ExtensionPoint: $pluginClass/$pointName" } -sealed class OrderingKind { - object None : OrderingKind() - class ByDsl(val block: (OrderDsl.() -> Unit)) : OrderingKind() +public sealed class OrderingKind { + public object None : OrderingKind() + + public class ByDsl( + public val block: (OrderDsl.() -> Unit) + ) : OrderingKind() } -sealed class OverrideKind { - object None : OverrideKind() - class Present(val overriden: List<Extension<*, *, *>>) : OverrideKind() +public sealed class OverrideKind { + public object None : OverrideKind() + public class Present( + public val overriden: List<Extension<*, *, *>> + ) : OverrideKind() } -class Extension<T : Any, Ordering : OrderingKind, Override : OverrideKind> internal constructor( +public class Extension<T : Any, Ordering : OrderingKind, Override : OverrideKind> internal constructor( internal val extensionPoint: ExtensionPoint<T>, internal val pluginClass: String, internal val extensionName: String, @@ -32,15 +37,15 @@ class Extension<T : Any, Ordering : OrderingKind, Override : OverrideKind> inter internal val override: Override, internal val conditions: List<DokkaConfiguration.() -> Boolean> ) { - override fun toString() = "Extension: $pluginClass/$extensionName" + override fun toString(): String = "Extension: $pluginClass/$extensionName" - override fun equals(other: Any?) = + override fun equals(other: Any?): Boolean = if (other is Extension<*, *, *>) this.pluginClass == other.pluginClass && this.extensionName == other.extensionName else false - override fun hashCode() = listOf(pluginClass, extensionName).hashCode() + override fun hashCode(): Int = listOf(pluginClass, extensionName).hashCode() - val condition: DokkaConfiguration.() -> Boolean + public val condition: DokkaConfiguration.() -> Boolean get() = { conditions.all { it(this) } } } @@ -52,44 +57,54 @@ internal fun <T : Any> Extension( ) = Extension(extensionPoint, pluginClass, extensionName, action, OrderingKind.None, OverrideKind.None, emptyList()) @DslMarker -annotation class ExtensionsDsl +public annotation class ExtensionsDsl @ExtensionsDsl -class ExtendingDSL(private val pluginClass: String, private val extensionName: String) { +public class ExtendingDSL(private val pluginClass: String, private val extensionName: String) { - infix fun <T : Any> ExtensionPoint<T>.with(action: T) = - Extension(this, this@ExtendingDSL.pluginClass, extensionName, LazyEvaluated.fromInstance(action)) + public infix fun <T : Any> ExtensionPoint<T>.with(action: T): Extension<T, OrderingKind.None, OverrideKind.None> { + return Extension(this, this@ExtendingDSL.pluginClass, extensionName, LazyEvaluated.fromInstance(action)) + } - infix fun <T : Any> ExtensionPoint<T>.providing(action: (DokkaContext) -> T) = - Extension(this, this@ExtendingDSL.pluginClass, extensionName, LazyEvaluated.fromRecipe(action)) + public infix fun <T : Any> ExtensionPoint<T>.providing(action: (DokkaContext) -> T): Extension<T, OrderingKind.None, OverrideKind.None> { + return Extension(this, this@ExtendingDSL.pluginClass, extensionName, LazyEvaluated.fromRecipe(action)) + } - infix fun <T : Any, Override : OverrideKind> Extension<T, OrderingKind.None, Override>.order( + public infix fun <T : Any, Override : OverrideKind> Extension<T, OrderingKind.None, Override>.order( block: OrderDsl.() -> Unit - ) = Extension(extensionPoint, pluginClass, extensionName, action, OrderingKind.ByDsl(block), override, conditions) + ): Extension<T, OrderingKind.ByDsl, Override> { + return Extension(extensionPoint, pluginClass, extensionName, action, OrderingKind.ByDsl(block), override, conditions) + } - infix fun <T : Any, Override : OverrideKind, Ordering: OrderingKind> Extension<T, Ordering, Override>.applyIf( + public infix fun <T : Any, Override : OverrideKind, Ordering: OrderingKind> Extension<T, Ordering, Override>.applyIf( condition: DokkaConfiguration.() -> Boolean - ) = Extension(extensionPoint, pluginClass, extensionName, action, ordering, override, conditions + condition) + ): Extension<T, Ordering, Override> { + return Extension(extensionPoint, pluginClass, extensionName, action, ordering, override, conditions + condition) + } - infix fun <T : Any, Override : OverrideKind, Ordering: OrderingKind> Extension<T, Ordering, Override>.override( + public infix fun <T : Any, Override : OverrideKind, Ordering: OrderingKind> Extension<T, Ordering, Override>.override( overriden: List<Extension<T, *, *>> - ) = Extension(extensionPoint, pluginClass, extensionName, action, ordering, OverrideKind.Present(overriden), conditions) + ): Extension<T, Ordering, OverrideKind.Present> { + return Extension(extensionPoint, pluginClass, extensionName, action, ordering, OverrideKind.Present(overriden), conditions) + } - infix fun <T : Any, Override : OverrideKind, Ordering: OrderingKind> Extension<T, Ordering, Override>.override( + public infix fun <T : Any, Override : OverrideKind, Ordering: OrderingKind> Extension<T, Ordering, Override>.override( overriden: Extension<T, *, *> - ) = this.override(listOf(overriden)) + ): Extension<T, Ordering, OverrideKind.Present> { + return this.override(listOf(overriden)) + } } @ExtensionsDsl -class OrderDsl { +public class OrderDsl { internal val previous = mutableSetOf<Extension<*, *, *>>() internal val following = mutableSetOf<Extension<*, *, *>>() - fun after(vararg extensions: Extension<*, *, *>) { + public fun after(vararg extensions: Extension<*, *, *>) { previous += extensions } - fun before(vararg extensions: Extension<*, *, *>) { + public fun before(vararg extensions: Extension<*, *, *>) { following += extensions } } diff --git a/core/src/main/kotlin/renderers/PostAction.kt b/core/src/main/kotlin/renderers/PostAction.kt index 046641ab..191a77b3 100644 --- a/core/src/main/kotlin/renderers/PostAction.kt +++ b/core/src/main/kotlin/renderers/PostAction.kt @@ -4,4 +4,4 @@ package org.jetbrains.dokka.renderers -fun interface PostAction : () -> Unit +public fun interface PostAction : () -> Unit diff --git a/core/src/main/kotlin/renderers/Renderer.kt b/core/src/main/kotlin/renderers/Renderer.kt index a4bc3531..f1583506 100644 --- a/core/src/main/kotlin/renderers/Renderer.kt +++ b/core/src/main/kotlin/renderers/Renderer.kt @@ -6,6 +6,6 @@ package org.jetbrains.dokka.renderers import org.jetbrains.dokka.pages.RootPageNode -fun interface Renderer { - fun render(root: RootPageNode) +public fun interface Renderer { + public fun render(root: RootPageNode) } diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt b/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt index 9673f2ff..aff1f763 100644 --- a/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt +++ b/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt @@ -6,6 +6,7 @@ package org.jetbrains.dokka.transformers.documentation import org.jetbrains.dokka.model.DModule -fun interface DocumentableMerger { - operator fun invoke(modules: Collection<DModule>): DModule? +public fun interface DocumentableMerger { + public operator fun invoke(modules: Collection<DModule>): DModule? } + diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt b/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt index fe83be18..ad35ab1d 100644 --- a/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt +++ b/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt @@ -7,6 +7,7 @@ package org.jetbrains.dokka.transformers.documentation import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.RootPageNode -fun interface DocumentableToPageTranslator { - operator fun invoke(module: DModule): RootPageNode +public fun interface DocumentableToPageTranslator { + public operator fun invoke(module: DModule): RootPageNode } + diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt b/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt index 9fdf38ba..f680b9f3 100644 --- a/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt +++ b/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt @@ -7,6 +7,6 @@ package org.jetbrains.dokka.transformers.documentation import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext -fun interface DocumentableTransformer { - operator fun invoke(original: DModule, context: DokkaContext): DModule +public fun interface DocumentableTransformer { + public operator fun invoke(original: DModule, context: DokkaContext): DModule } diff --git a/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt b/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt index 06d5ef04..8ae28605 100644 --- a/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt +++ b/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt @@ -8,33 +8,32 @@ import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.DokkaConfiguration.PackageOptions import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.model.Documentable +import org.jetbrains.dokka.model.DocumentableSource import org.jetbrains.dokka.model.WithSources -interface PreMergeDocumentableTransformer { - operator fun invoke(modules: List<DModule>): List<DModule> +public interface PreMergeDocumentableTransformer { + public operator fun invoke(modules: List<DModule>): List<DModule> } -/* Utils */ - /** * It is fair to assume that a given [Documentable] is not merged when seen by the [PreMergeDocumentableTransformer]. * Therefore, it can also be assumed, that there is just a single source set connected to the given [documentable] * @return the single source set associated with this [documentable]. */ -@Suppress("unused") // Receiver is used for scoping this function -fun PreMergeDocumentableTransformer.sourceSet(documentable: Documentable): DokkaSourceSet { +@Suppress("UnusedReceiverParameter") // Receiver is used for scoping this function +public fun PreMergeDocumentableTransformer.sourceSet(documentable: Documentable): DokkaSourceSet { return documentable.sourceSets.single() } /** * @return The [PackageOptions] associated with this documentable, or null */ -fun PreMergeDocumentableTransformer.perPackageOptions(documentable: Documentable): PackageOptions? { +public fun PreMergeDocumentableTransformer.perPackageOptions(documentable: Documentable): PackageOptions? { val packageName = documentable.dri.packageName ?: return null return sourceSet(documentable).perPackageOptions .sortedByDescending { packageOptions -> packageOptions.matchingRegex.length } .firstOrNull { packageOptions -> Regex(packageOptions.matchingRegex).matches(packageName) } } -fun <T> PreMergeDocumentableTransformer.source(documentable: T) where T : Documentable, T : WithSources = +public fun <T> PreMergeDocumentableTransformer.source(documentable: T): DocumentableSource where T : Documentable, T : WithSources = checkNotNull(documentable.sources[sourceSet(documentable)]) diff --git a/core/src/main/kotlin/transformers/pages/PageCreator.kt b/core/src/main/kotlin/transformers/pages/PageCreator.kt index 1dc179f7..8c008f04 100644 --- a/core/src/main/kotlin/transformers/pages/PageCreator.kt +++ b/core/src/main/kotlin/transformers/pages/PageCreator.kt @@ -6,10 +6,10 @@ package org.jetbrains.dokka.transformers.pages import org.jetbrains.dokka.pages.RootPageNode -interface CreationContext +public interface CreationContext -object NoCreationContext : CreationContext +public object NoCreationContext : CreationContext -interface PageCreator<T: CreationContext> { - operator fun invoke(creationContext: T): RootPageNode +public interface PageCreator<T: CreationContext> { + public operator fun invoke(creationContext: T): RootPageNode } diff --git a/core/src/main/kotlin/transformers/pages/PageTransformer.kt b/core/src/main/kotlin/transformers/pages/PageTransformer.kt index cd72818c..b2bbc1d1 100644 --- a/core/src/main/kotlin/transformers/pages/PageTransformer.kt +++ b/core/src/main/kotlin/transformers/pages/PageTransformer.kt @@ -6,6 +6,6 @@ package org.jetbrains.dokka.transformers.pages import org.jetbrains.dokka.pages.RootPageNode -fun interface PageTransformer { - operator fun invoke(input: RootPageNode): RootPageNode +public fun interface PageTransformer { + public operator fun invoke(input: RootPageNode): RootPageNode } diff --git a/core/src/main/kotlin/transformers/pages/PageTransformerBuilders.kt b/core/src/main/kotlin/transformers/pages/PageTransformerBuilders.kt index 2e3732f6..a00c1578 100644 --- a/core/src/main/kotlin/transformers/pages/PageTransformerBuilders.kt +++ b/core/src/main/kotlin/transformers/pages/PageTransformerBuilders.kt @@ -7,14 +7,21 @@ package org.jetbrains.dokka.transformers.pages import org.jetbrains.dokka.pages.PageNode import org.jetbrains.dokka.pages.RootPageNode -fun pageScanner(block: PageNode.() -> Unit) = PageTransformer { input -> input.invokeOnAll(block) as RootPageNode } +public fun pageScanner(block: PageNode.() -> Unit): PageTransformer { + return PageTransformer { input -> input.invokeOnAll(block) as RootPageNode } +} -fun pageMapper(block: PageNode.() -> PageNode) = PageTransformer { input -> input.alterChildren(block) as RootPageNode } +public fun pageMapper(block: PageNode.() -> PageNode): PageTransformer { + return PageTransformer { input -> input.alterChildren(block) as RootPageNode } +} -fun pageStructureTransformer(block: RootPageNode.() -> RootPageNode) = PageTransformer { input -> block(input) } +public fun pageStructureTransformer(block: RootPageNode.() -> RootPageNode): PageTransformer { + return PageTransformer { input -> block(input) } +} -fun PageNode.invokeOnAll(block: PageNode.() -> Unit): PageNode = +public fun PageNode.invokeOnAll(block: PageNode.() -> Unit): PageNode = this.also(block).also { it.children.forEach { it.invokeOnAll(block) } } -fun PageNode.alterChildren(block: PageNode.() -> PageNode): PageNode = +public fun PageNode.alterChildren(block: PageNode.() -> PageNode): PageNode = block(this).modified(children = this.children.map { it.alterChildren(block) }) + diff --git a/core/src/main/kotlin/transformers/sources/AsyncSourceToDocumentableTranslator.kt b/core/src/main/kotlin/transformers/sources/AsyncSourceToDocumentableTranslator.kt index a153759f..f7f45d25 100644 --- a/core/src/main/kotlin/transformers/sources/AsyncSourceToDocumentableTranslator.kt +++ b/core/src/main/kotlin/transformers/sources/AsyncSourceToDocumentableTranslator.kt @@ -10,8 +10,8 @@ import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext -interface AsyncSourceToDocumentableTranslator : SourceToDocumentableTranslator { - suspend fun invokeSuspending(sourceSet: DokkaConfiguration.DokkaSourceSet, context: DokkaContext): DModule +public interface AsyncSourceToDocumentableTranslator : SourceToDocumentableTranslator { + public suspend fun invokeSuspending(sourceSet: DokkaConfiguration.DokkaSourceSet, context: DokkaContext): DModule override fun invoke(sourceSet: DokkaConfiguration.DokkaSourceSet, context: DokkaContext): DModule = runBlocking(Dispatchers.Default) { diff --git a/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt b/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt index 0ba37d40..04f11830 100644 --- a/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt +++ b/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt @@ -8,6 +8,6 @@ import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext -fun interface SourceToDocumentableTranslator { - fun invoke(sourceSet: DokkaSourceSet, context: DokkaContext): DModule +public fun interface SourceToDocumentableTranslator { + public fun invoke(sourceSet: DokkaSourceSet, context: DokkaContext): DModule } diff --git a/core/src/main/kotlin/utilities/Collections.kt b/core/src/main/kotlin/utilities/Collections.kt index bcc77021..e0b84a28 100644 --- a/core/src/main/kotlin/utilities/Collections.kt +++ b/core/src/main/kotlin/utilities/Collections.kt @@ -12,7 +12,7 @@ import org.jetbrains.dokka.InternalDokkaApi * locally for convenience. */ @InternalDokkaApi -inline fun <reified T : Any> Iterable<*>.firstIsInstanceOrNull(): T? { +public inline fun <reified T : Any> Iterable<*>.firstIsInstanceOrNull(): T? { for (element in this) if (element is T) return element return null } @@ -23,7 +23,7 @@ inline fun <reified T : Any> Iterable<*>.firstIsInstanceOrNull(): T? { * locally for convenience. */ @InternalDokkaApi -inline fun <reified T : Any> Sequence<*>.firstIsInstanceOrNull(): T? { +public inline fun <reified T : Any> Sequence<*>.firstIsInstanceOrNull(): T? { for (element in this) if (element is T) return element return null } diff --git a/core/src/main/kotlin/utilities/DokkaLogging.kt b/core/src/main/kotlin/utilities/DokkaLogging.kt index 52492930..7855c9c1 100644 --- a/core/src/main/kotlin/utilities/DokkaLogging.kt +++ b/core/src/main/kotlin/utilities/DokkaLogging.kt @@ -6,17 +6,18 @@ package org.jetbrains.dokka.utilities import java.util.concurrent.atomic.AtomicInteger -interface DokkaLogger { - var warningsCount: Int - var errorsCount: Int - fun debug(message: String) - fun info(message: String) - fun progress(message: String) - fun warn(message: String) - fun error(message: String) +public interface DokkaLogger { + public var warningsCount: Int + public var errorsCount: Int + + public fun debug(message: String) + public fun info(message: String) + public fun progress(message: String) + public fun warn(message: String) + public fun error(message: String) } -fun DokkaLogger.report() { +public fun DokkaLogger.report() { if (warningsCount > 0 || errorsCount > 0) { info( "Generation completed with $warningsCount warning" + @@ -29,20 +30,22 @@ fun DokkaLogger.report() { } } -enum class LoggingLevel(val index: Int) { +public enum class LoggingLevel( + public val index: Int +) { DEBUG(0), PROGRESS(1), INFO(2), WARN(3), ERROR(4); } /** * Used to decouple the transport layer from logger and make it convenient for testing */ -fun interface MessageEmitter : (String) -> Unit { - companion object { - val consoleEmitter: MessageEmitter = MessageEmitter { message -> println(message) } +public fun interface MessageEmitter : (String) -> Unit { + public companion object { + public val consoleEmitter: MessageEmitter = MessageEmitter { message -> println(message) } } } -class DokkaConsoleLogger( +public class DokkaConsoleLogger( private val minLevel: LoggingLevel = LoggingLevel.PROGRESS, private val emitter: MessageEmitter = MessageEmitter.consoleEmitter ) : DokkaLogger { diff --git a/core/src/main/kotlin/utilities/Html.kt b/core/src/main/kotlin/utilities/Html.kt index 4f34eab0..fc2330d2 100644 --- a/core/src/main/kotlin/utilities/Html.kt +++ b/core/src/main/kotlin/utilities/Html.kt @@ -13,11 +13,11 @@ import java.net.URLEncoder * Replaces & with &, < with < and > with > */ @InternalDokkaApi -fun String.htmlEscape(): String = replace("&", "&").replace("<", "<").replace(">", ">").replace("\"", """) +public fun String.htmlEscape(): String = replace("&", "&").replace("<", "<").replace(">", ">").replace("\"", """) @InternalDokkaApi -fun String.urlEncoded(): String = URLEncoder.encode(this, "UTF-8") +public fun String.urlEncoded(): String = URLEncoder.encode(this, "UTF-8") @InternalDokkaApi -fun String.formatToEndWithHtml() = +public fun String.formatToEndWithHtml(): String = if (endsWith(".html") || contains(Regex("\\.html#"))) this else "$this.html" diff --git a/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt b/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt index eb219804..57d3b1e1 100644 --- a/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt +++ b/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt @@ -9,7 +9,7 @@ import org.jetbrains.dokka.InternalDokkaApi @InternalDokkaApi @Suppress("DEPRECATION_ERROR") @Deprecated(message = "SelfRepresentingSingletonSet is an incorrect set implementation that breaks set invariants", level = DeprecationLevel.ERROR) -interface SelfRepresentingSingletonSet<T : SelfRepresentingSingletonSet<T>> : Set<T> { +public interface SelfRepresentingSingletonSet<T : SelfRepresentingSingletonSet<T>> : Set<T> { override val size: Int get() = 1 override fun contains(element: T): Boolean = this == element diff --git a/core/src/main/kotlin/utilities/ServiceLocator.kt b/core/src/main/kotlin/utilities/ServiceLocator.kt index 8ec886be..c8b8a837 100644 --- a/core/src/main/kotlin/utilities/ServiceLocator.kt +++ b/core/src/main/kotlin/utilities/ServiceLocator.kt @@ -13,19 +13,19 @@ import java.util.jar.JarFile import java.util.zip.ZipEntry @InternalDokkaApi -data class ServiceDescriptor(val name: String, val category: String, val description: String?, val className: String) +public data class ServiceDescriptor(val name: String, val category: String, val description: String?, val className: String) @InternalDokkaApi -class ServiceLookupException(message: String) : Exception(message) +public class ServiceLookupException(message: String) : Exception(message) @InternalDokkaApi -object ServiceLocator { - fun <T : Any> lookup(clazz: Class<T>, category: String, implementationName: String): T { +public object ServiceLocator { + public fun <T : Any> lookup(clazz: Class<T>, category: String, implementationName: String): T { val descriptor = lookupDescriptor(category, implementationName) return lookup(clazz, descriptor) } - fun <T : Any> lookup( + public fun <T : Any> lookup( clazz: Class<T>, descriptor: ServiceDescriptor ): T { @@ -56,7 +56,7 @@ object ServiceLocator { return ServiceDescriptor(implementationName, category, properties["description"]?.toString(), className) } - fun URL.toFile(): File { + public fun URL.toFile(): File { assert(protocol == "file") return try { @@ -66,7 +66,7 @@ object ServiceLocator { } } - fun allServices(category: String): List<ServiceDescriptor> { + public fun allServices(category: String): List<ServiceDescriptor> { val entries = this.javaClass.classLoader.getResources("dokka/$category")?.toList() ?: emptyList() return entries.flatMap { diff --git a/core/src/main/kotlin/utilities/Uri.kt b/core/src/main/kotlin/utilities/Uri.kt index ceee14bd..7e6b3fbe 100644 --- a/core/src/main/kotlin/utilities/Uri.kt +++ b/core/src/main/kotlin/utilities/Uri.kt @@ -9,7 +9,7 @@ import java.net.URI @InternalDokkaApi @Deprecated("Deprecated for removal") // Unused in Dokka -fun URI.relativeTo(uri: URI): URI { +public fun URI.relativeTo(uri: URI): URI { // Normalize paths to remove . and .. segments val base = uri.normalize() val child = this.normalize() diff --git a/core/src/main/kotlin/utilities/associateWithNotNull.kt b/core/src/main/kotlin/utilities/associateWithNotNull.kt index 38531108..29e37d13 100644 --- a/core/src/main/kotlin/utilities/associateWithNotNull.kt +++ b/core/src/main/kotlin/utilities/associateWithNotNull.kt @@ -7,7 +7,7 @@ package org.jetbrains.dokka.utilities import org.jetbrains.dokka.InternalDokkaApi @InternalDokkaApi -inline fun <K, V : Any> Iterable<K>.associateWithNotNull(valueSelector: (K) -> V?): Map<K, V> { +public inline fun <K, V : Any> Iterable<K>.associateWithNotNull(valueSelector: (K) -> V?): Map<K, V> { @Suppress("UNCHECKED_CAST") return associateWith { valueSelector(it) }.filterValues { it != null } as Map<K, V> } diff --git a/core/src/main/kotlin/utilities/cast.kt b/core/src/main/kotlin/utilities/cast.kt index cbd77456..c2598a33 100644 --- a/core/src/main/kotlin/utilities/cast.kt +++ b/core/src/main/kotlin/utilities/cast.kt @@ -7,6 +7,6 @@ package org.jetbrains.dokka.utilities import org.jetbrains.dokka.InternalDokkaApi @InternalDokkaApi -inline fun <reified T> Any.cast(): T { +public inline fun <reified T> Any.cast(): T { return this as T } diff --git a/core/src/main/kotlin/utilities/parallelCollectionOperations.kt b/core/src/main/kotlin/utilities/parallelCollectionOperations.kt index 1bb563c9..001fca0b 100644 --- a/core/src/main/kotlin/utilities/parallelCollectionOperations.kt +++ b/core/src/main/kotlin/utilities/parallelCollectionOperations.kt @@ -11,16 +11,16 @@ import kotlinx.coroutines.launch import org.jetbrains.dokka.InternalDokkaApi @InternalDokkaApi -suspend inline fun <A, B> Iterable<A>.parallelMap(crossinline f: suspend (A) -> B): List<B> = coroutineScope { +public suspend inline fun <A, B> Iterable<A>.parallelMap(crossinline f: suspend (A) -> B): List<B> = coroutineScope { map { async { f(it) } }.awaitAll() } @InternalDokkaApi -suspend inline fun <A, B> Iterable<A>.parallelMapNotNull(crossinline f: suspend (A) -> B?): List<B> = coroutineScope { +public suspend inline fun <A, B> Iterable<A>.parallelMapNotNull(crossinline f: suspend (A) -> B?): List<B> = coroutineScope { map { async { f(it) } }.awaitAll().filterNotNull() } @InternalDokkaApi -suspend inline fun <A> Iterable<A>.parallelForEach(crossinline f: suspend (A) -> Unit): Unit = coroutineScope { +public suspend inline fun <A> Iterable<A>.parallelForEach(crossinline f: suspend (A) -> Unit): Unit = coroutineScope { forEach { launch { f(it) } } } diff --git a/core/src/main/kotlin/validity/PreGenerationChecker.kt b/core/src/main/kotlin/validity/PreGenerationChecker.kt index 09284528..349b398b 100644 --- a/core/src/main/kotlin/validity/PreGenerationChecker.kt +++ b/core/src/main/kotlin/validity/PreGenerationChecker.kt @@ -4,13 +4,14 @@ package org.jetbrains.dokka.validity -fun interface PreGenerationChecker : () -> PreGenerationCheckerOutput { +public fun interface PreGenerationChecker : () -> PreGenerationCheckerOutput { override fun invoke(): PreGenerationCheckerOutput } -data class PreGenerationCheckerOutput(val result: Boolean, val messages: List<String>) { +public data class PreGenerationCheckerOutput(val result: Boolean, val messages: List<String>) { - operator fun plus(pair: Pair<Boolean, List<String>>) = - Pair(result && pair.first, messages + pair.second) + public operator fun plus(pair: Pair<Boolean, List<String>>): Pair<Boolean, List<String>> { + return Pair(result && pair.first, messages + pair.second) + } } |