aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorVadim Mishenev <vad-mishenev@yandex.ru>2023-10-26 14:39:00 +0300
committerGitHub <noreply@github.com>2023-10-26 14:39:00 +0300
commit9b07435773831874d4d80066a2227596198af988 (patch)
tree45bdc3f88ac64ea934515a1f6b44e63e461f6ce1 /plugins
parent3be4dd94e3af2e749969ba352482eae6957cac5a (diff)
downloaddokka-9b07435773831874d4d80066a2227596198af988.tar.gz
dokka-9b07435773831874d4d80066a2227596198af988.tar.bz2
dokka-9b07435773831874d4d80066a2227596198af988.zip
[K2] Support kotlin-as-java and javadoc plugins and update version of Analysis API (#3227)
* Implement InheritanceBuilder and for symbols * Enable tests for as-java and javadoc plugins and fix some * Update the version of Analysis API and enable test * Use assert from kotlin.test * Rename `descriptorInheritanceBuilder` * Fix after rebasing * Mute test `two classes from different packages`
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/test/kotlin/model/ClassesTest.kt15
-rw-r--r--plugins/javadoc/build.gradle.kts7
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/AbstractJavadocTemplateMapTest.kt1
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAccessorNamingTest.kt23
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAllClassesTemplateMapTest.kt2
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocIndexTest.kt17
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt1
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/validity/MultiplatformConfiguredCheckerTest.kt8
-rw-r--r--plugins/kotlin-as-java/build.gradle.kts7
-rw-r--r--plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt1
-rw-r--r--plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaSignatureTest.kt1
11 files changed, 70 insertions, 13 deletions
diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt
index 763809e8..c18dfafb 100644
--- a/plugins/base/src/test/kotlin/model/ClassesTest.kt
+++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt
@@ -126,6 +126,21 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
type.name equals "Unit"
}
}
+
+ with((this.companion).cast<DObject>()) {
+ name equals "Companion"
+ children counts 5
+
+ with((this / "x").cast<DProperty>()) {
+ name equals "x"
+ }
+
+ with((this / "foo").cast<DFunction>()) {
+ name equals "foo"
+ parameters counts 0
+ type.name equals "Unit"
+ }
+ }
}
}
}
diff --git a/plugins/javadoc/build.gradle.kts b/plugins/javadoc/build.gradle.kts
index 2a04366b..ea882bb4 100644
--- a/plugins/javadoc/build.gradle.kts
+++ b/plugins/javadoc/build.gradle.kts
@@ -7,6 +7,7 @@ import org.jetbrains.registerDokkaArtifactPublication
plugins {
id("org.jetbrains.conventions.kotlin-jvm")
id("org.jetbrains.conventions.maven-publish")
+ id("org.jetbrains.conventions.base-unit-test")
}
dependencies {
@@ -22,7 +23,11 @@ dependencies {
implementation(libs.kotlinx.coroutines.core)
testImplementation(kotlin("test"))
- testImplementation(projects.plugins.base.baseTestUtils)
+ symbolsTestConfiguration(project(path = ":subprojects:analysis-kotlin-symbols", configuration = "shadow"))
+ descriptorsTestConfiguration(project(path = ":subprojects:analysis-kotlin-descriptors", configuration = "shadow"))
+ testImplementation(projects.plugins.base.baseTestUtils) {
+ exclude(module = "analysis-kotlin-descriptors")
+ }
testImplementation(projects.core.testApi)
testImplementation(libs.jsoup)
}
diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/AbstractJavadocTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/AbstractJavadocTemplateMapTest.kt
index 070f1834..60265e33 100644
--- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/AbstractJavadocTemplateMapTest.kt
+++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/AbstractJavadocTemplateMapTest.kt
@@ -28,6 +28,7 @@ internal abstract class AbstractJavadocTemplateMapTest : BaseAbstractTest() {
DokkaConfiguration.ExternalDocumentationLink.jdk(8),
DokkaConfiguration.ExternalDocumentationLink.kotlinStdlib()
)
+ classpath = listOfNotNull(jvmStdlibPath)
}
}
}
diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAccessorNamingTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAccessorNamingTest.kt
index 3f7e1610..95ce4d27 100644
--- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAccessorNamingTest.kt
+++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAccessorNamingTest.kt
@@ -8,6 +8,7 @@ import org.jsoup.Jsoup
import utils.TestOutputWriterPlugin
import kotlin.test.Test
import kotlin.test.assertEquals
+import kotlin.test.assertTrue
internal class JavadocAccessorNamingTest : AbstractJavadocTemplateMapTest() {
@@ -16,6 +17,7 @@ internal class JavadocAccessorNamingTest : AbstractJavadocTemplateMapTest() {
sourceSets {
sourceSet {
sourceRoots = listOf("src/main/kotlin")
+ classpath = listOfNotNull(jvmStdlibPath)
}
}
}
@@ -54,13 +56,20 @@ internal class JavadocAccessorNamingTest : AbstractJavadocTemplateMapTest() {
.select("code")
.map { it.text() }
.toSet()
-
- assertEquals(setOf(
- "getIssuesFetched()",
- "setIssuesFetched(Integer issuesFetched)",
- "isFoo()",
- "setFoo(String isFoo)",
- ), props)
+ // In K2 name of accessors parameter is `value`
+ assertTrue(
+ setOf(
+ "getIssuesFetched()",
+ "setIssuesFetched(Integer issuesFetched)",
+ "isFoo()",
+ "setFoo(String isFoo)",
+ ) == props || setOf(
+ "getIssuesFetched()",
+ "setIssuesFetched(Integer value)",
+ "isFoo()",
+ "setFoo(String value)",
+ ) == props
+ )
val descriptionLinks = html
.select("div.description")
diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAllClassesTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAllClassesTemplateMapTest.kt
index a399f523..8d7ff1ea 100644
--- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAllClassesTemplateMapTest.kt
+++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAllClassesTemplateMapTest.kt
@@ -8,11 +8,13 @@ import org.jetbrains.dokka.javadoc.pages.AllClassesPage
import org.jetbrains.dokka.javadoc.pages.LinkJavadocListEntry
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.pages.ContentKind
+import org.junit.jupiter.api.Tag
import kotlin.test.Test
import kotlin.test.assertEquals
internal class JavadocAllClassesTemplateMapTest : AbstractJavadocTemplateMapTest() {
@Test
+ @Tag("onlyDescriptors") // https://github.com/Kotlin/dokka/issues/3250
fun `two classes from different packages`() {
dualTestTemplateMapInline(
"""
diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocIndexTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocIndexTest.kt
index ec36d0e3..ba8f73cf 100644
--- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocIndexTest.kt
+++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocIndexTest.kt
@@ -7,6 +7,7 @@ package org.jetbrains.dokka.javadoc
import org.jetbrains.dokka.javadoc.pages.IndexPage
import org.jetbrains.dokka.javadoc.renderer.TemplateMap
import org.jetbrains.dokka.links.DRI
+import org.junit.jupiter.api.Tag
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
@@ -76,7 +77,21 @@ internal class JavadocIndexTest : AbstractJavadocTemplateMapTest() {
AnnotationTarget.ANNOTATION_CLASS::class.java.methods.any { it.name == "describeConstable" }
testIndexPages(commonTestQuery) { indexPages ->
- assertEquals(if (hasAdditionalFunction()) 33 else 32, indexPages.sumBy { it.elements.size })
+ assertEquals("A-index: a, A\n" +
+ "B-index: b\n" +
+ "C-index: c, ClassA, ClassB, ClassC, ClassC.InnerClass, ClassCEnum, compareTo\n" +
+ "D-index: d, D\n" +
+ "E-index: e, E, equals, equals\n" +
+ "F-index: f\n" +
+ "G-index: g, getDeclaringClass, getEntries, getName, getOrdinal\n" +
+ "H-index: h, hashCode, hashCode\n" +
+ "J-index: j\n" +
+ "K-index: k\n" +
+ "P-index: package0, package1\n" +
+ "T-index: toString, toString\n" +
+ "V-index: valueOf, values",
+ indexPages.joinToString("\n") { it.title + ": " + it.elements.joinToString { it.getId() } })
+ assertEquals(if (hasAdditionalFunction()) 34 else 33, indexPages.sumBy { it.elements.size })
}
}
diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt
index 60de0e3d..bef81372 100644
--- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt
+++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationTest.kt
@@ -247,6 +247,7 @@ class JavadocLocationTest : BaseAbstractTest() {
DokkaConfiguration.ExternalDocumentationLink.kotlinStdlib()
)
analysisPlatform = "jvm"
+ classpath = listOfNotNull(jvmStdlibPath)
}
}
}
diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/validity/MultiplatformConfiguredCheckerTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/validity/MultiplatformConfiguredCheckerTest.kt
index 0bd6c4d5..cea32026 100644
--- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/validity/MultiplatformConfiguredCheckerTest.kt
+++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/validity/MultiplatformConfiguredCheckerTest.kt
@@ -18,7 +18,7 @@ class MultiplatformConfiguredCheckerTest : BaseAbstractTest() {
format = "javadoc"
sourceSets {
sourceSet {
- sourceRoots = listOf("src")
+ sourceRoots = listOf("src/jvm")
analysisPlatform = "jvm"
externalDocumentationLinks = listOf(
ExternalDocumentationLink("https://docs.oracle.com/javase/8/docs/api/"),
@@ -26,7 +26,7 @@ class MultiplatformConfiguredCheckerTest : BaseAbstractTest() {
)
}
sourceSet {
- sourceRoots = listOf("src")
+ sourceRoots = listOf("src/js")
analysisPlatform = "js"
externalDocumentationLinks = listOf(
ExternalDocumentationLink("https://docs.oracle.com/javase/8/docs/api/"),
@@ -54,7 +54,9 @@ class MultiplatformConfiguredCheckerTest : BaseAbstractTest() {
fun `mpp config should fail for javadoc`() {
testInline(
"""
- |/src/main/kotlin/example/Test.kt
+ |/src/jvm/kotlin/example/Test.kt
+ |class Test
+ |/src/js/kotlin/example/Test.kt
|class Test
""".trimMargin(), mppConfig
) {
diff --git a/plugins/kotlin-as-java/build.gradle.kts b/plugins/kotlin-as-java/build.gradle.kts
index 19a7bf78..0b855895 100644
--- a/plugins/kotlin-as-java/build.gradle.kts
+++ b/plugins/kotlin-as-java/build.gradle.kts
@@ -7,6 +7,7 @@ import org.jetbrains.registerDokkaArtifactPublication
plugins {
id("org.jetbrains.conventions.kotlin-jvm")
id("org.jetbrains.conventions.maven-publish")
+ id("org.jetbrains.conventions.base-unit-test")
}
dependencies {
@@ -20,7 +21,11 @@ dependencies {
testImplementation(kotlin("test"))
testImplementation(libs.jsoup)
testImplementation(projects.plugins.base)
- testImplementation(projects.plugins.base.baseTestUtils)
+ symbolsTestConfiguration(project(path = ":subprojects:analysis-kotlin-symbols", configuration = "shadow"))
+ descriptorsTestConfiguration(project(path = ":subprojects:analysis-kotlin-descriptors", configuration = "shadow"))
+ testImplementation(projects.plugins.base.baseTestUtils) {
+ exclude(module = "analysis-kotlin-descriptors")
+ }
testImplementation(projects.core.contentMatcherTestUtils)
testImplementation(projects.core.testApi)
}
diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
index f6124f88..93d5c1b5 100644
--- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
+++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
@@ -377,6 +377,7 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() {
DokkaConfiguration.ExternalDocumentationLink.jdk(8),
stdlibExternalDocumentationLink
)
+ classpath = listOfNotNull(jvmStdlibPath)
}
}
}
diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaSignatureTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaSignatureTest.kt
index c87fda5e..25312810 100644
--- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaSignatureTest.kt
+++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaSignatureTest.kt
@@ -23,6 +23,7 @@ class KotlinAsJavaSignatureTest : BaseAbstractTest() {
DokkaConfiguration.ExternalDocumentationLink.jdk(8),
stdlibExternalDocumentationLink
)
+ classpath = listOfNotNull(jvmStdlibPath)
}
}
}