From 10874a53b0db00c45d4ab44dfd226672dcf75115 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 26 Feb 2020 13:16:31 +0100 Subject: Sketch of default signature provider --- core/src/main/kotlin/CoreExtensions.kt | 4 +++- core/src/main/kotlin/links/DRI.kt | 3 +++ core/src/main/kotlin/model/Documentable.kt | 15 +++++++++------ core/src/main/kotlin/model/SignatureProvider.kt | 7 +++++++ 4 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 core/src/main/kotlin/model/SignatureProvider.kt (limited to 'core') diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt index dd6eab1b..6a1af187 100644 --- a/core/src/main/kotlin/CoreExtensions.kt +++ b/core/src/main/kotlin/CoreExtensions.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka +import org.jetbrains.dokka.model.SignatureProvider import org.jetbrains.dokka.plugability.ExtensionPoint import org.jetbrains.dokka.renderers.Renderer import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentableTranslator @@ -18,8 +19,9 @@ object CoreExtensions { val documentableToPageTranslator by coreExtension() val pageTransformer by coreExtension() val renderer by coreExtension() + val signatureProvider by coreExtension() - private fun coreExtension() = object { + private fun coreExtension() = object { operator fun provideDelegate(thisRef: CoreExtensions, property: KProperty<*>): Lazy> = lazy { ExtensionPoint(thisRef::class.qualifiedName!!, property.name) } } diff --git a/core/src/main/kotlin/links/DRI.kt b/core/src/main/kotlin/links/DRI.kt index 791d2b5e..57ac96e5 100644 --- a/core/src/main/kotlin/links/DRI.kt +++ b/core/src/main/kotlin/links/DRI.kt @@ -68,6 +68,9 @@ val DRI.parent: DRI else -> DRI.topLevel } +val DRI.sureClassNames + get() = classNames ?: throw IllegalStateException("Malformed DRI. It requires classNames in this context.") + data class Callable( val name: String, val receiver: TypeReference? = null, diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index c16f8a87..4190edc3 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -315,7 +315,7 @@ data class TypeParameter( override val dri: DRI, override val name: String, override val documentation: PlatformDependent, - val bounds: List, + val bounds: List, override val platformData: List, override val extra: PropertyContainer = PropertyContainer.empty() ) : Documentable(), WithExtraProperties { @@ -325,11 +325,14 @@ data class TypeParameter( override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -sealed class Projection { - data class OtherParameter(val name: String) : Projection() - object Star : Projection() - data class TypeConstructor(val dri: DRI, val projections: List) : Projection() - data class Nullable(val inner: Projection) : Projection() +sealed class Projection +sealed class Bound : Projection() +data class OtherParameter(val name: String) : Bound() +object Star : Projection() +data class TypeConstructor(val dri: DRI, val projections: List) : Bound() +data class Nullable(val inner: Bound) : Bound() +data class Variance(val kind: Kind, val inner: Bound): Projection() { + enum class Kind { In, Out } } enum class ExtraModifiers { diff --git a/core/src/main/kotlin/model/SignatureProvider.kt b/core/src/main/kotlin/model/SignatureProvider.kt new file mode 100644 index 00000000..2df0f4b6 --- /dev/null +++ b/core/src/main/kotlin/model/SignatureProvider.kt @@ -0,0 +1,7 @@ +package org.jetbrains.dokka.model + +import org.jetbrains.dokka.pages.ContentNode + +interface SignatureProvider { + fun signature(documentable: Documentable): List +} \ No newline at end of file -- cgit