From 37db297bfc00a12114122db06f34091528ed03e3 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Tue, 8 Sep 2020 17:03:31 +0200 Subject: Fix presentation of typealiases --- .../resolvers/local/DokkaLocationProvider.kt | 2 +- .../DefaultDescriptorToDocumentableTranslator.kt | 34 +++++++++++++--------- .../documentables/DefaultPageCreator.kt | 7 ++--- 3 files changed, 24 insertions(+), 19 deletions(-) (limited to 'plugins/base/src') diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt index 14111a3b..43ffff85 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt @@ -68,7 +68,7 @@ open class DokkaLocationProvider( private fun getLocalLocation(dri: Pair, context: PageNode?): String? = pagesIndex[dri]?.let { resolve(it, context) } - ?: anchorsIndex[dri]?.let { resolve(it, context) + "#$dri" } + ?: anchorsIndex[dri]?.let { resolve(it, context) + "#${dri.first}" } override fun pathToRoot(from: PageNode): String = diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 5e6f8f20..d42acb32 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -631,20 +631,26 @@ private class DokkaDescriptorVisitor( private fun KotlinType.toBound(): Bound = when (this) { is DynamicType -> Dynamic - else -> when (val ctor = constructor.declarationDescriptor) { - is TypeParameterDescriptor -> TypeParameter( - dri = DRI.from(ctor), - name = ctor.name.asString() - ) - else -> TypeConstructor( - DRI.from(ctor!!), // TODO: remove '!!' - arguments.map { it.toProjection() }, - if (isExtensionFunctionType) FunctionModifiers.EXTENSION - else if (isFunctionType) FunctionModifiers.FUNCTION - else FunctionModifiers.NONE - ) - }.let { - if (isMarkedNullable) Nullable(it) else it + else -> { + val ctor = when (this) { + is AbbreviatedType -> abbreviation.constructor.declarationDescriptor + else -> constructor.declarationDescriptor + } + when (ctor) { + is TypeParameterDescriptor -> TypeParameter( + dri = DRI.from(ctor), + name = ctor.name.asString() + ) + else -> TypeConstructor( + DRI.from(ctor!!), // TODO: remove '!!' + arguments.map { it.toProjection() }, + if (isExtensionFunctionType) FunctionModifiers.EXTENSION + else if (isFunctionType) FunctionModifiers.FUNCTION + else FunctionModifiers.NONE + ) + }.let { + if (isMarkedNullable) Nullable(it) else it + } } } diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 55e59b77..a702766e 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs import kotlin.reflect.KClass import kotlin.reflect.full.isSubclassOf import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet +import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint import org.jetbrains.dokka.base.transformers.documentables.ClashingDriIdentifier private typealias GroupedTags = Map, List>> @@ -73,8 +74,6 @@ open class DefaultPageCreator( open fun pageForFunction(f: DFunction) = MemberPageNode(f.name, contentForFunction(f), setOf(f.dri), f) - open fun pageForTypeAlias(t: DTypeAlias) = MemberPageNode(t.name, contentForTypeAlias(t), setOf(t.dri), t) - private val WithScope.filteredFunctions: List get() = functions.mapNotNull { function -> function.takeIf { @@ -476,7 +475,7 @@ open class DefaultPageCreator( } protected open fun contentForFunction(f: DFunction) = contentForMember(f) - protected open fun contentForTypeAlias(t: DTypeAlias) = contentForMember(t) + protected open fun contentForMember(d: Documentable) = contentBuilder.contentFor(d) { group(kind = ContentKind.Cover) { cover(d.name.orEmpty()) @@ -522,7 +521,7 @@ open class DefaultPageCreator( kind = kind ) { elements.map { - instance(setOf(it.dri), it.sourceSets.toSet()) { + instance(setOf(it.dri), it.sourceSets.toSet(), extra = PropertyContainer.withAll(SymbolAnchorHint)) { before { contentForBrief(it) contentForSinceKotlin(it) -- cgit