diff --git a/plugins/base/src/test/kotlin/translators/ExternalDocumentablesTest.kt b/plugins/base/src/test/kotlin/translators/ExternalDocumentablesTest.kt index 1879c5380e..b3a5a9552a 100644 --- a/plugins/base/src/test/kotlin/translators/ExternalDocumentablesTest.kt +++ b/plugins/base/src/test/kotlin/translators/ExternalDocumentablesTest.kt @@ -4,7 +4,8 @@ package translators -import org.jetbrains.dokka.analysis.kotlin.internal.ExternalDocumentablesProvider +import org.jetbrains.dokka.analysis.kotlin.KotlinAnalysisPlugin +import org.jetbrains.dokka.analysis.kotlin.documentable.ExternalDocumentableProvider import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest import org.jetbrains.dokka.model.DClass @@ -36,9 +37,9 @@ class ExternalDocumentablesTest : BaseAbstractTest() { """.trimIndent(), configuration ) { - lateinit var provider: ExternalDocumentablesProvider + lateinit var provider: ExternalDocumentableProvider pluginsSetupStage = { - provider = it.plugin().querySingle { externalDocumentablesProvider } + provider = it.plugin().querySingle { externalDocumentableProvider } } documentablesTransformationStage = { mod -> val entry = mod.packages.single().classlikes.single().cast().supertypes.entries.single() @@ -85,9 +86,9 @@ class ExternalDocumentablesTest : BaseAbstractTest() { """.trimIndent(), configuration ) { - lateinit var provider: ExternalDocumentablesProvider + lateinit var provider: ExternalDocumentableProvider pluginsSetupStage = { - provider = it.plugin().querySingle { externalDocumentablesProvider } + provider = it.plugin().querySingle { externalDocumentableProvider } } documentablesTransformationStage = { mod -> val entry = mod.packages.single().classlikes.single().cast().supertypes.entries.single() @@ -127,9 +128,9 @@ class ExternalDocumentablesTest : BaseAbstractTest() { """.trimIndent(), configuration ) { - lateinit var provider: ExternalDocumentablesProvider + lateinit var provider: ExternalDocumentableProvider pluginsSetupStage = { - provider = it.plugin().querySingle { externalDocumentablesProvider } + provider = it.plugin().querySingle { externalDocumentableProvider } } documentablesTransformationStage = { mod -> val entry = mod.packages.single().classlikes.single().cast().supertypes.entries.single() diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/KotlinAnalysisPlugin.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/KotlinAnalysisPlugin.kt index 1df1dfe6d3..421242b7d8 100644 --- a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/KotlinAnalysisPlugin.kt +++ b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/KotlinAnalysisPlugin.kt @@ -4,6 +4,7 @@ package org.jetbrains.dokka.analysis.kotlin +import org.jetbrains.dokka.analysis.kotlin.documentable.ExternalDocumentableProvider import org.jetbrains.dokka.analysis.kotlin.sample.SampleAnalysisEnvironmentCreator import org.jetbrains.dokka.analysis.kotlin.sample.SampleAnalysisEnvironment import org.jetbrains.dokka.plugability.DokkaPlugin @@ -20,6 +21,11 @@ public class KotlinAnalysisPlugin : DokkaPlugin() { */ public val sampleAnalysisEnvironmentCreator: ExtensionPoint by extensionPoint() + /** + * TODO [external-documentable-provider] add documentation + */ + public val externalDocumentableProvider: ExtensionPoint by extensionPoint() + @OptIn(DokkaPluginApiPreview::class) override fun pluginApiPreviewAcknowledgement(): PluginApiPreviewAcknowledgement = PluginApiPreviewAcknowledgement } diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/documentable/ExternalDocumentableProvider.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/documentable/ExternalDocumentableProvider.kt new file mode 100644 index 0000000000..49d17fd256 --- /dev/null +++ b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/documentable/ExternalDocumentableProvider.kt @@ -0,0 +1,20 @@ +/* + * 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.kotlin.documentable + +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.model.DClasslike + +/** + * TODO [external-documentable-provider] add documentation + */ +public interface ExternalDocumentableProvider { + + /** + * TODO [external-documentable-provider] add documentation + */ + public fun findClasslike(dri: DRI, sourceSet: DokkaSourceSet): DClasslike? +} diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/ExternalDocumentablesProvider.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/ExternalDocumentablesProvider.kt deleted file mode 100644 index 7c564880e8..0000000000 --- a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/ExternalDocumentablesProvider.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.kotlin.internal - -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.InternalDokkaApi -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.DClasslike - -/** - * Service that can be queried with [DRI] and source set to obtain a documentable for classlike. - * - * There are some cases when there is a need to process documentables of classlikes that were not defined - * in the project itself but are somehow related to the symbols defined in the documented project (e.g. are supertypes - * of classes defined in project). - */ -@InternalDokkaApi -public fun interface ExternalDocumentablesProvider { - - /** - * Returns [DClasslike] matching provided [DRI] in specified source set. - * - * Result is null if compiler haven't generated matching class descriptor. - */ - public fun findClasslike(dri: DRI, sourceSet: DokkaConfiguration.DokkaSourceSet): DClasslike? -} diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/InternalKotlinAnalysisPlugin.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/InternalKotlinAnalysisPlugin.kt index d032d49050..dbf33c8e88 100644 --- a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/InternalKotlinAnalysisPlugin.kt +++ b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/InternalKotlinAnalysisPlugin.kt @@ -27,8 +27,6 @@ public class InternalKotlinAnalysisPlugin : DokkaPlugin() { public val inheritanceBuilder: ExtensionPoint by extensionPoint() - public val externalDocumentablesProvider: ExtensionPoint by extensionPoint() - public val documentableSourceLanguageParser: ExtensionPoint by extensionPoint() @OptIn(DokkaPluginApiPreview::class) diff --git a/subprojects/analysis-kotlin-api/src/test/kotlin/org/jetbrains/dokka/analysis/test/ExternalDocumentableProviderTest.kt b/subprojects/analysis-kotlin-api/src/test/kotlin/org/jetbrains/dokka/analysis/test/ExternalDocumentableProviderTest.kt new file mode 100644 index 0000000000..eed797f821 --- /dev/null +++ b/subprojects/analysis-kotlin-api/src/test/kotlin/org/jetbrains/dokka/analysis/test/ExternalDocumentableProviderTest.kt @@ -0,0 +1,293 @@ +/* + * 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 + +import org.jetbrains.dokka.analysis.test.api.javaTestProject +import org.jetbrains.dokka.analysis.test.api.kotlinJvmTestProject +import org.jetbrains.dokka.analysis.test.api.useServices +import org.jetbrains.dokka.analysis.test.api.util.getResourceAbsolutePath +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.model.* +import kotlin.test.* + +class ExternalDocumentableProviderTest { + + @Test + fun `should find a valid external class from java stdlib`() { + val project = javaTestProject { + javaFile("org/jetbrains/dokka/test/MyProjectJavaClass.java") { + +"public class MyProjectJavaClass {}" + } + } + + project.useServices { context -> + // first check that Dokka only returns documentables declared in the project by default + // to make sure later that the external documentable is indeed external and not local + val projectPackages = context.module.packages + assertEquals(1, projectPackages.size, "Expected only a single package to be returned") + + val projectPackageChildren = projectPackages.single().children + assertEquals(1, projectPackageChildren.size, "Expected the project to contain only 1 child") + assertEquals("MyProjectJavaClass", projectPackageChildren.single().name) + + + // query for an external documentable that is not part of the project itself + val sourceSet = context.configuration.sourceSets.single() + val arrayListDRI = DRI("java.util", "ArrayList") + + val arrayListClasslike = externalDocumentableProvider.findClasslike(arrayListDRI, sourceSet) + assertNotNull(arrayListClasslike) + + assertEquals("ArrayList", arrayListClasslike.name) + assertEquals(arrayListDRI, arrayListClasslike.dri) + assertTrue(arrayListClasslike is DClass) + assertTrue(arrayListClasslike.functions.size > 10, "java.util.ArrayList is expected to have >10 functions") + + val superTypes = arrayListClasslike.supertypes.entries.single().value + val abstractListSuperType = superTypes.firstOrNull { + val dri = it.typeConstructor.dri + dri.packageName == "java.util" && dri.classNames == "AbstractList" + } + assertNotNull(abstractListSuperType, "java.util.ArrayList is expected to extend java.util.AbstractList") + + } + } + + @Test + fun `should find a valid external annotation from kotlin jvm stdlib`() { + val project = kotlinJvmTestProject { + ktFile("org/jetbrains/test/dokka/MyKotlinFile.kt") { + +"class MyKotlinClass {}" + } + } + + project.useServices { context -> + // first check that Dokka only returns documentables declared in the project by default + // to make sure later that the external documentable is indeed external and not local + val projectPackages = context.module.packages + assertEquals(1, projectPackages.size, "Expected only a single package to be returned") + + val projectPackageChildren = projectPackages.single().children + assertEquals(1, projectPackageChildren.size, "Expected the project to contain only 1 child") + assertEquals("MyKotlinClass", projectPackageChildren.single().name) + + + // query for an external documentable that is not part of the project itself + val sourceSet = context.configuration.sourceSets.single() + val jvmFieldDRI = DRI("kotlin.jvm", "JvmField") + + val jvmFieldAnnotation = externalDocumentableProvider.findClasslike(jvmFieldDRI, sourceSet) + assertNotNull(jvmFieldAnnotation) + + assertEquals("JvmField", jvmFieldAnnotation.name) + assertEquals(jvmFieldDRI, jvmFieldAnnotation.dri) + assertTrue(jvmFieldAnnotation is DAnnotation) + } + } + + @Test + fun `should find a valid external enum from kotlin stdlib`() { + val project = kotlinJvmTestProject { + ktFile("org/jetbrains/test/dokka/MyKotlinFile.kt") { + +"class MyKotlinClass {}" + } + } + + project.useServices { context -> + // first check that Dokka only returns documentables declared in the project by default + // to make sure later that the external documentable is indeed external and not local + val projectPackages = context.module.packages + assertEquals(1, projectPackages.size, "Expected only a single package to be returned") + + val projectPackageChildren = projectPackages.single().children + assertEquals(1, projectPackageChildren.size, "Expected the project to contain only 1 child") + assertEquals("MyKotlinClass", projectPackageChildren.single().name) + + + // query for an external documentable that is not part of the project itself + val sourceSet = context.configuration.sourceSets.single() + val deprecationLevelDRI = DRI("kotlin", "DeprecationLevel") + + val deprecationLevelEnum = externalDocumentableProvider.findClasslike(deprecationLevelDRI, sourceSet) + assertNotNull(deprecationLevelEnum) + + assertEquals("DeprecationLevel", deprecationLevelEnum.name) + assertEquals(deprecationLevelDRI, deprecationLevelEnum.dri) + assertTrue(deprecationLevelEnum is DEnum) + assertEquals(3, deprecationLevelEnum.entries.size) + + val warningLevel = deprecationLevelEnum.entries[0] + assertEquals("WARNING", warningLevel.name) + } + } + + @Test + fun `should find a valid external interface from kotlin stdlib`() { + val project = kotlinJvmTestProject { + ktFile("org/jetbrains/test/dokka/MyKotlinFile.kt") { + +"class MyKotlinClass {}" + } + } + + project.useServices { context -> + // first check that Dokka only returns documentables declared in the project by default + // to make sure later that the external documentable is indeed external and not local + val projectPackages = context.module.packages + assertEquals(1, projectPackages.size, "Expected only a single package to be returned") + + val projectPackageChildren = projectPackages.single().children + assertEquals(1, projectPackageChildren.size, "Expected the project to contain only 1 child") + assertEquals("MyKotlinClass", projectPackageChildren.single().name) + + + // query for an external documentable that is not part of the project itself + val sourceSet = context.configuration.sourceSets.single() + val sequenceDRI = DRI("kotlin.sequences", "Sequence") + + val sequenceInterface = externalDocumentableProvider.findClasslike(sequenceDRI, sourceSet) + assertNotNull(sequenceInterface) + + assertEquals("Sequence", sequenceInterface.name) + assertEquals(sequenceDRI, sequenceInterface.dri) + assertTrue(sequenceInterface is DInterface) + + val iteratorFunction = sequenceInterface.functions.firstOrNull { it.name == "iterator" } + assertNotNull(iteratorFunction) + } + } + + @Test + fun `should find a valid external object from kotlin stdlib`() { + val project = kotlinJvmTestProject { + ktFile("org/jetbrains/test/dokka/MyKotlinFile.kt") { + +"class MyKotlinClass {}" + } + } + + project.useServices { context -> + // first check that Dokka only returns documentables declared in the project by default + // to make sure later that the external documentable is indeed external and not local + val projectPackages = context.module.packages + assertEquals(1, projectPackages.size, "Expected only a single package to be returned") + + val projectPackageChildren = projectPackages.single().children + assertEquals(1, projectPackageChildren.size, "Expected the project to contain only 1 child") + assertEquals("MyKotlinClass", projectPackageChildren.single().name) + + + // query for an external documentable that is not part of the project itself + val sourceSet = context.configuration.sourceSets.single() + val emptyCoroutineContextDRI = DRI("kotlin.coroutines", "EmptyCoroutineContext") + + val emptyCoroutineContext = externalDocumentableProvider.findClasslike(emptyCoroutineContextDRI, sourceSet) + assertNotNull(emptyCoroutineContext) + + assertEquals("EmptyCoroutineContext", emptyCoroutineContext.name) + assertEquals(emptyCoroutineContextDRI, emptyCoroutineContext.dri) + assertTrue(emptyCoroutineContext is DObject) + } + } + + @Test + fun `should find a valid external class from a third party library`() { + val project = kotlinJvmTestProject { + dokkaConfiguration { + kotlinSourceSet { + additionalClasspath = setOf( + getResourceAbsolutePath("jars/kotlinx-cli-jvm-0.3.6.jar") + ) + } + } + + ktFile("org/jetbrains/test/dokka/MyKotlinFile.kt") { + +"class MyKotlinClass {}" + } + } + + project.useServices { context -> + // first check that Dokka only returns documentables declared in the project by default + // to make sure later that the external documentable is indeed external and not local + val projectPackages = context.module.packages + assertEquals(1, projectPackages.size, "Expected only a single package to be returned") + + val projectPackageChildren = projectPackages.single().children + assertEquals(1, projectPackageChildren.size, "Expected the project to contain only 1 child") + assertEquals("MyKotlinClass", projectPackageChildren.single().name) + + + // query for an external documentable that is not part of the project itself + val sourceSet = context.configuration.sourceSets.single() + val argTypeDRI = DRI("kotlinx.cli", "ArgType") + + val argTypeClass = externalDocumentableProvider.findClasslike(argTypeDRI, sourceSet) + assertNotNull(argTypeClass) + + assertEquals("ArgType", argTypeClass.name) + assertEquals(argTypeDRI, argTypeClass.dri) + assertTrue(argTypeClass is DClass) + assertEquals(KotlinModifier.Abstract, argTypeClass.modifier.values.single()) + } + } + + @Test + fun `should find a nested interface from java stdlib`() { + val project = kotlinJvmTestProject { + ktFile("org/jetbrains/test/dokka/MyKotlinFile.kt") { + +"class MyKotlinClass {}" + } + } + + project.useServices { context -> + // first check that Dokka only returns documentables declared in the project by default + // to make sure later that the external documentable is indeed external and not local + val projectPackages = context.module.packages + assertEquals(1, projectPackages.size, "Expected only a single package to be returned") + + val projectPackageChildren = projectPackages.single().children + assertEquals(1, projectPackageChildren.size, "Expected the project to contain only 1 child") + assertEquals("MyKotlinClass", projectPackageChildren.single().name) + + + // query for an external documentable that is not part of the project itself + val sourceSet = context.configuration.sourceSets.single() + val mapEntryDRI = DRI("java.util", "Map.Entry") + + val mapEntryInterface = externalDocumentableProvider.findClasslike(mapEntryDRI, sourceSet) + assertNotNull(mapEntryInterface) + + assertEquals("Entry", mapEntryInterface.name) + assertEquals(mapEntryDRI, mapEntryInterface.dri) + assertTrue(mapEntryInterface is DInterface) + } + } + + @Test + fun `should return null for querying non existing dri`() { + val project = kotlinJvmTestProject { + ktFile("org/jetbrains/test/dokka/MyKotlinFile.kt") { + +"class MyKotlinClass {}" + } + } + + project.useServices { context -> + // first check that Dokka only returns documentables declared in the project by default + // to make sure later that the external documentable is indeed external and not local + val projectPackages = context.module.packages + assertEquals(1, projectPackages.size, "Expected only a single package to be returned") + + val projectPackageChildren = projectPackages.single().children + assertEquals(1, projectPackageChildren.size, "Expected the project to contain only 1 child") + assertEquals("MyKotlinClass", projectPackageChildren.single().name) + + + // query for an external documentable that is not part of the project itself + val sourceSet = context.configuration.sourceSets.single() + + val nonExistingDRI = DRI("com.example.pckg", "NonExistingClassname") + val nonExistingClasslike = externalDocumentableProvider.findClasslike(nonExistingDRI, sourceSet) + assertNull(nonExistingClasslike) + } + } +} diff --git a/subprojects/analysis-kotlin-api/src/test/resources/jars/README.md b/subprojects/analysis-kotlin-api/src/test/resources/jars/README.md new file mode 100644 index 0000000000..21f27d406d --- /dev/null +++ b/subprojects/analysis-kotlin-api/src/test/resources/jars/README.md @@ -0,0 +1 @@ +The JARs in this directory can be used as external dependencies for testing purposes. diff --git a/subprojects/analysis-kotlin-api/src/test/resources/jars/kotlinx-cli-jvm-0.3.6.jar b/subprojects/analysis-kotlin-api/src/test/resources/jars/kotlinx-cli-jvm-0.3.6.jar new file mode 100644 index 0000000000..b4f1e5a45c Binary files /dev/null and b/subprojects/analysis-kotlin-api/src/test/resources/jars/kotlinx-cli-jvm-0.3.6.jar differ diff --git a/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/analysis/TestAnalysisServices.kt b/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/analysis/TestAnalysisServices.kt index f729838d81..714ee16ab4 100644 --- a/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/analysis/TestAnalysisServices.kt +++ b/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/analysis/TestAnalysisServices.kt @@ -5,6 +5,7 @@ package org.jetbrains.dokka.analysis.test.api.analysis import org.jetbrains.dokka.analysis.kotlin.KotlinAnalysisPlugin +import org.jetbrains.dokka.analysis.kotlin.documentable.ExternalDocumentableProvider import org.jetbrains.dokka.analysis.kotlin.internal.ModuleAndPackageDocumentationReader import org.jetbrains.dokka.analysis.kotlin.sample.SampleAnalysisEnvironmentCreator @@ -16,5 +17,6 @@ import org.jetbrains.dokka.analysis.kotlin.sample.SampleAnalysisEnvironmentCreat */ class TestAnalysisServices( val sampleAnalysisEnvironmentCreator: SampleAnalysisEnvironmentCreator, + val externalDocumentableProvider: ExternalDocumentableProvider, val moduleAndPackageDocumentationReader: ModuleAndPackageDocumentationReader ) diff --git a/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/analysis/TestProjectAnalyzer.kt b/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/analysis/TestProjectAnalyzer.kt index 674c6d4779..7a410d7dbb 100644 --- a/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/analysis/TestProjectAnalyzer.kt +++ b/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/analysis/TestProjectAnalyzer.kt @@ -228,6 +228,7 @@ internal object TestProjectAnalyzer { val internalAnalysisPlugin = context.plugin() return TestAnalysisServices( sampleAnalysisEnvironmentCreator = publicAnalysisPlugin.querySingle { sampleAnalysisEnvironmentCreator }, + externalDocumentableProvider = publicAnalysisPlugin.querySingle { externalDocumentableProvider }, moduleAndPackageDocumentationReader = internalAnalysisPlugin.querySingle { moduleAndPackageDocumentationReader } diff --git a/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/configuration/TestDokkaConfigurationBuilder.kt b/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/configuration/TestDokkaConfigurationBuilder.kt index b6563fb7d0..fc3499eaf8 100644 --- a/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/configuration/TestDokkaConfigurationBuilder.kt +++ b/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/configuration/TestDokkaConfigurationBuilder.kt @@ -5,6 +5,7 @@ package org.jetbrains.dokka.analysis.test.api.configuration import org.jetbrains.dokka.analysis.test.api.TestProject +import org.jetbrains.dokka.analysis.test.api.util.getResourceAbsolutePath import org.jetbrains.dokka.analysis.test.api.util.AnalysisTestDslMarker /** @@ -66,6 +67,8 @@ abstract class BaseTestDokkaSourceSetBuilder { /** * JARs **additional** to the default classpath. * + * You can put test JARs inside `src/resources`, and then get it via [getResourceAbsolutePath]. + * * @see TestDokkaSourceSet.classpath */ open var additionalClasspath: Set = emptySet() diff --git a/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/util/FileUtils.kt b/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/util/FileUtils.kt index 779add8d31..924a65462a 100644 --- a/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/util/FileUtils.kt +++ b/subprojects/analysis-kotlin-api/src/testFixtures/kotlin/org/jetbrains/dokka/analysis/test/api/util/FileUtils.kt @@ -39,3 +39,24 @@ internal fun withTempDirectory(logger: DokkaLogger? = null, block: (tempDire logger?.debug("Deleted temporary directory $tempDir") } } + +/** + * TODO [external-documentable-provider] add documentation + */ +fun getResourceAbsolutePath(resourcePath: String): String { + val resourceFile = getResourceFile(resourcePath) + require(resourceFile.exists()) { + "Resource file does not exist: $resourcePath" + } + return resourceFile.absolutePath +} + +/** + * TODO [external-documentable-provider] add documentation + */ +fun getResourceFile(resourcePath: String): File { + val resource = object {}.javaClass.classLoader.getResource(resourcePath)?.file + ?: throw IllegalArgumentException("Resource not found: $resourcePath") + + return File(resource) +} diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/CompilerDescriptorAnalysisPlugin.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/CompilerDescriptorAnalysisPlugin.kt index e8ebceb02b..5bffaa48f4 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/CompilerDescriptorAnalysisPlugin.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/CompilerDescriptorAnalysisPlugin.kt @@ -18,7 +18,7 @@ import org.jetbrains.dokka.analysis.kotlin.descriptors.compiler.impl.* import org.jetbrains.dokka.analysis.kotlin.descriptors.compiler.impl.moduledocs.ModuleAndPackageDocumentationReader import org.jetbrains.dokka.analysis.kotlin.descriptors.compiler.java.* import org.jetbrains.dokka.analysis.kotlin.descriptors.compiler.translator.DefaultDescriptorToDocumentableTranslator -import org.jetbrains.dokka.analysis.kotlin.descriptors.compiler.translator.DefaultExternalDocumentablesProvider +import org.jetbrains.dokka.analysis.kotlin.descriptors.compiler.translator.DescriptorExternalDocumentablesProvider import org.jetbrains.dokka.renderers.PostAction import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin import org.jetbrains.dokka.plugability.* @@ -95,8 +95,8 @@ public class CompilerDescriptorAnalysisPlugin : DokkaPlugin() { plugin().inheritanceBuilder providing { DescriptorInheritanceBuilder() } } - internal val defaultExternalDocumentablesProvider by extending { - plugin().externalDocumentablesProvider providing ::DefaultExternalDocumentablesProvider + internal val descriptorExternalDocumentableProvider by extending { + plugin().externalDocumentableProvider providing ::DescriptorExternalDocumentablesProvider } private val javaAnalysisPlugin by lazy { plugin() } diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/translator/DefaultExternalDocumentablesProvider.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/translator/DescriptorExternalDocumentablesProvider.kt similarity index 91% rename from subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/translator/DefaultExternalDocumentablesProvider.kt rename to subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/translator/DescriptorExternalDocumentablesProvider.kt index 006a990ba6..946b2272c2 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/translator/DefaultExternalDocumentablesProvider.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/translator/DescriptorExternalDocumentablesProvider.kt @@ -11,7 +11,7 @@ import org.jetbrains.dokka.model.DClasslike import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.querySingle -import org.jetbrains.dokka.analysis.kotlin.internal.ExternalDocumentablesProvider +import org.jetbrains.dokka.analysis.kotlin.documentable.ExternalDocumentableProvider import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.PackageViewDescriptor @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered -internal class DefaultExternalDocumentablesProvider(context: DokkaContext) : ExternalDocumentablesProvider { +internal class DescriptorExternalDocumentablesProvider(context: DokkaContext) : ExternalDocumentableProvider { private val analysis = context.plugin().querySingle { kotlinAnalysis } private val translator: ExternalClasslikesTranslator = DefaultDescriptorToDocumentableTranslator(context) diff --git a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/SymbolsAnalysisPlugin.kt b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/SymbolsAnalysisPlugin.kt index 23bb0dc554..d8b171b90f 100644 --- a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/SymbolsAnalysisPlugin.kt +++ b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/plugin/SymbolsAnalysisPlugin.kt @@ -114,8 +114,8 @@ public class SymbolsAnalysisPlugin : DokkaPlugin() { plugin().inheritanceBuilder providing ::SymbolInheritanceBuilder } - internal val symbolExternalDocumentablesProvider by extending { - plugin().externalDocumentablesProvider providing ::SymbolExternalDocumentablesProvider + internal val symbolExternalDocumentableProvider by extending { + plugin().externalDocumentableProvider providing ::SymbolExternalDocumentablesProvider } internal val symbolSampleAnalysisEnvironmentCreator by extending { diff --git a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/services/SymbolExternalDocumentablesProvider.kt b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/services/SymbolExternalDocumentablesProvider.kt index 1473a7da15..97b12ae25e 100644 --- a/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/services/SymbolExternalDocumentablesProvider.kt +++ b/subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/services/SymbolExternalDocumentablesProvider.kt @@ -16,9 +16,9 @@ import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.kotlin.analysis.api.analyze import org.jetbrains.kotlin.analysis.api.symbols.KtNamedClassOrObjectSymbol -import org.jetbrains.dokka.analysis.kotlin.internal.ExternalDocumentablesProvider +import org.jetbrains.dokka.analysis.kotlin.documentable.ExternalDocumentableProvider -internal class SymbolExternalDocumentablesProvider(val context: DokkaContext) : ExternalDocumentablesProvider { +internal class SymbolExternalDocumentablesProvider(val context: DokkaContext) : ExternalDocumentableProvider { private val kotlinAnalysis = context.plugin().querySingle { kotlinAnalysis } override fun findClasslike(dri: DRI, sourceSet: DokkaSourceSet): DClasslike? {