diff options
46 files changed, 2365 insertions, 41 deletions
diff --git a/core/api/core.api b/core/api/core.api index 2399880b..fffcb877 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -4513,6 +4513,32 @@ public abstract interface class org/jetbrains/dokka/renderers/Renderer { public abstract fun render (Lorg/jetbrains/dokka/pages/RootPageNode;)V } +public final class org/jetbrains/dokka/transformers/documentation/ClashingDriIdentifier : org/jetbrains/dokka/model/properties/ExtraProperty { + public static final field Companion Lorg/jetbrains/dokka/transformers/documentation/ClashingDriIdentifier$Companion; + public fun <init> (Ljava/util/Set;)V + public final fun component1 ()Ljava/util/Set; + public final fun copy (Ljava/util/Set;)Lorg/jetbrains/dokka/transformers/documentation/ClashingDriIdentifier; + public static synthetic fun copy$default (Lorg/jetbrains/dokka/transformers/documentation/ClashingDriIdentifier;Ljava/util/Set;ILjava/lang/Object;)Lorg/jetbrains/dokka/transformers/documentation/ClashingDriIdentifier; + public fun equals (Ljava/lang/Object;)Z + public fun getKey ()Lorg/jetbrains/dokka/model/properties/ExtraProperty$Key; + public final fun getValue ()Ljava/util/Set; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class org/jetbrains/dokka/transformers/documentation/ClashingDriIdentifier$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/transformers/documentation/ClashingDriIdentifier;Lorg/jetbrains/dokka/transformers/documentation/ClashingDriIdentifier;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; +} + +public final class org/jetbrains/dokka/transformers/documentation/DefaultDocumentableMerger : org/jetbrains/dokka/transformers/documentation/DocumentableMerger { + public fun <init> (Lorg/jetbrains/dokka/plugability/DokkaContext;)V + public fun invoke (Ljava/util/Collection;)Lorg/jetbrains/dokka/model/DModule; + public final fun mergeWith (Lorg/jetbrains/dokka/model/DFunction;Lorg/jetbrains/dokka/model/DFunction;)Lorg/jetbrains/dokka/model/DFunction; + public final fun mergeWith (Lorg/jetbrains/dokka/model/DPackage;Lorg/jetbrains/dokka/model/DPackage;)Lorg/jetbrains/dokka/model/DPackage; + public final fun mergeWith (Lorg/jetbrains/dokka/model/DProperty;Lorg/jetbrains/dokka/model/DProperty;)Lorg/jetbrains/dokka/model/DProperty; +} + public abstract interface class org/jetbrains/dokka/transformers/documentation/DocumentableMerger { public abstract fun invoke (Ljava/util/Collection;)Lorg/jetbrains/dokka/model/DModule; } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt b/core/src/main/kotlin/transformers/documentation/DefaultDocumentableMerger.kt index ec53df78..fe1e5d64 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt +++ b/core/src/main/kotlin/transformers/documentation/DefaultDocumentableMerger.kt @@ -2,18 +2,27 @@ * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -package org.jetbrains.dokka.base.transformers.documentables +package org.jetbrains.dokka.transformers.documentation import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.base.utils.firstNotNullOfOrNull +import org.jetbrains.dokka.InternalDokkaApi import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy import org.jetbrains.dokka.model.properties.mergeExtras import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.transformers.documentation.DocumentableMerger +import org.jetbrains.dokka.CoreExtensions -internal class DefaultDocumentableMerger(val context: DokkaContext) : DocumentableMerger { +/** + * Should NOT be used outside of Dokka itself, there are no guarantees + * this class will continue to exist in future releases. + * + * This class resides in core because it is a non-trivial implementation + * for a core extension [CoreExtensions.documentableMerger], which is needed + * in modules that only have access to `dokka-core`. + */ +@InternalDokkaApi +public class DefaultDocumentableMerger(context: DokkaContext) : DocumentableMerger { private val dependencyInfo = context.getDependencyInfo() override fun invoke(modules: Collection<DModule>): DModule? = @@ -123,7 +132,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab } } - fun DPackage.mergeWith(other: DPackage): DPackage = copy( + public fun DPackage.mergeWith(other: DPackage): DPackage = copy( functions = mergeExpectActual(functions + other.functions) { f1, f2 -> f1.mergeWith(f2) }, properties = mergeExpectActual(properties + other.properties) { p1, p2 -> p1.mergeWith(p2) }, classlikes = mergeExpectActual(classlikes + other.classlikes) { c1, c2 -> c1.mergeWith(c2) }, @@ -133,7 +142,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) - fun DFunction.mergeWith(other: DFunction): DFunction = copy( + public fun DFunction.mergeWith(other: DFunction): DFunction = copy( parameters = merge(this.parameters + other.parameters) { p1, p2 -> p1.mergeWith(p2) }, receiver = receiver?.let { r -> other.receiver?.let { r.mergeWith(it) } ?: r } ?: other.receiver, documentation = documentation + other.documentation, @@ -145,7 +154,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab generics = merge(generics + other.generics) { tp1, tp2 -> tp1.mergeWith(tp2) }, ).mergeExtras(this, other) - fun DProperty.mergeWith(other: DProperty): DProperty = copy( + public fun DProperty.mergeWith(other: DProperty): DProperty = copy( receiver = receiver?.let { r -> other.receiver?.let { r.mergeWith(it) } ?: r } ?: other.receiver, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, @@ -158,7 +167,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab generics = merge(generics + other.generics) { tp1, tp2 -> tp1.mergeWith(tp2) }, ).mergeExtras(this, other) - fun DClasslike.mergeWith(other: DClasslike): DClasslike = when { + private fun DClasslike.mergeWith(other: DClasslike): DClasslike = when { this is DClass && other is DClass -> mergeWith(other) this is DEnum && other is DEnum -> mergeWith(other) this is DInterface && other is DInterface -> mergeWith(other) @@ -167,7 +176,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab else -> throw IllegalStateException("${this::class.qualifiedName} ${this.name} cannot be merged with ${other::class.qualifiedName} ${other.name}") } - fun DClass.mergeWith(other: DClass): DClass = copy( + private fun DClass.mergeWith(other: DClass): DClass = copy( constructors = mergeExpectActual( constructors + other.constructors ) { f1, f2 -> f1.mergeWith(f2) }, @@ -185,7 +194,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) - fun DEnum.mergeWith(other: DEnum): DEnum = copy( + private fun DEnum.mergeWith(other: DEnum): DEnum = copy( entries = merge(entries + other.entries) { ee1, ee2 -> ee1.mergeWith(ee2) }, constructors = mergeExpectActual( constructors + other.constructors @@ -202,7 +211,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) - fun DEnumEntry.mergeWith(other: DEnumEntry): DEnumEntry = copy( + private fun DEnumEntry.mergeWith(other: DEnumEntry): DEnumEntry = copy( functions = mergeExpectActual(functions + other.functions) { f1, f2 -> f1.mergeWith(f2) }, properties = mergeExpectActual(properties + other.properties) { p1, p2 -> p1.mergeWith(p2) }, classlikes = mergeExpectActual(classlikes + other.classlikes) { c1, c2 -> c1.mergeWith(c2) }, @@ -211,7 +220,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) - fun DObject.mergeWith(other: DObject): DObject = copy( + private fun DObject.mergeWith(other: DObject): DObject = copy( functions = mergeExpectActual(functions + other.functions) { f1, f2 -> f1.mergeWith(f2) }, properties = mergeExpectActual(properties + other.properties) { p1, p2 -> p1.mergeWith(p2) }, classlikes = mergeExpectActual(classlikes + other.classlikes) { c1, c2 -> c1.mergeWith(c2) }, @@ -223,7 +232,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) - fun DInterface.mergeWith(other: DInterface): DInterface = copy( + private fun DInterface.mergeWith(other: DInterface): DInterface = copy( functions = mergeExpectActual(functions + other.functions) { f1, f2 -> f1.mergeWith(f2) }, properties = mergeExpectActual(properties + other.properties) { p1, p2 -> p1.mergeWith(p2) }, classlikes = mergeExpectActual(classlikes + other.classlikes) { c1, c2 -> c1.mergeWith(c2) }, @@ -237,7 +246,7 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) - fun DAnnotation.mergeWith(other: DAnnotation): DAnnotation = copy( + private fun DAnnotation.mergeWith(other: DAnnotation): DAnnotation = copy( constructors = mergeExpectActual( constructors + other.constructors ) { f1, f2 -> f1.mergeWith(f2) }, @@ -253,19 +262,19 @@ internal class DefaultDocumentableMerger(val context: DokkaContext) : Documentab generics = merge(generics + other.generics) { tp1, tp2 -> tp1.mergeWith(tp2) } ).mergeExtras(this, other) - fun DParameter.mergeWith(other: DParameter): DParameter = copy( + private fun DParameter.mergeWith(other: DParameter): DParameter = copy( documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) - fun DTypeParameter.mergeWith(other: DTypeParameter): DTypeParameter = copy( + private fun DTypeParameter.mergeWith(other: DTypeParameter): DTypeParameter = copy( documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) - fun DTypeAlias.mergeWith(other: DTypeAlias): DTypeAlias = copy( + private fun DTypeAlias.mergeWith(other: DTypeAlias): DTypeAlias = copy( documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, underlyingType = underlyingType + other.underlyingType, @@ -285,3 +294,14 @@ public data class ClashingDriIdentifier(val value: Set<DokkaConfiguration.DokkaS override val key: ExtraProperty.Key<Documentable, *> = ClashingDriIdentifier } + +// TODO [beresnev] remove this copy-paste and use the same method from stdlib instead after updating to 1.5 +private inline fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(transform: (T) -> R?): R? { + for (element in this) { + val result = transform(element) + if (result != null) { + return result + } + } + return null +} diff --git a/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt b/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt index 23300190..0958ea14 100644 --- a/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt +++ b/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt @@ -113,7 +113,7 @@ public abstract class AbstractTest<M : TestMethods, T : TestBuilder<M>, D : Dokk block(tempDir) } finally { if (cleanUpAfterUse) { - tempDir.delete() + tempDir.deleteRecursively() } } } diff --git a/plugins/base/api/base.api b/plugins/base/api/base.api index 788444b9..ae872558 100644 --- a/plugins/base/api/base.api +++ b/plugins/base/api/base.api @@ -1102,24 +1102,6 @@ public final class org/jetbrains/dokka/base/transformers/documentables/CallableE public fun mergeStrategyFor (Lorg/jetbrains/dokka/base/transformers/documentables/CallableExtensions;Lorg/jetbrains/dokka/base/transformers/documentables/CallableExtensions;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; } -public final class org/jetbrains/dokka/base/transformers/documentables/ClashingDriIdentifier : org/jetbrains/dokka/model/properties/ExtraProperty { - public static final field Companion Lorg/jetbrains/dokka/base/transformers/documentables/ClashingDriIdentifier$Companion; - public fun <init> (Ljava/util/Set;)V - public final fun component1 ()Ljava/util/Set; - public final fun copy (Ljava/util/Set;)Lorg/jetbrains/dokka/base/transformers/documentables/ClashingDriIdentifier; - public static synthetic fun copy$default (Lorg/jetbrains/dokka/base/transformers/documentables/ClashingDriIdentifier;Ljava/util/Set;ILjava/lang/Object;)Lorg/jetbrains/dokka/base/transformers/documentables/ClashingDriIdentifier; - public fun equals (Ljava/lang/Object;)Z - public fun getKey ()Lorg/jetbrains/dokka/model/properties/ExtraProperty$Key; - public final fun getValue ()Ljava/util/Set; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class org/jetbrains/dokka/base/transformers/documentables/ClashingDriIdentifier$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/base/transformers/documentables/ClashingDriIdentifier;Lorg/jetbrains/dokka/base/transformers/documentables/ClashingDriIdentifier;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; -} - public final class org/jetbrains/dokka/base/transformers/documentables/DeprecatedDocumentableFilterTransformer : org/jetbrains/dokka/base/transformers/documentables/SuppressedByConditionDocumentableFilterTransformer { public fun <init> (Lorg/jetbrains/dokka/plugability/DokkaContext;)V public fun shouldBeSuppressed (Lorg/jetbrains/dokka/model/Documentable;)Z diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt index dfec2c15..ca86d4d5 100644 --- a/plugins/base/src/main/kotlin/DokkaBase.kt +++ b/plugins/base/src/main/kotlin/DokkaBase.kt @@ -33,10 +33,7 @@ import org.jetbrains.dokka.base.translators.documentables.DefaultDocumentableToP import org.jetbrains.dokka.generation.Generation import org.jetbrains.dokka.plugability.* import org.jetbrains.dokka.renderers.Renderer -import org.jetbrains.dokka.transformers.documentation.DocumentableMerger -import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator -import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer -import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer +import org.jetbrains.dokka.transformers.documentation.* import org.jetbrains.dokka.transformers.pages.PageTransformer @Suppress("unused") diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ClashingDriIdentifier.kt b/plugins/base/src/main/kotlin/transformers/documentables/ClashingDriIdentifier.kt new file mode 100644 index 00000000..e9c7342e --- /dev/null +++ b/plugins/base/src/main/kotlin/transformers/documentables/ClashingDriIdentifier.kt @@ -0,0 +1,12 @@ +/* + * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package org.jetbrains.dokka.base.transformers.documentables + +@Deprecated( + message = "Declaration was moved to dokka-core", + replaceWith = ReplaceWith("org.jetbrains.dokka.transformers.documentation.ClashingDriIdentifier"), + level = DeprecationLevel.WARNING // TODO change to error after Kotlin 1.9.20 +) +public typealias ClashingDriIdentifier = org.jetbrains.dokka.transformers.documentation.ClashingDriIdentifier diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 58abee56..5c8ac512 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -9,7 +9,7 @@ import org.jetbrains.dokka.base.DokkaBaseConfiguration import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.documentables.CallableExtensions -import org.jetbrains.dokka.base.transformers.documentables.ClashingDriIdentifier +import org.jetbrains.dokka.transformers.documentation.ClashingDriIdentifier import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.base.transformers.pages.tags.CustomTagContentProvider import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder.DocumentableContentBuilder diff --git a/subprojects/analysis-kotlin-api/build.gradle.kts b/subprojects/analysis-kotlin-api/build.gradle.kts index 58247479..bf3b5b3c 100644 --- a/subprojects/analysis-kotlin-api/build.gradle.kts +++ b/subprojects/analysis-kotlin-api/build.gradle.kts @@ -7,10 +7,30 @@ import org.jetbrains.registerDokkaArtifactPublication plugins { id("org.jetbrains.conventions.kotlin-jvm") id("org.jetbrains.conventions.maven-publish") + `java-test-fixtures` } dependencies { compileOnly(projects.core) + + testFixturesApi(projects.core) + + testImplementation(kotlin("test")) + testImplementation(projects.subprojects.analysisKotlinDescriptors) +} + +disableTestFixturesPublishing() + +/** + * Test fixtures are automatically published by default, which at this moment in time is unwanted + * as the test api is unstable and is internal to the Dokka project, so it shouldn't be used outside of it. + * + * @see https://docs.gradle.org/current/userguide/java_testing.html#ex-disable-publishing-of-test-fixtures-variants + */ +fun disableTestFixturesPublishing() { + val javaComponent = components["java"] as AdhocComponentWithVariants + javaComponent.withVariantsFromConfiguration(configurations["testFixturesApiElements"]) { skip() } + javaComponent.withVariantsFromConfiguration(configurations["testFixturesRuntimeElements"]) { skip() } } registerDokkaArtifactPublication("analysisKotlinApi") { diff --git a/subprojects/analysis-kotlin-api/src/test/kotlin/org/jetbrains/dokka/analysis/test/jvm/java/SampleJavaAnalysisTest.kt b/subprojects/analysis-kotlin-api/src/test/kotlin/org/jetbrains/dokka/analysis/test/jvm/java/SampleJavaAnalysisTest.kt new file mode 100644 index 00000000..f6632f60 --- /dev/null +++ b/subprojects/analysis-kotlin-api/src/test/kotlin/org/jetbrains/dokka/analysis/test/jvm/java/SampleJavaAnalysisTest.kt @@ -0,0 +1,49 @@ +/* + * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package org.jetbrains.dokka.analysis.test.jvm.java + +import org.jetbrains.dokka.analysis.test.api.javaTestProject +import org.jetbrains.dokka.analysis.test.api.parse +import kotlin.test.Test +import kotlin.test.assertEquals + +class SampleJavaAnalysisTest { + + /** + * Used as a sample for [javaTestProject] + */ + @Test + fun sample() { + val testProject = javaTestProject { + dokkaConfiguration { + moduleName = "java-module-name-for-unit-test" + + javaSourceSet { + // source-set specific configuration + } + } + javaFile(pathFromSrc = "org/jetbrains/dokka/test/java/Bar.java") { + +""" + public class Bar { + public static void bar() { + System.out.println("Bar"); + } + } + """ + } + } + + val module = testProject.parse() + assertEquals("java-module-name-for-unit-test", module.name) + assertEquals(1, module.packages.size) + + val pckg = module.packages[0] + assertEquals("org.jetbrains.dokka.test.java", pckg.name) + assertEquals(1, pckg.classlikes.size) + + val fooClass = pckg.classlikes[0] + assertEquals("Bar", fooClass.name) + } +} diff --git a/subprojects/analysis-kotlin-api/src/test/kotlin/org/jetbrains/dokka/analysis/test/jvm/kotlin/SampleKotlinJvmAnalysisTest.kt b/subprojects/analysis-kotlin-api/src/test/kotlin/org/jetbrains/dokka/analysis/test/jvm/kotlin/SampleKotlinJvmAnalysisTest.kt new file mode 100644 index 00000000..6c73af1f --- /dev/null +++ b/subprojects/analysis-kotlin-api/src/test/kotlin/or |
