diff options
Diffstat (limited to 'core')
23 files changed, 110 insertions, 36 deletions
diff --git a/core/api/core.api b/core/api/core.api index ac48cfd5..9530899d 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -1459,6 +1459,7 @@ public final class org/jetbrains/dokka/model/DocumentableKt { } public abstract interface class org/jetbrains/dokka/model/DocumentableSource { + public abstract fun computeLineNumber ()Ljava/lang/Integer; public abstract fun getPath ()Ljava/lang/String; } @@ -1782,6 +1783,24 @@ public final class org/jetbrains/dokka/model/Invariance : org/jetbrains/dokka/mo public fun toString ()Ljava/lang/String; } +public final class org/jetbrains/dokka/model/IsAlsoParameter : org/jetbrains/dokka/model/properties/ExtraProperty { + public static final field Companion Lorg/jetbrains/dokka/model/IsAlsoParameter$Companion; + public fun <init> (Ljava/util/List;)V + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Lorg/jetbrains/dokka/model/IsAlsoParameter; + public static synthetic fun copy$default (Lorg/jetbrains/dokka/model/IsAlsoParameter;Ljava/util/List;ILjava/lang/Object;)Lorg/jetbrains/dokka/model/IsAlsoParameter; + public fun equals (Ljava/lang/Object;)Z + public final fun getInSourceSets ()Ljava/util/List; + public fun getKey ()Lorg/jetbrains/dokka/model/properties/ExtraProperty$Key; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class org/jetbrains/dokka/model/IsAlsoParameter$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/IsAlsoParameter;Lorg/jetbrains/dokka/model/IsAlsoParameter;)Lorg/jetbrains/dokka/model/properties/MergeStrategy; +} + public final class org/jetbrains/dokka/model/IsVar : org/jetbrains/dokka/model/properties/ExtraProperty, org/jetbrains/dokka/model/properties/ExtraProperty$Key { public static final field INSTANCE Lorg/jetbrains/dokka/model/IsVar; public fun getKey ()Lorg/jetbrains/dokka/model/properties/ExtraProperty$Key; @@ -4400,6 +4419,7 @@ public abstract class org/jetbrains/dokka/plugability/DokkaPlugin { protected final fun extending (Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/dokka/plugability/DokkaPlugin$ExtensionProvider; protected final fun extensionPoint ()Lkotlin/properties/ReadOnlyProperty; public final fun getContext ()Lorg/jetbrains/dokka/plugability/DokkaContext; + protected final fun getLogger ()Lorg/jetbrains/dokka/utilities/DokkaLogger; protected abstract fun pluginApiPreviewAcknowledgement ()Lorg/jetbrains/dokka/plugability/PluginApiPreviewAcknowledgement; public final fun setContext (Lorg/jetbrains/dokka/plugability/DokkaContext;)V protected final fun unsafeInstall (Lkotlin/Lazy;)V diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 1afed43d..2a5b668c 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -7,11 +7,8 @@ plugins { } dependencies { - api(libs.jetbrains.markdown) implementation(kotlin("reflect")) - - implementation(libs.jsoup) - + implementation(libs.kotlinx.coroutines.core) implementation(libs.jackson.kotlin) implementation(libs.jackson.xml) constraints { @@ -20,8 +17,6 @@ dependencies { } } - implementation(libs.kotlinx.coroutines.core) - testImplementation(projects.core.testApi) testImplementation(kotlin("test-junit")) } diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt index ddfa0c69..8b5196c3 100644 --- a/core/src/main/kotlin/CoreExtensions.kt +++ b/core/src/main/kotlin/CoreExtensions.kt @@ -1,7 +1,7 @@ package org.jetbrains.dokka import org.jetbrains.dokka.generation.Generation -import org.jetbrains.dokka.plugability.* +import org.jetbrains.dokka.plugability.ExtensionPoint import org.jetbrains.dokka.renderers.PostAction import org.jetbrains.dokka.renderers.Renderer import org.jetbrains.dokka.transformers.documentation.DocumentableMerger @@ -28,4 +28,4 @@ object CoreExtensions { operator fun provideDelegate(thisRef: CoreExtensions, property: KProperty<*>): Lazy<ExtensionPoint<T>> = lazy { ExtensionPoint(thisRef::class.qualifiedName!!, property.name) } } -}
\ No newline at end of file +} diff --git a/core/src/main/kotlin/DokkaBootstrap.kt b/core/src/main/kotlin/DokkaBootstrap.kt index f4533d5b..10a91c5e 100644 --- a/core/src/main/kotlin/DokkaBootstrap.kt +++ b/core/src/main/kotlin/DokkaBootstrap.kt @@ -1,7 +1,6 @@ package org.jetbrains.dokka import java.util.function.BiConsumer -import kotlin.jvm.Throws interface DokkaBootstrap { @Throws(Throwable::class) diff --git a/core/src/main/kotlin/InternalDokkaApi.kt b/core/src/main/kotlin/InternalDokkaApi.kt index 4389bf7b..0582d350 100644 --- a/core/src/main/kotlin/InternalDokkaApi.kt +++ b/core/src/main/kotlin/InternalDokkaApi.kt @@ -16,6 +16,9 @@ package org.jetbrains.dokka level = RequiresOptIn.Level.ERROR, message = "This is an internal Dokka API not intended for public use" ) -@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.FIELD) +@Target( + AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.FIELD, + AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS +) @Retention(AnnotationRetention.BINARY) public annotation class InternalDokkaApi() diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index c7b2290e..64c3e14c 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -518,6 +518,15 @@ fun <T> SourceSetDependent<T>?.orEmpty(): SourceSetDependent<T> = this ?: emptyM interface DocumentableSource { val path: String + + /** + * Computes the first line number of the documentable's declaration/signature/identifier. + * + * Numbering is always 1-based. + * + * May return null if the sources could not be found - for example, for synthetic/generated declarations. + */ + fun computeLineNumber(): Int? } -data class TypeConstructorWithKind(val typeConstructor: TypeConstructor, val kind: ClassKind)
\ No newline at end of file +data class TypeConstructorWithKind(val typeConstructor: TypeConstructor, val kind: ClassKind) diff --git a/core/src/main/kotlin/model/WithChildren.kt b/core/src/main/kotlin/model/WithChildren.kt index 01a188c8..7412971a 100644 --- a/core/src/main/kotlin/model/WithChildren.kt +++ b/core/src/main/kotlin/model/WithChildren.kt @@ -91,4 +91,4 @@ fun <T : WithChildren<T>> T.asPrintableTree( } return buildString { append(this@asPrintableTree, "", "") } -}
\ No newline at end of file +} diff --git a/core/src/main/kotlin/model/documentableProperties.kt b/core/src/main/kotlin/model/documentableProperties.kt index 9fe8aa1d..4e743b0a 100644 --- a/core/src/main/kotlin/model/documentableProperties.kt +++ b/core/src/main/kotlin/model/documentableProperties.kt @@ -49,6 +49,15 @@ object IsVar : ExtraProperty<DProperty>, ExtraProperty.Key<DProperty, IsVar> { override val key: ExtraProperty.Key<DProperty, *> = this } +data class IsAlsoParameter(val inSourceSets: List<DokkaSourceSet>) : ExtraProperty<DProperty> { + companion object : ExtraProperty.Key<DProperty, IsAlsoParameter> { + override fun mergeStrategyFor(left: IsAlsoParameter, right: IsAlsoParameter): MergeStrategy<DProperty> = + MergeStrategy.Replace(IsAlsoParameter(left.inSourceSets + right.inSourceSets)) + } + + override val key: ExtraProperty.Key<DProperty, *> = IsAlsoParameter +} + data class CheckedExceptions(val exceptions: SourceSetDependent<List<DRI>>) : ExtraProperty<Documentable>, ExtraProperty.Key<Documentable, ObviousMember> { companion object : ExtraProperty.Key<Documentable, CheckedExceptions> { override fun mergeStrategyFor(left: CheckedExceptions, right: CheckedExceptions) = diff --git a/core/src/main/kotlin/plugability/DokkaPlugin.kt b/core/src/main/kotlin/plugability/DokkaPlugin.kt index 54733ac2..99fa4b95 100644 --- a/core/src/main/kotlin/plugability/DokkaPlugin.kt +++ b/core/src/main/kotlin/plugability/DokkaPlugin.kt @@ -4,6 +4,7 @@ import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule import com.fasterxml.jackson.dataformat.xml.XmlMapper import com.fasterxml.jackson.module.kotlin.readValue import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.utilities.DokkaLogger import org.jetbrains.dokka.utilities.parseJson import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KProperty @@ -33,6 +34,8 @@ abstract class DokkaPlugin { @PublishedApi internal var context: DokkaContext? = null + protected val logger: DokkaLogger get() = context?.logger ?: throw IllegalStateException("No logger found") + /** * @see PluginApiPreviewAcknowledgement */ diff --git a/core/src/main/kotlin/utilities/Collections.kt b/core/src/main/kotlin/utilities/Collections.kt new file mode 100644 index 00000000..b18752f7 --- /dev/null +++ b/core/src/main/kotlin/utilities/Collections.kt @@ -0,0 +1,25 @@ +package org.jetbrains.dokka.utilities + +import org.jetbrains.dokka.InternalDokkaApi + +/** + * This utility method was previously imported from `org.jetbrains.kotlin.utils.addToStdlib`, + * and there were a lot of usages. Since no replacement exists in stdlib, it was implemented + * locally for convenience. + */ +@InternalDokkaApi +inline fun <reified T : Any> Iterable<*>.firstIsInstanceOrNull(): T? { + for (element in this) if (element is T) return element + return null +} + +/** + * This utility method was previously imported from `org.jetbrains.kotlin.utils.addToStdlib`, + * and there were a lot of usages. Since no replacement exists in stdlib, it was implemented + * locally for convenience. + */ +@InternalDokkaApi +inline fun <reified T : Any> Sequence<*>.firstIsInstanceOrNull(): T? { + for (element in this) if (element is T) return element + return null +} diff --git a/core/src/main/kotlin/utilities/Html.kt b/core/src/main/kotlin/utilities/Html.kt index a1d8ecec..262dd0a0 100644 --- a/core/src/main/kotlin/utilities/Html.kt +++ b/core/src/main/kotlin/utilities/Html.kt @@ -1,6 +1,6 @@ package org.jetbrains.dokka.utilities -import org.jetbrains.dokka.* +import org.jetbrains.dokka.InternalDokkaApi import java.net.URLEncoder diff --git a/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt b/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt index c29d1b2a..e1b42388 100644 --- a/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt +++ b/core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt @@ -1,6 +1,6 @@ package org.jetbrains.dokka.utilities -import org.jetbrains.dokka.* +import org.jetbrains.dokka.InternalDokkaApi @InternalDokkaApi interface SelfRepresentingSingletonSet<T : SelfRepresentingSingletonSet<T>> : Set<T> { diff --git a/core/src/main/kotlin/utilities/ServiceLocator.kt b/core/src/main/kotlin/utilities/ServiceLocator.kt index f86960ec..b5b19057 100644 --- a/core/src/main/kotlin/utilities/ServiceLocator.kt +++ b/core/src/main/kotlin/utilities/ServiceLocator.kt @@ -1,6 +1,6 @@ package org.jetbrains.dokka.utilities -import org.jetbrains.dokka.* +import org.jetbrains.dokka.InternalDokkaApi import java.io.File import java.net.URISyntaxException import java.net.URL diff --git a/core/src/main/kotlin/utilities/Uri.kt b/core/src/main/kotlin/utilities/Uri.kt index 67c81d98..ef8549f7 100644 --- a/core/src/main/kotlin/utilities/Uri.kt +++ b/core/src/main/kotlin/utilities/Uri.kt @@ -1,6 +1,6 @@ package org.jetbrains.dokka.utilities -import org.jetbrains.dokka.* +import org.jetbrains.dokka.InternalDokkaApi import java.net.URI @InternalDokkaApi diff --git a/core/src/main/kotlin/utilities/associateWithNotNull.kt b/core/src/main/kotlin/utilities/associateWithNotNull.kt index 6c0bf4d8..9ff55d2c 100644 --- a/core/src/main/kotlin/utilities/associateWithNotNull.kt +++ b/core/src/main/kotlin/utilities/associateWithNotNull.kt @@ -1,6 +1,6 @@ package org.jetbrains.dokka.utilities -import org.jetbrains.dokka.* +import org.jetbrains.dokka.InternalDokkaApi @InternalDokkaApi inline fun <K, V : Any> Iterable<K>.associateWithNotNull(valueSelector: (K) -> V?): Map<K, V> { diff --git a/core/src/main/kotlin/utilities/cast.kt b/core/src/main/kotlin/utilities/cast.kt index 784b7e2a..9fe76ef6 100644 --- a/core/src/main/kotlin/utilities/cast.kt +++ b/core/src/main/kotlin/utilities/cast.kt @@ -1,6 +1,6 @@ package org.jetbrains.dokka.utilities -import org.jetbrains.dokka.* +import org.jetbrains.dokka.InternalDokkaApi @InternalDokkaApi inline fun <reified T> Any.cast(): T { diff --git a/core/src/main/kotlin/utilities/parallelCollectionOperations.kt b/core/src/main/kotlin/utilities/parallelCollectionOperations.kt index d24aa7a6..cff8d735 100644 --- a/core/src/main/kotlin/utilities/parallelCollectionOperations.kt +++ b/core/src/main/kotlin/utilities/parallelCollectionOperations.kt @@ -1,7 +1,10 @@ package org.jetbrains.dokka.utilities -import kotlinx.coroutines.* -import org.jetbrains.dokka.* +import kotlinx.coroutines.async +import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch +import org.jetbrains.dokka.InternalDokkaApi @InternalDokkaApi suspend inline fun <A, B> Iterable<A>.parallelMap(crossinline f: suspend (A) -> B): List<B> = coroutineScope { diff --git a/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt b/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt index 9ac5fea0..d93ea5df 100644 --- a/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt +++ b/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt @@ -1,6 +1,9 @@ package utilities -import org.jetbrains.dokka.* +import org.jetbrains.dokka.DokkaConfigurationImpl +import org.jetbrains.dokka.DokkaSourceSetID +import org.jetbrains.dokka.DokkaSourceSetImpl +import org.jetbrains.dokka.toCompactJsonString import java.io.File import kotlin.test.Test import kotlin.test.assertEquals diff --git a/core/src/test/kotlin/utilities/JsonKtTest.kt b/core/src/test/kotlin/utilities/JsonKtTest.kt index ee78392c..301f4f5d 100644 --- a/core/src/test/kotlin/utilities/JsonKtTest.kt +++ b/core/src/test/kotlin/utilities/JsonKtTest.kt @@ -2,8 +2,8 @@ package utilities import org.jetbrains.dokka.utilities.serializeAsCompactJson import org.jetbrains.dokka.utilities.serializeAsPrettyJson -import kotlin.test.assertEquals import kotlin.test.Test +import kotlin.test.assertEquals class JsonTest { diff --git a/core/test-api/build.gradle.kts b/core/test-api/build.gradle.kts index 1eb8f00c..6b4b4d17 100644 --- a/core/test-api/build.gradle.kts +++ b/core/test-api/build.gradle.kts @@ -7,7 +7,7 @@ plugins { dependencies { api(projects.core) - implementation(projects.kotlinAnalysis) + implementation("junit:junit:4.13.2") // TODO: remove dependency to junit implementation(kotlin("reflect")) } diff --git a/core/test-api/src/main/kotlin/testApi/logger/TestLogger.kt b/core/test-api/src/main/kotlin/testApi/logger/TestLogger.kt index e70200a7..1e301735 100644 --- a/core/test-api/src/main/kotlin/testApi/logger/TestLogger.kt +++ b/core/test-api/src/main/kotlin/testApi/logger/TestLogger.kt @@ -1,7 +1,7 @@ package org.jetbrains.dokka.testApi.logger import org.jetbrains.dokka.utilities.DokkaLogger -import java.util.Collections +import java.util.* /* * Even in tests it be used in a concurrent environment, so needs to be thread safe diff --git a/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt b/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt index 50ab3bad..c63f5b2e 100644 --- a/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt +++ b/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt @@ -1,6 +1,5 @@ package testApi.testRunner -import org.intellij.markdown.MarkdownElementTypes import org.jetbrains.dokka.* import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.* @@ -206,6 +205,5 @@ fun dPackage( fun documentationNode(vararg texts: String): DocumentationNode { return DocumentationNode( texts.toList() - .map { Description(CustomDocTag(listOf(Text(it)), name = MarkdownElementTypes.MARKDOWN_FILE.name)) }) + .map { Description(CustomDocTag(listOf(Text(it)), name = "MARKDOWN_FILE")) }) } - 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 31443b2d..cfb809ea 100644 --- a/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt +++ b/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt @@ -1,7 +1,8 @@ package org.jetbrains.dokka.testApi.testRunner -import com.intellij.openapi.application.PathManager -import org.jetbrains.dokka.* +import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.DokkaConfigurationImpl +import org.jetbrains.dokka.ExternalDocumentationLinkImpl import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext @@ -37,7 +38,7 @@ abstract class AbstractTest<M : TestMethods, T : TestBuilder<M>, D : DokkaTestGe cleanupOutput: Boolean = true, useOutputLocationFromConfig: Boolean = false, pluginOverrides: List<DokkaPlugin> = emptyList(), - block: T.() -> Unit + block: T.() -> Unit, ) { val testMethods = testBuilder().apply(block).build() val configurationToUse = @@ -65,7 +66,7 @@ abstract class AbstractTest<M : TestMethods, T : TestBuilder<M>, D : DokkaTestGe cleanupOutput: Boolean = true, pluginOverrides: List<DokkaPlugin> = emptyList(), loggerForTest: DokkaLogger = logger, - block: T.() -> Unit + block: T.() -> Unit, ) { val testMethods = testBuilder().apply(block).build() val testDirPath = getTempDir(cleanupOutput).root.toPath().toAbsolutePath() @@ -133,7 +134,7 @@ abstract class AbstractTest<M : TestMethods, T : TestBuilder<M>, D : DokkaTestGe private fun Map<String, String>.materializeFiles( root: Path = Paths.get("."), - charset: Charset = Charset.forName("utf-8") + charset: Charset = Charset.forName("utf-8"), ) = this.map { (path, content) -> val file = root.resolve(path) Files.createDirectories(file.parent) @@ -160,11 +161,17 @@ abstract class AbstractTest<M : TestMethods, T : TestBuilder<M>, D : DokkaTestGe protected val jvmStdlibPath: String? by lazy { - PathManager.getResourceRoot(Strictfp::class.java, "/kotlin/jvm/Strictfp.class") + ClassLoader.getSystemResource("kotlin/jvm/Strictfp.class") + ?.file + ?.replace("file:", "") + ?.replaceAfter(".jar", "") } protected val jsStdlibPath: String? by lazy { - PathManager.getResourceRoot(Any::class.java, "/kotlin/jquery") + ClassLoader.getSystemResource("kotlin/jquery") + ?.file + ?.replace("file:", "") + ?.replaceAfter(".jar", "") } protected val commonStdlibPath: String? by lazy { @@ -195,7 +202,7 @@ open class CoreTestMethods( open val documentablesTransformationStage: (DModule) -> Unit, open val pagesGenerationStage: (RootPageNode) -> Unit, open val pagesTransformationStage: (RootPageNode) -> Unit, - open val renderingStage: (RootPageNode, DokkaContext) -> Unit + open val renderingStage: (RootPageNode, DokkaContext) -> Unit, ) : TestMethods abstract class TestBuilder<M : TestMethods> { @@ -206,7 +213,7 @@ abstract class DokkaTestGenerator<T : TestMethods>( protected val configuration: DokkaConfiguration, protected val logger: DokkaLogger, protected val testMethods: T, - protected val additionalPlugins: List<DokkaPlugin> = emptyList() + protected val additionalPlugins: List<DokkaPlugin> = emptyList(), ) { abstract fun generate() } |