diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts index 6093253f36..d2425ce3e0 100644 --- a/build-logic/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts +++ b/build-logic/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts @@ -5,6 +5,7 @@ package org.jetbrains.conventions import org.jetbrains.configureDokkaVersion +import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -14,25 +15,44 @@ plugins { configureDokkaVersion() -val projectsWithoutOptInDependency = setOf( - ":integration-tests", ":integration-tests:gradle", ":integration-tests:maven", ":integration-tests:cli") +kotlin { + explicitApi = ExplicitApiMode.Strict + + compilerOptions { + allWarningsAsErrors.set(true) + languageVersion.set(dokkaBuild.kotlinLanguageLevel) + apiVersion.set(dokkaBuild.kotlinLanguageLevel) + + freeCompilerArgs.addAll( + listOf( + // need 1.4 support, otherwise there might be problems + // with Gradle 6.x (it's bundling Kotlin 1.4) + "-Xsuppress-version-warnings", + "-Xjsr305=strict", + "-Xskip-metadata-version-check", + ) + ) + } +} + +val projectsWithoutInternalDokkaApiUsage = setOf( + ":integration-tests", + ":integration-tests:gradle", + ":integration-tests:maven", + ":integration-tests:cli" +) tasks.withType().configureEach { // By path because Dokka has multiple projects with the same name (i.e. 'cli') - if (project.path in projectsWithoutOptInDependency) return@configureEach + if (project.path in projectsWithoutInternalDokkaApiUsage) { + return@configureEach + } compilerOptions { freeCompilerArgs.addAll( listOf( "-opt-in=kotlin.RequiresOptIn", "-opt-in=org.jetbrains.dokka.InternalDokkaApi", - "-Xjsr305=strict", - "-Xskip-metadata-version-check", - // need 1.4 support, otherwise there might be problems with Gradle 6.x (it's bundling Kotlin 1.4) - "-Xsuppress-version-warnings", ) ) - allWarningsAsErrors.set(true) - languageVersion.set(dokkaBuild.kotlinLanguageLevel) - apiVersion.set(dokkaBuild.kotlinLanguageLevel) } } diff --git a/core/api/core.api b/core/api/core.api index 6da499ee6e..2399880b93 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -658,7 +658,7 @@ public final class org/jetbrains/dokka/model/ActualTypealias : org/jetbrains/dok public final class org/jetbrains/dokka/model/ActualTypealias$Companion : org/jetbrains/dokka/model/properties/ExtraProperty$Key { public synthetic fun mergeStrategyFor (Ljava/lang/Object;Ljava/lang/Object;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; - public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/ActualTypealias;Lorg/jetbrains/dokka/model/ActualTypealias;)Lorg/jetbrains/dokka/model/properties/MergeStrategy$Fail; + public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/ActualTypealias;Lorg/jetbrains/dokka/model/ActualTypealias;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; } public final class org/jetbrains/dokka/model/AdditionalExtrasKt { @@ -817,7 +817,7 @@ public final class org/jetbrains/dokka/model/CheckedExceptions : org/jetbrains/d public final class org/jetbrains/dokka/model/CheckedExceptions$Companion : org/jetbrains/dokka/model/properties/ExtraProperty$Key { public synthetic fun mergeStrategyFor (Ljava/lang/Object;Ljava/lang/Object;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; - public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/CheckedExceptions;Lorg/jetbrains/dokka/model/CheckedExceptions;)Lorg/jetbrains/dokka/model/properties/MergeStrategy$Replace; + public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/CheckedExceptions;Lorg/jetbrains/dokka/model/CheckedExceptions;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; } public abstract interface class org/jetbrains/dokka/model/ClassKind { @@ -1505,7 +1505,7 @@ public final class org/jetbrains/dokka/model/ExceptionInSupertypes : org/jetbrai public final class org/jetbrains/dokka/model/ExceptionInSupertypes$Companion : org/jetbrains/dokka/model/properties/ExtraProperty$Key { public synthetic fun mergeStrategyFor (Ljava/lang/Object;Ljava/lang/Object;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; - public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/ExceptionInSupertypes;Lorg/jetbrains/dokka/model/ExceptionInSupertypes;)Lorg/jetbrains/dokka/model/properties/MergeStrategy$Replace; + public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/ExceptionInSupertypes;Lorg/jetbrains/dokka/model/ExceptionInSupertypes;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; } public abstract interface class org/jetbrains/dokka/model/Expression { @@ -1707,7 +1707,7 @@ public final class org/jetbrains/dokka/model/ImplementedInterfaces : org/jetbrai public final class org/jetbrains/dokka/model/ImplementedInterfaces$Companion : org/jetbrains/dokka/model/properties/ExtraProperty$Key { public synthetic fun mergeStrategyFor (Ljava/lang/Object;Ljava/lang/Object;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; - public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/ImplementedInterfaces;Lorg/jetbrains/dokka/model/ImplementedInterfaces;)Lorg/jetbrains/dokka/model/properties/MergeStrategy$Replace; + public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/ImplementedInterfaces;Lorg/jetbrains/dokka/model/ImplementedInterfaces;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; } public final class org/jetbrains/dokka/model/InheritedMember : org/jetbrains/dokka/model/properties/ExtraProperty { @@ -1726,7 +1726,7 @@ public final class org/jetbrains/dokka/model/InheritedMember : org/jetbrains/dok public final class org/jetbrains/dokka/model/InheritedMember$Companion : org/jetbrains/dokka/model/properties/ExtraProperty$Key { public synthetic fun mergeStrategyFor (Ljava/lang/Object;Ljava/lang/Object;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; - public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/InheritedMember;Lorg/jetbrains/dokka/model/InheritedMember;)Lorg/jetbrains/dokka/model/properties/MergeStrategy$Replace; + public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/InheritedMember;Lorg/jetbrains/dokka/model/InheritedMember;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; } public final class org/jetbrains/dokka/model/IntValue : org/jetbrains/dokka/model/LiteralValue { @@ -4103,8 +4103,7 @@ public final class org/jetbrains/dokka/pages/MultimoduleRootPageNode : org/jetbr public fun getName ()Ljava/lang/String; public synthetic fun modified (Ljava/lang/String;Ljava/util/List;)Lorg/jetbrains/dokka/pages/PageNode; public fun modified (Ljava/lang/String;Ljava/util/List;)Lorg/jetbrains/dokka/pages/RootPageNode; - public synthetic fun modified (Ljava/lang/String;Lorg/jetbrains/dokka/pages/ContentNode;Ljava/util/Set;Ljava/util/List;Ljava/util/List;)Lorg/jetbrains/dokka/pages/ContentPage; - public fun modified (Ljava/lang/String;Lorg/jetbrains/dokka/pages/ContentNode;Ljava/util/Set;Ljava/util/List;Ljava/util/List;)Lorg/jetbrains/dokka/pages/MultimoduleRootPageNode; + public fun modified (Ljava/lang/String;Lorg/jetbrains/dokka/pages/ContentNode;Ljava/util/Set;Ljava/util/List;Ljava/util/List;)Lorg/jetbrains/dokka/pages/ContentPage; } public final class org/jetbrains/dokka/pages/MultimoduleTable : org/jetbrains/dokka/pages/Style { @@ -4166,7 +4165,7 @@ public final class org/jetbrains/dokka/pages/PlatformHintedContent : org/jetbrai public synthetic fun transformChildren (Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/dokka/pages/ContentComposite; public fun transformChildren (Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/dokka/pages/PlatformHintedContent; public synthetic fun withNewExtras (Lorg/jetbrains/dokka/model/properties/PropertyContainer;)Ljava/lang/Object; - public fun withNewExtras (Lorg/jetbrains/dokka/model/properties/PropertyContainer;)Ljava/lang/Void; + public fun withNewExtras (Lorg/jetbrains/dokka/model/properties/PropertyContainer;)Lorg/jetbrains/dokka/pages/ContentNode; public synthetic fun withSourceSets (Ljava/util/Set;)Lorg/jetbrains/dokka/pages/ContentNode; public fun withSourceSets (Ljava/util/Set;)Lorg/jetbrains/dokka/pages/PlatformHintedContent; } diff --git a/core/content-matcher-test-utils/src/main/kotlin/matchers/content/ContentMatchersDsl.kt b/core/content-matcher-test-utils/src/main/kotlin/matchers/content/ContentMatchersDsl.kt index 5a8de9ceb2..026f7b6b74 100644 --- a/core/content-matcher-test-utils/src/main/kotlin/matchers/content/ContentMatchersDsl.kt +++ b/core/content-matcher-test-utils/src/main/kotlin/matchers/content/ContentMatchersDsl.kt @@ -12,7 +12,7 @@ import kotlin.test.assertEquals import kotlin.test.asserter // entry point: -fun ContentNode.assertNode(block: ContentMatcherBuilder.() -> Unit) { +public fun ContentNode.assertNode(block: ContentMatcherBuilder.() -> Unit) { val matcher = ContentMatcherBuilder(ContentComposite::class).apply(block).build() try { matcher.tryMatch(this) @@ -24,123 +24,161 @@ fun ContentNode.assertNode(block: ContentMatcherBuilder.() -> // DSL: @DslMarker -annotation class ContentMatchersDsl +public annotation class ContentMatchersDsl @ContentMatchersDsl -class ContentMatcherBuilder @PublishedApi internal constructor(private val kclass: KClass) { +public class ContentMatcherBuilder @PublishedApi internal constructor(private val kclass: KClass) { @PublishedApi - internal val children = mutableListOf() + internal val children: MutableList = mutableListOf() internal val assertions = mutableListOf Unit>() - fun build() = CompositeMatcher(kclass, childrenOrSkip()) { assertions.forEach { it() } } + public fun build(): CompositeMatcher = CompositeMatcher(kclass, childrenOrSkip()) { assertions.forEach { it() } } // part of DSL that cannot be defined as an extension - operator fun String.unaryPlus() { + public operator fun String.unaryPlus() { children += TextMatcher(this) } private fun childrenOrSkip() = if (children.isEmpty() && assertions.isNotEmpty()) listOf(Anything) else children } -fun ContentMatcherBuilder.check(assertion: T.() -> Unit) { +public fun ContentMatcherBuilder.check(assertion: T.() -> Unit) { assertions += assertion } private val ContentComposite.extractedText get() = withDescendants().filterIsInstance().joinToString(separator = "") { it.text } -fun ContentMatcherBuilder.hasExactText(expected: String) { +public fun ContentMatcherBuilder.hasExactText(expected: String) { assertions += { assertEquals(expected, this.extractedText) } } -inline fun ContentMatcherBuilder<*>.composite( +public inline fun ContentMatcherBuilder<*>.composite( block: ContentMatcherBuilder.() -> Unit ) { children += ContentMatcherBuilder(S::class).apply(block).build() } -inline fun ContentMatcherBuilder<*>.node(noinline assertions: S.() -> Unit = {}) { +public inline fun ContentMatcherBuilder<*>.node(noinline assertions: S.() -> Unit = {}) { children += NodeMatcher(S::class, assertions) } -fun ContentMatcherBuilder<*>.skipAllNotMatching() { +public fun ContentMatcherBuilder<*>.skipAllNotMatching() { children += Anything } // Convenience functions: -fun ContentMatcherBuilder<*>.group(block: ContentMatcherBuilder.() -> Unit) = composite(block) +public fun ContentMatcherBuilder<*>.group(block: ContentMatcherBuilder.() -> Unit) { + composite(block) +} -fun ContentMatcherBuilder<*>.tabbedGroup( +public fun ContentMatcherBuilder<*>.tabbedGroup( block: ContentMatcherBuilder.() -> Unit -) = composite { - block() - check { assertContains(this.style, ContentStyle.TabbedContent) } +) { + composite { + block() + check { assertContains(this.style, ContentStyle.TabbedContent) } + } } -fun ContentMatcherBuilder<*>.tab( +public fun ContentMatcherBuilder<*>.tab( tabbedContentType: TabbedContentType, block: ContentMatcherBuilder.() -> Unit -) = composite { - block() - check { - assertEquals(tabbedContentType, this.extra[TabbedContentTypeExtra]?.value) +) { + composite { + block() + check { + assertEquals(tabbedContentType, this.extra[TabbedContentTypeExtra]?.value) + } } } -fun ContentMatcherBuilder<*>.header(expectedLevel: Int? = null, block: ContentMatcherBuilder.() -> Unit) = +public fun ContentMatcherBuilder<*>.header(expectedLevel: Int? = null, block: ContentMatcherBuilder.() -> Unit) { composite { block() check { if (expectedLevel != null) assertEquals(expectedLevel, this.level) } } +} -fun ContentMatcherBuilder<*>.p(block: ContentMatcherBuilder.() -> Unit) = +public fun ContentMatcherBuilder<*>.p(block: ContentMatcherBuilder.() -> Unit) { composite { block() check { assertContains(this.style, TextStyle.Paragraph) } } +} -fun ContentMatcherBuilder<*>.link(block: ContentMatcherBuilder.() -> Unit) = composite(block) +public fun ContentMatcherBuilder<*>.link(block: ContentMatcherBuilder.() -> Unit) { + composite(block) +} -fun ContentMatcherBuilder<*>.table(block: ContentMatcherBuilder.() -> Unit) = composite(block) +public fun ContentMatcherBuilder<*>.table(block: ContentMatcherBuilder.() -> Unit) { + composite(block) +} -fun ContentMatcherBuilder<*>.platformHinted(block: ContentMatcherBuilder.() -> Unit) = +public fun ContentMatcherBuilder<*>.platformHinted(block: ContentMatcherBuilder.() -> Unit) { composite { group(block) } +} -fun ContentMatcherBuilder<*>.list(block: ContentMatcherBuilder.() -> Unit) = composite(block) +public fun ContentMatcherBuilder<*>.list(block: ContentMatcherBuilder.() -> Unit) { + composite(block) +} -fun ContentMatcherBuilder<*>.codeBlock(block: ContentMatcherBuilder.() -> Unit) = composite(block) +public fun ContentMatcherBuilder<*>.codeBlock(block: ContentMatcherBuilder.() -> Unit) { + composite(block) +} -fun ContentMatcherBuilder<*>.codeInline(block: ContentMatcherBuilder.() -> Unit) = composite(block) +public fun ContentMatcherBuilder<*>.codeInline(block: ContentMatcherBuilder.() -> Unit) { + composite(block) +} -fun ContentMatcherBuilder<*>.caption(block: ContentMatcherBuilder.() -> Unit) = composite { - block() - check { assertContains(this.style, ContentStyle.Caption) } +public fun ContentMatcherBuilder<*>.caption(block: ContentMatcherBuilder.() -> Unit) { + composite { + block() + check { assertContains(this.style, ContentStyle.Caption) } + } } -fun ContentMatcherBuilder<*>.br() = node() +public fun ContentMatcherBuilder<*>.br() { + node() +} -fun ContentMatcherBuilder<*>.somewhere(block: ContentMatcherBuilder<*>.() -> Unit) { +public fun ContentMatcherBuilder<*>.somewhere(block: ContentMatcherBuilder<*>.() -> Unit) { skipAllNotMatching() block() skipAllNotMatching() } -fun ContentMatcherBuilder<*>.divergentGroup(block: ContentMatcherBuilder.() -> Unit) = +public fun ContentMatcherBuilder<*>.divergentGroup( + block: ContentMatcherBuilder.() -> Unit +) { composite(block) +} -fun ContentMatcherBuilder.divergentInstance(block: ContentMatcherBuilder.() -> Unit) = +public fun ContentMatcherBuilder.divergentInstance( + block: ContentMatcherBuilder.() -> Unit +) { composite(block) +} -fun ContentMatcherBuilder.before(block: ContentMatcherBuilder.() -> Unit) = +public fun ContentMatcherBuilder.before( + block: ContentMatcherBuilder.() -> Unit +) { composite(block) +} -fun ContentMatcherBuilder.divergent(block: ContentMatcherBuilder.() -> Unit) = +public fun ContentMatcherBuilder.divergent( + block: ContentMatcherBuilder.() -> Unit +) { composite(block) +} -fun ContentMatcherBuilder.after(block: ContentMatcherBuilder.() -> Unit) = +public fun ContentMatcherBuilder.after( + block: ContentMatcherBuilder.() -> Unit +) { composite(block) +} /* * TODO replace with kotlin.test.assertContains after migrating to Kotlin language version 1.5+ diff --git a/core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt b/core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt index a6549b31b0..412f728b8e 100644 --- a/core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt +++ b/core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt @@ -14,15 +14,18 @@ import kotlin.reflect.KClass import kotlin.reflect.full.cast import kotlin.reflect.full.safeCast -sealed class MatcherElement +public sealed class MatcherElement -class TextMatcher(val text: String) : MatcherElement() +public class TextMatcher( + public val text: String +) : MatcherElement() -open class NodeMatcher( - val kclass: KClass, - val assertions: T.() -> Unit = {} +public open class NodeMatcher( + public val kclass: KClass, + public val assertions: T.() -> Unit = {} ) : MatcherElement() { - open fun tryMatch(node: ContentNode) { + + public open fun tryMatch(node: ContentNode) { kclass.safeCast(node)?.apply { try { assertions() @@ -37,11 +40,12 @@ open class NodeMatcher( } } -class CompositeMatcher( +public class CompositeMatcher( kclass: KClass, private val children: List, assertions: T.() -> Unit = {} ) : NodeMatcher(kclass, assertions) { + internal val normalizedChildren: List by lazy { children.fold(listOf()) { acc, e -> when { @@ -61,7 +65,7 @@ class CompositeMatcher( } } -object Anything : MatcherElement() +public object Anything : MatcherElement() private sealed class MatchWalkerState { abstract fun next(node: ContentNode): MatchWalkerState @@ -176,7 +180,7 @@ private fun ContentNode.debugRepresentation() = asPrintableTree { element -> ) } -data class MatcherError( +public data class MatcherError( override val message: String, val anchor: MatcherElement, val anchorAfter: Boolean = false, diff --git a/core/src/main/kotlin/ConfigurationJsonUtils.kt b/core/src/main/kotlin/ConfigurationJsonUtils.kt index 9e03b906ab..e693f4ef12 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.toJsonString(): String = this.toCompactJsonString() +public fun T.toJsonString(): String = this.toCompactJsonString() /** * Serializes [DokkaConfiguration] as a machine-readable and compact JSON string. @@ -25,7 +25,7 @@ fun 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.toCompactJsonString(): String = serializeAsCompactJson(this) +public fun T.toCompactJsonString(): String = serializeAsCompactJson(this) /** * Serializes a [ConfigurableBlock] as a human-readable (pretty printed) JSON string. @@ -51,4 +51,4 @@ fun 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.toPrettyJsonString(): String = serializeAsCompactJson(this) +public fun T.toPrettyJsonString(): String = serializeAsCompactJson(this) diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt index d689d10238..ca2504e2b5 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() - val generation by coreExtensionPoint() - val sourceToDocumentableTranslator by coreExtensionPoint() - val documentableMerger by coreExtensionPoint() - val documentableTransformer by coreExtensionPoint() - val documentableToPageTranslator by coreExtensionPoint() - val pageTransformer by coreExtensionPoint() - val renderer by coreExtensionPoint() - val postActions by coreExtensionPoint() +public object CoreExtensions { + + public val preGenerationCheck: ExtensionPoint by coreExtensionPoint() + + public val generation: ExtensionPoint by coreExtensionPoint() + + public val sourceToDocumentableTranslator: ExtensionPoint by coreExtensionPoint() + + public val documentableMerger: ExtensionPoint by coreExtensionPoint() + + public val documentableTransformer: ExtensionPoint by coreExtensionPoint() + + public val documentableToPageTranslator: ExtensionPoint by coreExtensionPoint() + + public val pageTransformer: ExtensionPoint by coreExtensionPoint() + + public val renderer: ExtensionPoint by coreExtensionPoint() + + public val postActions: ExtensionPoint by coreExtensionPoint() private fun coreExtensionPoint() = object { operator fun provideDelegate(thisRef: CoreExtensions, property: KProperty<*>): Lazy> = diff --git a/core/src/main/kotlin/DokkaBootstrap.kt b/core/src/main/kotlin/DokkaBootstrap.kt index 13cc9ded99..d3d82e398a 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) + public fun configure(serializedConfigurationJSON: String, logger: BiConsumer) @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 c0af9a41bb..65f0ef72e7 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) : DokkaLogger { + public class DokkaProxyLogger( + public val consumer: BiConsumer + ) : 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) = configure( - DokkaProxyLogger(logger), - DokkaConfigurationImpl(serializedConfigurationJSON) - ) + override fun configure(serializedConfigurationJSON: String, logger: BiConsumer) { + 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 cc4871751d..f16a26496c 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 6132b92f35..9ae3adb4df 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 = 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 37ce77baff..d846988b7e 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 9cbc6ea2ad..65035d04e4 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 = setOf(DokkaConfiguration.Visibility.PUBLIC) + public const val includeNonPublic: Boolean = false + public val documentedVisibilities: Set = setOf(DokkaConfiguration.Visibility.PUBLIC) - val pluginsConfiguration = mutableListOf() + public val pluginsConfiguration: List = 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 { - fun build(): T +public fun interface DokkaConfigurationBuilder { + public fun build(): T } -fun Iterable>.build(): List = this.map { it.build() } +public fun Iterable>.build(): List = 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?, val externalDocumentationLinks: List?, val sourceLinks: List? ) -fun DokkaConfiguration.apply(globals: GlobalDokkaConfiguration): DokkaConfiguration = this.apply { +public fun DokkaConfiguration.apply(globals: GlobalDokkaConfiguration): DokkaConfiguration = this.apply { sourceSets.forEach { it.perPackageOptions.cast>() .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 - val modules: List - val pluginsClasspath: List - val pluginsConfiguration: List - val delayTemplateSubstitution: Boolean - val suppressObviousFunctions: Boolean - val includes: Set - 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 + public val modules: List + public val pluginsClasspath: List + public val pluginsConfiguration: List + public val delayTemplateSubstitution: Boolean + public val suppressObviousFunctions: Boolean + public val includes: Set + 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 - val sourceRoots: Set - val dependentSourceSets: Set - val samples: Set - val includes: Set + public interface DokkaSourceSet : Serializable { + public val sourceSetID: DokkaSourceSetID + public val displayName: String + public val classpath: List + public val sourceRoots: Set + public val dependentSourceSets: Set + public val samples: Set + public val includes: Set @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 - val perPackageOptions: List - val externalDocumentationLinks: Set - val languageVersion: String? - val apiVersion: String? - val noStdlibLink: Boolean - val noJdkLink: Boolean - val suppressedFiles: Set - val analysisPlatform: Platform - val documentedVisibilities: Set + public val includeNonPublic: Boolean + public val reportUndocumented: Boolean + public val skipEmptyPackages: Boolean + public val skipDeprecated: Boolean + public val jdkVersion: Int + public val sourceLinks: Set + public val perPackageOptions: List + public val externalDocumentationLinks: Set + public val languageVersion: String? + public val apiVersion: String? + public val noStdlibLink: Boolean + public val noJdkLink: Boolean + public val suppressedFiles: Set + public val analysisPlatform: Platform + public val documentedVisibilities: Set } - 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 + public interface DokkaModuleDescription : Serializable { + public val name: String + public val relativePathToOutputDirectory: File + public val sourceOutputDirectory: File + public val includes: Set } - 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 + public val includeNonPublic: Boolean + public val reportUndocumented: Boolean? + public val skipDeprecated: Boolean + public val suppress: Boolean + public val documentedVisibilities: Set } - 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 2ea5e0ef33..f858d8c0ed 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 = emptyList(), @@ -59,20 +59,21 @@ data class DokkaSourceSetImpl( override val documentedVisibilities: Set = DokkaDefaults.documentedVisibilities, ) : DokkaSourceSet -data class DokkaModuleDescriptionImpl( +public data class DokkaModuleDescriptionImpl( override val name: String, override val relativePathToOutputDirectory: File, override val includes: Set, 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 8d3b96553a..26e3e0ae4d 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 185b00f843..9f14912fec 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 bcd0198b1b..180d9eb8e3 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() +public object EnumEntryDRIExtra: DRIExtraProperty() -abstract class DRIExtraProperty { - val key: String = this::class.qualifiedName +public abstract class DRIExtraProperty { + 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 = if (data != null) OBJECT_MAPPER.readValue(data) else mutableMapOf() - inline operator fun get(prop: DRIExtraProperty): T? = +public class DRIExtraContainer(public val data: String? = null) { + public val map: MutableMap = if (data != null) OBJECT_MAPPER.readValue(data) else mutableMapOf() + public inline operator fun get(prop: DRIExtraProperty): T? = map[prop.key]?.let { prop as? T } - inline operator fun set(prop: DRIExtraProperty, value: T) = - value.also { map[prop.key] = it as Any } + public inline operator fun set(prop: DRIExtraProperty, 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 ) { - 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() +public data class TypeParam(val bounds: List) : TypeReference() -data class TypeConstructor( +public data class TypeConstructor( val fullyQualifiedName: String, val params: List ) : 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 3631863323..af7d1a5dde 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 = 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 d96b051cc3..c6109f47bf 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, +public abstract class Documentable : WithChildren, AnnotationTarget { - abstract val name: String? - abstract val dri: DRI - abstract val documentation: SourceSetDependent - abstract val sourceSets: Set - abstract val expectPresentInSet: DokkaSourceSet? + public abstract val name: String? + public abstract val dri: DRI + public abstract val documentation: SourceSetDependent + public abstract val sourceSets: Set + public abstract val expectPresentInSet: DokkaSourceSet? abstract override val children: List 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 = Map +public typealias SourceSetDependent = Map -interface WithSources { - val sources: SourceSetDependent +public interface WithSources { + public val sources: SourceSetDependent } -interface WithScope { - val functions: List - val properties: List - val classlikes: List +public interface WithScope { + public val functions: List + public val properties: List + public val classlikes: List } -interface WithVisibility { - val visibility: SourceSetDependent +public interface WithVisibility { + public val visibility: SourceSetDependent } -interface WithType { - val type: Bound +public interface WithType { + public val type: Bound } -interface WithAbstraction { - val modifier: SourceSetDependent +public interface WithAbstraction { + public val modifier: SourceSetDependent } -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 +public interface WithConstructors { + public val constructors: List } -interface WithGenerics { - val generics: List +public interface WithGenerics { + public val generics: List } -interface WithSupertypes { - val supertypes: SourceSetDependent> +public interface WithSupertypes { + public val supertypes: SourceSetDependent> } -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, override val documentation: SourceSetDependent, @@ -107,10 +110,10 @@ data class DModule( override val children: List get() = packages - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer): DModule = copy(extra = newExtras) } -data class DPackage( +public data class DPackage( override val dri: DRI, override val functions: List, override val properties: List, @@ -134,10 +137,10 @@ data class DPackage( override val children: List = properties + functions + classlikes + typealiases - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer): DPackage = copy(extra = newExtras) } -data class DClass( +public data class DClass( override val dri: DRI, override val name: String, override val constructors: List, @@ -161,10 +164,10 @@ data class DClass( override val children: List get() = (functions + properties + classlikes + constructors) - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer): DClass = copy(extra = newExtras) } -data class DEnum( +public data class DEnum( override val dri: DRI, override val name: String, val entries: List, @@ -185,10 +188,10 @@ data class DEnum( override val children: List get() = (entries + functions + properties + classlikes + constructors) - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer): DEnum = copy(extra = newExtras) } -data class DEnumEntry( +public data class DEnumEntry( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent, @@ -202,10 +205,10 @@ data class DEnumEntry( override val children: List get() = (functions + properties + classlikes) - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer): 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 get() = parameters - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer): DFunction = copy(extra = newExtras) } -data class DInterface( +public data class DInterface( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent, @@ -248,10 +251,10 @@ data class DInterface( override val children: List get() = (functions + properties + classlikes) - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer): DInterface = copy(extra = newExtras) } -data class DObject( +public data class DObject( override val name: String?, override val dri: DRI, override val documentation: SourceSetDependent, @@ -269,10 +272,10 @@ data class DObject( override val children: List get() = (functions + properties + classlikes) - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer): DObject = copy(extra = newExtras) } -data class DAnnotation( +public data class DAnnotation( override val name: String, override val dri: DRI, override val documentation: SourceSetDependent, @@ -292,10 +295,10 @@ data class DAnnotation( override val children: List get() = (functions + properties + classlikes + constructors) - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer): DAnnotation = copy(extra = newExtras) } -data class DProperty( +public data class DProperty( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent, @@ -315,11 +318,11 @@ data class DProperty( override val children: List get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer): 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, @@ -331,10 +334,10 @@ data class DParameter( override val children: List get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer): DParameter = copy(extra = newExtras) } -data class DTypeParameter( +public data class DTypeParameter( val variantTypeParameter: Variance, override val documentation: SourceSetDependent, override val expectPresentInSet: DokkaSourceSet?, @@ -343,7 +346,7 @@ data class DTypeParameter( override val extra: PropertyContainer = PropertyContainer.empty() ) : Documentable(), WithExtraProperties { - constructor( + public constructor( dri: DRI, name: String, presentableName: String?, @@ -367,10 +370,10 @@ data class DTypeParameter( override val children: List get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer): 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 get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer): 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 - abstract val presentableName: String? +public sealed class TypeConstructor : Bound(), AnnotationTarget { + public abstract val dri: DRI + public abstract val projections: List + public abstract val presentableName: String? } -data class GenericTypeConstructor( +public data class GenericTypeConstructor( override val dri: DRI, override val projections: List, 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, 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 = 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 = PropertyContainer.empty() ) : Bound(), AnnotationTarget, WithExtraProperties { @@ -447,13 +450,13 @@ data class PrimitiveJavaType( copy(extra = newExtras) } -data class JavaObject(override val extra: PropertyContainer = PropertyContainer.empty()) : +public data class JavaObject(override val extra: PropertyContainer = PropertyContainer.empty()) : Bound(), AnnotationTarget, WithExtraProperties { override fun withNewExtras(newExtras: PropertyContainer): JavaObject = copy(extra = newExtras) } -data class UnresolvedBound( +public data class UnresolvedBound( val name: String, override val extra: PropertyContainer = PropertyContainer.empty() ) : Bound(), AnnotationTarget, WithExtraProperties { @@ -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 : Projection() { - abstract val inner: T +public sealed class Variance : Projection() { + public abstract val inner: T } -data class Covariance(override val inner: T) : Variance() { - override fun toString() = "out" +public data class Covariance(override val inner: T) : Variance() { + override fun toString(): String = "out" } -data class Contravariance(override val inner: T) : Variance() { - override fun toString() = "in" +public data class Contravariance(override val inner: T) : Variance() { + override fun toString(): String = "in" } -data class Invariance(override val inner: T) : Variance() { - override fun toString() = "" +public data class Invariance(override val inner: T) : Variance() { + 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.withDri(dri: DRI) = when (this) { +public fun Variance.withDri(dri: DRI): Variance = 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 SourceSetDependent?.orEmpty(): SourceSetDependent = this ?: emptyMap() +public fun SourceSetDependent?.orEmpty(): SourceSetDependent = 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 38829ef5c9..a2b641c9d7 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 01e69fd017..f73a5aa01c 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 { - val children: List +public interface WithChildren { + public val children: List } -inline fun WithChildren<*>.firstChildOfTypeOrNull(): T? = +public inline fun WithChildren<*>.firstChildOfTypeOrNull(): T? = children.filterIsInstance().firstOrNull() -inline fun WithChildren<*>.firstChildOfTypeOrNull(predicate: (T) -> Boolean): T? = +public inline fun WithChildren<*>.firstChildOfTypeOrNull(predicate: (T) -> Boolean): T? = children.filterIsInstance().firstOrNull(predicate) -inline fun WithChildren<*>.firstChildOfType(): T = +public inline fun WithChildren<*>.firstChildOfType(): T = children.filterIsInstance().first() -inline fun WithChildren<*>.childrenOfType(): List = +public inline fun WithChildren<*>.childrenOfType(): List = children.filterIsInstance() -inline fun WithChildren<*>.firstChildOfType(predicate: (T) -> Boolean): T = +public inline fun WithChildren<*>.firstChildOfType(predicate: (T) -> Boolean): T = children.filterIsInstance().first(predicate) -inline fun WithChildren>.firstMemberOfType(): T where T : WithChildren<*> { +public inline fun WithChildren>.firstMemberOfType(): T where T : WithChildren<*> { return withDescendants().filterIsInstance().first() } -inline fun WithChildren>.firstMemberOfType( +public inline fun WithChildren>.firstMemberOfType( predicate: (T) -> Boolean ): T where T : WithChildren<*> = withDescendants().filterIsInstance().first(predicate) -inline fun WithChildren>.firstMemberOfTypeOrNull(): T? where T : WithChildren<*> { +public inline fun WithChildren>.firstMemberOfTypeOrNull(): T? where T : WithChildren<*> { return withDescendants().filterIsInstance().firstOrNull() } -fun T.withDescendants(): Sequence where T : WithChildren { +public fun T.withDescendants(): Sequence where T : WithChildren { return sequence { yield(this@withDescendants) children.forEach { child -> @@ -46,7 +46,7 @@ fun T.withDescendants(): Sequence where T : WithChildren { } @JvmName("withDescendantsProjection") -fun WithChildren<*>.withDescendants(): Sequence { +public fun WithChildren<*>.withDescendants(): Sequence { return sequence { yield(this@withDescendants) children.forEach { child -> @@ -58,7 +58,7 @@ fun WithChildren<*>.withDescendants(): Sequence { } @JvmName("withDescendantsAny") -fun WithChildren.withDescendants(): Sequence { +public fun WithChildren.withDescendants(): Sequence { return sequence { yield(this@withDescendants) children.forEach { child -> @@ -69,13 +69,13 @@ fun WithChildren.withDescendants(): Sequence { } } -fun T.dfs(predicate: (T) -> Boolean): T? where T : WithChildren = if (predicate(this)) { +public fun T.dfs(predicate: (T) -> Boolean): T? where T : WithChildren = if (predicate(this)) { this } else { children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull() } -fun > T.asPrintableTree( +public fun > 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 64c1e31544..1db8e59dee 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>) : ExtraProperty { - companion object : ExtraProperty.Key { +public class AdditionalModifiers( + public val content: SourceSetDependent> +) : ExtraProperty { + + public companion object : ExtraProperty.Key { override fun mergeStrategyFor( left: AdditionalModifiers, right: AdditionalModifiers @@ -19,23 +22,23 @@ class AdditionalModifiers(val content: SourceSetDependent>) 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 = AdditionalModifiers } -fun SourceSetDependent>.toAdditionalModifiers() = AdditionalModifiers(this) +public fun SourceSetDependent>.toAdditionalModifiers(): AdditionalModifiers = AdditionalModifiers(this) -data class Annotations( +public data class Annotations( private val myContent: SourceSetDependent> ) : ExtraProperty { - companion object : ExtraProperty.Key { + public companion object : ExtraProperty.Key { override fun mergeStrategyFor(left: Annotations, right: Annotations): MergeStrategy = MergeStrategy.Replace(Annotations(left.myContent + right.myContent)) } override val key: ExtraProperty.Key = Annotations - data class Annotation( + public data class Annotation( val dri: DRI, val params: Map, 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>.toAnnotations() = Annotations(this) +public fun SourceSetDependent>.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() + +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() -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, ExtraProperty.Key { +public object PrimaryConstructorExtra : ExtraProperty, ExtraProperty.Key { override val key: ExtraProperty.Key = this } -data class ActualTypealias( +public data class ActualTypealias( val typeAlias: DTypeAlias ) : ExtraProperty { @@ -117,11 +129,11 @@ data class ActualTypealias( val underlyingType: SourceSetDependent get() = typeAlias.underlyingType - companion object : ExtraProperty.Key { + public companion object : ExtraProperty.Key { override fun mergeStrategyFor( left: ActualTypealias, right: ActualTypealias - ) = MergeStrategy.Fail { + ): MergeStrategy = 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 da469eecbd..7203ab1844 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, ) { - fun allImplementedInterfaces(): List { + public fun allImplementedInterfaces(): List { fun traverseInterfaces(ancestry: AncestryNode): List = 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 7c9461ccd2..252560225f 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 6d4b2ac05d..426954fb77 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): ExtraProperty { +public class DefaultValue( + public val expression: SourceSetDependent +): ExtraProperty { @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 { + + public companion object : ExtraProperty.Key { override fun mergeStrategyFor(left: DefaultValue, right: DefaultValue): MergeStrategy = MergeStrategy.Replace(DefaultValue(left.expression + right.expression)) @@ -22,10 +25,10 @@ class DefaultValue(val expression: SourceSetDependent): 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 ead64774b6..f4cb9b332f 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 { - abstract val params: Map +public sealed class DocTag : WithChildren { + public abstract val params: Map - companion object { - fun contentTypeParam(type: String): Map = mapOf("content-type" to type) + public companion object { + public fun contentTypeParam(type: String): Map = mapOf("content-type" to type) } } -data class A( +public data class A( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Big( +public data class Big( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class B( +public data class B( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class BlockQuote( +public data class BlockQuote( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -object Br : DocTag() { - override val params = emptyMap() - override val children = emptyList() +public object Br : DocTag() { + override val children: List = emptyList() + override val params: Map = emptyMap() } -data class Cite( +public data class Cite( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -sealed class Code : DocTag() +public sealed class Code : DocTag() -data class CodeInline( +public data class CodeInline( override val children: List = emptyList(), override val params: Map = emptyMap() ) : Code() -data class CodeBlock( +public data class CodeBlock( override val children: List = emptyList(), override val params: Map = emptyMap() ) : Code() -data class CustomDocTag( +public data class CustomDocTag( override val children: List = emptyList(), override val params: Map = emptyMap(), val name: String ) : DocTag() -data class Dd( +public data class Dd( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Dfn( +public data class Dfn( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Dir( +public data class Dir( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Div( +public data class Div( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Dl( +public data class Dl( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class DocumentationLink( +public data class DocumentationLink( val dri: DRI, override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Dt( +public data class Dt( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Em( +public data class Em( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Font( +public data class Font( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Footer( +public data class Footer( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Frame( +public data class Frame( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class FrameSet( +public data class FrameSet( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class H1( +public data class H1( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class H2( +public data class H2( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class H3( +public data class H3( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class H4( +public data class H4( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class H5( +public data class H5( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class H6( +public data class H6( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Head( +public data class Head( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Header( +public data class Header( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -object HorizontalRule : DocTag() { - override val params = emptyMap() - override val children = emptyList() +public object HorizontalRule : DocTag() { + override val children: List = emptyList() + override val params: Map = emptyMap() } -data class Html( +public data class Html( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class I( +public data class I( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class IFrame( +public data class IFrame( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Img( +public data class Img( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Index( +public data class Index( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Input( +public data class Input( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Li( +public data class Li( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Link( +public data class Link( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Listing( +public data class Listing( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Main( +public data class Main( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Menu( +public data class Menu( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Meta( +public data class Meta( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Nav( +public data class Nav( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class NoFrames( +public data class NoFrames( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class NoScript( +public data class NoScript( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Ol( +public data class Ol( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class P( +public data class P( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Pre( +public data class Pre( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Script( +public data class Script( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Section( +public data class Section( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Small( +public data class Small( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Span( +public data class Span( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Strikethrough( +public data class Strikethrough( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Strong( +public data class Strong( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Sub( +public data class Sub( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Sup( +public data class Sup( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Table( +public data class Table( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Text( +public data class Text( val body: String = "", override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class TBody( +public data class TBody( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Td( +public data class Td( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class TFoot( +public data class TFoot( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Th( +public data class Th( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class THead( +public data class THead( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Title( +public data class Title( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Tr( +public data class Tr( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Tt( +public data class Tt( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class U(override val children: List = emptyList(), override val params: Map = emptyMap()) : - DocTag() +public data class U( + override val children: List = emptyList(), + override val params: Map = emptyMap() +) : DocTag() -data class Ul( +public data class Ul( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Var( +public data class Var( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() -data class Caption( +public data class Caption( override val children: List = emptyList(), override val params: Map = emptyMap() ) : DocTag() + diff --git a/core/src/main/kotlin/model/doc/DocumentationNode.kt b/core/src/main/kotlin/model/doc/DocumentationNode.kt index 1066d9416b..9c270f79a4 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): WithChildren +public data class DocumentationNode(override val children: List): WithChildren diff --git a/core/src/main/kotlin/model/doc/TagWrapper.kt b/core/src/main/kotlin/model/doc/TagWrapper.kt index 45a0b61a80..e3eaffb7c0 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 { - abstract val root: DocTag +public sealed class TagWrapper : WithChildren { + public abstract val root: DocTag + override val children: List 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 dc6456f86b..b0ebb6ef18 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) : ExtraProperty { - companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: InheritedMember, right: InheritedMember) = MergeStrategy.Replace( +public data class InheritedMember(val inheritedFrom: SourceSetDependent) : ExtraProperty { + public companion object : ExtraProperty.Key { + override fun mergeStrategyFor(left: InheritedMember, right: InheritedMember): MergeStrategy = 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 = InheritedMember } -data class ImplementedInterfaces(val interfaces: SourceSetDependent>) : ExtraProperty { - companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: ImplementedInterfaces, right: ImplementedInterfaces) = +public data class ImplementedInterfaces(val interfaces: SourceSetDependent>) : ExtraProperty { + public companion object : ExtraProperty.Key { + override fun mergeStrategyFor(left: ImplementedInterfaces, right: ImplementedInterfaces): MergeStrategy = MergeStrategy.Replace(ImplementedInterfaces(left.interfaces + right.interfaces)) } override val key: ExtraProperty.Key = ImplementedInterfaces } -data class ExceptionInSupertypes(val exceptions: SourceSetDependent>): ExtraProperty { - companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: ExceptionInSupertypes, right: ExceptionInSupertypes) = +public data class ExceptionInSupertypes(val exceptions: SourceSetDependent>): ExtraProperty { + public companion object : ExtraProperty.Key { + override fun mergeStrategyFor(left: ExceptionInSupertypes, right: ExceptionInSupertypes): MergeStrategy = MergeStrategy.Replace(ExceptionInSupertypes(left.exceptions + right.exceptions)) } override val key: ExtraProperty.Key = ExceptionInSupertypes } -object ObviousMember : ExtraProperty, ExtraProperty.Key { +public object ObviousMember : ExtraProperty, ExtraProperty.Key { override val key: ExtraProperty.Key = this } @@ -49,12 +49,12 @@ object ObviousMember : ExtraProperty, ExtraProperty.Key, ExtraProperty.Key { +public object IsVar : ExtraProperty, ExtraProperty.Key { override val key: ExtraProperty.Key = this } -data class IsAlsoParameter(val inSourceSets: List) : ExtraProperty { - companion object : ExtraProperty.Key { +public data class IsAlsoParameter(val inSourceSets: List) : ExtraProperty { + public companion object : ExtraProperty.Key { override fun mergeStrategyFor(left: IsAlsoParameter, right: IsAlsoParameter): MergeStrategy = MergeStrategy.Replace(IsAlsoParameter(left.inSourceSets + right.inSourceSets)) } @@ -62,9 +62,9 @@ data class IsAlsoParameter(val inSourceSets: List) : ExtraProper override val key: ExtraProperty.Key = IsAlsoParameter } -data class CheckedExceptions(val exceptions: SourceSetDependent>) : ExtraProperty, ExtraProperty.Key { - companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: CheckedExceptions, right: CheckedExceptions) = +public data class CheckedExceptions(val exceptions: SourceSetDependent>) : ExtraProperty, ExtraProperty.Key { + public companion object : ExtraProperty.Key { + override fun mergeStrategyFor(left: CheckedExceptions, right: CheckedExceptions): MergeStrategy = MergeStrategy.Replace(CheckedExceptions(left.exceptions + right.exceptions)) } override val key: ExtraProperty.Key = CheckedExceptions diff --git a/core/src/main/kotlin/model/documentableUtils.kt b/core/src/main/kotlin/model/documentableUtils.kt index 5f08a2ced0..c9d75bf419 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 SourceSetDependent.filtered(sourceSets: Set) = filter { it.key in sourceSets } -fun DokkaSourceSet?.filtered(sourceSets: Set) = takeIf { this in sourceSets } +public fun SourceSetDependent.filtered(sourceSets: Set): SourceSetDependent = filter { it.key in sourceSets } +public fun DokkaSourceSet?.filtered(sourceSets: Set): DokkaSourceSet? = takeIf { this in sourceSets } -fun DTypeParameter.filter(filteredSet: Set) = +public fun DTypeParameter.filter(filteredSet: Set): DTypeParameter? = if (filteredSet.containsAll(sourceSets)) this else { val intersection = filteredSet.intersect(sourceSets) @@ -24,4 +24,4 @@ fun DTypeParameter.filter(filteredSet: Set) = ) } -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 4eb2a01bec..f1193070b9 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 67df9148b6..8fd7ccd9e7 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 24577bd53d..7f5bb2f0d7 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 internal constructor( +public data class PropertyContainer internal constructor( @PublishedApi internal val map: Map, ExtraProperty> ) { - operator fun plus(prop: ExtraProperty): PropertyContainer = + public operator fun plus(prop: ExtraProperty): PropertyContainer = PropertyContainer(map + (prop.key to prop)) // TODO: Add logic for caching calculated properties - inline operator fun get(key: ExtraProperty.Key): T? = when (val prop = map[key]) { + public inline operator fun get(key: ExtraProperty.Key): T? = when (val prop = map[key]) { is T? -> prop else -> throw ClassCastException("Property for $key stored under not matching key type.") } - inline fun allOfType(): List = map.values.filterIsInstance() - fun addAll(extras: Collection>): PropertyContainer = + public inline fun allOfType(): List = map.values.filterIsInstance() + + public fun addAll(extras: Collection>): PropertyContainer = PropertyContainer(map + extras.map { p -> p.key to p }) - operator fun minus(prop: ExtraProperty.Key): PropertyContainer = + public operator fun minus(prop: ExtraProperty.Key): PropertyContainer = PropertyContainer(map.filterNot { it.key == prop }) - companion object { - fun empty(): PropertyContainer = PropertyContainer(emptyMap()) - fun withAll(vararg extras: ExtraProperty?) = empty().addAll(extras.filterNotNull()) - fun withAll(extras: Collection>) = empty().addAll(extras) + public companion object { + public fun empty(): PropertyContainer = PropertyContainer(emptyMap()) + public fun withAll(vararg extras: ExtraProperty?): PropertyContainer = empty().addAll(extras.filterNotNull()) + public fun withAll(extras: Collection>): PropertyContainer = empty().addAll(extras) } } -operator fun PropertyContainer.plus(prop: ExtraProperty?): PropertyContainer = +public operator fun PropertyContainer.plus(prop: ExtraProperty?): PropertyContainer = if (prop == null) this else PropertyContainer(map + (prop.key to prop)) -interface WithExtraProperties { - val extra: PropertyContainer +public interface WithExtraProperties { + public val extra: PropertyContainer - fun withNewExtras(newExtras: PropertyContainer): C + public fun withNewExtras(newExtras: PropertyContainer): C } -fun C.mergeExtras(left: C, right: C): C where C : Any, C : WithExtraProperties { +public fun C.mergeExtras(left: C, right: C): C where C : Any, C : WithExtraProperties { val aggregatedExtras: List>> = (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 e15a166819..ea76dc729d 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 { - interface Key { - fun mergeStrategyFor(left: T, right: T): MergeStrategy = MergeStrategy.Fail { +public interface ExtraProperty { + public interface Key { + public fun mergeStrategyFor(left: T, right: T): MergeStrategy = MergeStrategy.Fail { throw NotImplementedError("Property merging for $this is not implemented") } } - val key: Key + public val key: Key } -interface CalculatedProperty : ExtraProperty.Key { - fun calculate(subject: C): T +public interface CalculatedProperty : ExtraProperty.Key { + public fun calculate(subject: C): T } -sealed class MergeStrategy { - class Replace(val newProperty: ExtraProperty) : MergeStrategy() - object Remove : MergeStrategy() - class Full(val merger: (preMerged: C, left: C, right: C) -> C) : MergeStrategy() - class Fail(val error: () -> Nothing) : MergeStrategy() +public sealed class MergeStrategy { + + public class Replace( + public val newProperty: ExtraProperty + ) : MergeStrategy() + + public object Remove : MergeStrategy() + + public class Full( + public val merger: (preMerged: C, left: C, right: C) -> C + ) : MergeStrategy() + + public class Fail( + public val error: () -> Nothing + ) : MergeStrategy() } diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt index 8717827706..96f43205e8 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, val kind: Kind) { - override fun toString() = "$dri[$kind]" +public data class DCI(val dri: Set, val kind: Kind) { + override fun toString(): String = "$dri[$kind]" } -interface ContentNode : WithExtraProperties, WithChildren { - val dci: DCI - val sourceSets: Set - val style: Set