diff options
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r-- | core/src/main/kotlin/CoreExtensions.kt | 4 | ||||
-rw-r--r-- | core/src/main/kotlin/DokkaBootstrap.kt | 1 | ||||
-rw-r--r-- | core/src/main/kotlin/InternalDokkaApi.kt | 5 | ||||
-rw-r--r-- | core/src/main/kotlin/model/Documentable.kt | 11 | ||||
-rw-r--r-- | core/src/main/kotlin/model/WithChildren.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/model/documentableProperties.kt | 9 | ||||
-rw-r--r-- | core/src/main/kotlin/plugability/DokkaPlugin.kt | 3 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/Collections.kt | 25 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/Html.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/SelfRepresentingSingletonSet.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/ServiceLocator.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/Uri.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/associateWithNotNull.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/cast.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/parallelCollectionOperations.kt | 7 |
15 files changed, 65 insertions, 14 deletions
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 { |