diff options
Diffstat (limited to 'plugins/base/src')
5 files changed, 45 insertions, 1 deletions
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index 8d8c5f73..a30e1b72 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -27,6 +27,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog is DClasslike -> signature(documentable) is DTypeParameter -> signature(documentable) is DEnumEntry -> signature(documentable) + is DTypeAlias -> signature(documentable) else -> throw NotImplementedError( "Cannot generate signature for ${documentable::class.qualifiedName} ${documentable.name}" ) @@ -105,6 +106,13 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog else -> true } + private fun signature(t: DTypeAlias) = contentBuilder.contentFor(t, ContentKind.Symbol, setOf(TextStyle.Monospace)) { + text("typealias ") + signatureForProjection(t.type) + text(" = ") + signatureForProjection(t.underlyingType) + } + private fun signature(t: DTypeParameter) = contentBuilder.contentFor(t) { link(t.name, t.dri) list(t.bounds, prefix = " : ") { diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt index 9f86c82a..36441426 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt @@ -67,6 +67,7 @@ internal object DocumentableVisibilityFilter : PreMergeDocumentableTransformer { functions, properties, classlikes, + it.typealiases, it.documentation, it.platformData, it.extra diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 5f2b5a46..ceb4d0bd 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -78,6 +78,7 @@ private class DokkaDescriptorVisitor( functions = scope.functions(driWithPlatform), properties = scope.properties(driWithPlatform), classlikes = scope.classlikes(driWithPlatform), + typealiases = scope.typealiases(driWithPlatform), documentation = descriptor.resolveDescriptorData(platformData), platformData = listOf(platformData) ) @@ -403,6 +404,16 @@ private class DokkaDescriptorVisitor( ) } + override fun visitTypeAliasDescriptor(descriptor: TypeAliasDescriptor, parent: DRIWithPlatformInfo?) = + DTypeAlias( + dri = DRI.from(descriptor), + name = descriptor.name.asString(), + type = descriptor.defaultType.toBound(), + underlyingType = descriptor.underlyingType.toBound(), + documentation = descriptor.resolveDescriptorData(platformData), + platformData = listOf(platformData) + ) + private fun parameter(index: Int, descriptor: ValueParameterDescriptor, parent: DRIWithPlatformInfo) = DParameter( dri = parent.dri.copy(target = index + 1), @@ -439,6 +450,11 @@ private class DokkaDescriptorVisitor( .filterIsInstance<PackageFragmentDescriptor>() .map { visitPackageFragmentDescriptor(it, parent) } + private fun MemberScope.typealiases(parent: DRIWithPlatformInfo): List<DTypeAlias> = + getContributedDescriptors(DescriptorKindFilter.TYPE_ALIASES) { true } + .filterIsInstance<TypeAliasDescriptor>() + .map { visitTypeAliasDescriptor(it, parent) } + private fun MemberScope.enumEntries(parent: DRIWithPlatformInfo): List<DEnumEntry> = this.getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS) { true } .filterIsInstance<ClassDescriptor>() diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 67284b22..5ed44e18 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -32,7 +32,8 @@ open class DefaultPageCreator( open fun pageForPackage(p: DPackage): PackagePageNode = PackagePageNode( p.name, contentForPackage(p), setOf(p.dri), p, p.classlikes.map(::pageForClasslike) + - p.functions.map(::pageForFunction) + p.functions.map(::pageForFunction) + + p.typealiases.map(::pageForTypeAlias) ) open fun pageForEnumEntry(e: DEnumEntry): ClasslikePageNode = @@ -56,6 +57,8 @@ 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 get() = functions.filter { it.extra[InheritedFunction]?.isInherited != true } @@ -73,6 +76,15 @@ open class DefaultPageCreator( header(1) { text("Package ${p.name}") } } +contentForScope(p, p.dri, p.platformData) + block("Type aliases", 2, ContentKind.Classlikes, p.typealiases, p.platformData.toSet()) { + link(it.name, it.dri) + group { + +buildSignature(it) + group(kind = ContentKind.BriefComment) { + text(it.briefDocumentation()) + } + } + } } protected open fun contentForScope( @@ -304,6 +316,12 @@ open class DefaultPageCreator( +contentForComments(f) } + protected open fun contentForTypeAlias(t: DTypeAlias) = contentBuilder.contentFor(t) { + header(1) { text(t.name) } + +buildSignature(t) + +contentForComments(t) + } + protected open fun TagWrapper.toHeaderString() = this.javaClass.toGenericString().split('.').last() //TODO: It isn't platform-aware and produces wrong docs Probably should use platformDependentHint diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index 87c78aa8..33100e3e 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -44,6 +44,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { psiFiles.flatMap { psFile -> psFile.classes.map { docParser.parseClasslike(it, dri) } }, + emptyList(), PlatformDependent.empty(), listOf(platformData) ) |