diff options
6 files changed, 43 insertions, 4 deletions
diff --git a/core/src/main/resources/dokka/styles/style.css b/core/src/main/resources/dokka/styles/style.css index 063a9502..46a78467 100644 --- a/core/src/main/resources/dokka/styles/style.css +++ b/core/src/main/resources/dokka/styles/style.css @@ -73,6 +73,9 @@ text-decoration: line-through; } +.symbol:empty { + padding: 0px; +} .symbol { padding: 5px; background-color: #F4F4F4; diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index f59a41a1..8d8c5f73 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -26,11 +26,14 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog is DProperty -> signature(documentable) is DClasslike -> signature(documentable) is DTypeParameter -> signature(documentable) + is DEnumEntry -> signature(documentable) else -> throw NotImplementedError( "Cannot generate signature for ${documentable::class.qualifiedName} ${documentable.name}" ) } + private fun signature(e: DEnumEntry)= contentBuilder.contentFor(e, ContentKind.Symbol, setOf(TextStyle.Monospace)) + private fun signature(c: DClasslike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) { platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " } if (c is DClass) { diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index bed6c25c..1c374626 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -422,8 +422,8 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv private fun MemberScope.classlikes(parent: DRIWithPlatformInfo): List<DClasslike> = getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS) { true } - .filterIsInstance<ClassDescriptor>() - .map { visitClassDescriptor(it, parent) } + .filter { it is ClassDescriptor && it.kind != ClassKind.ENUM_ENTRY } + .map { visitClassDescriptor(it as ClassDescriptor, parent) } .mapNotNull { it as? DClasslike } private fun MemberScope.packages(parent: DRIWithPlatformInfo): List<DPackage> = diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index da30cf6f..b217117b 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -29,6 +29,13 @@ open class DefaultPageCreator( p.functions.map(::pageForFunction) ) + open fun pageForEnumEntry(e: DEnumEntry): ClasslikePageNode = + ClasslikePageNode( + e.name.orEmpty(), contentForEnumEntry(e), setOf(e.dri), e, + e.classlikes.map(::pageForClasslike) + + e.functions.map(::pageForFunction) + ) + open fun pageForClasslike(c: DClasslike): ClasslikePageNode { val constructors = if (c is WithConstructors) c.constructors else emptyList() @@ -36,7 +43,8 @@ open class DefaultPageCreator( c.name.orEmpty(), contentForClasslike(c), setOf(c.dri), c, constructors.map(::pageForFunction) + c.classlikes.map(::pageForClasslike) + - c.functions.map(::pageForFunction) + c.functions.map(::pageForFunction) + + if (c is DEnum) c.entries.map(::pageForEnumEntry) else emptyList() ) } @@ -103,6 +111,15 @@ open class DefaultPageCreator( } } + protected open fun contentForEnumEntry(e: DEnumEntry) = contentBuilder.contentFor(e) { + header(1) { text(e.name.orEmpty()) } + +buildSignature(e) + + +contentForComments(e) { it !is Property } + + +contentForScope(e, e.dri, e.platformData) + } + protected open fun contentForClasslike(c: DClasslike) = contentBuilder.contentFor(c) { header(1) { text(c.name.orEmpty()) } platformDependentHint(c.dri, c.platformData.toSet()) { @@ -130,6 +147,19 @@ open class DefaultPageCreator( } } } + if (c is DEnum) { + block( + "Entries", 2, ContentKind.Classlikes, c.entries, c.platformData.toSet() + ) { + link(it.name.orEmpty(), it.dri) + group { + +buildSignature(it) + group(kind = ContentKind.BriefComment) { + text(it.briefDocumentation()) + } + } + } + } +contentForScope(c, c.dri, c.platformData) } diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt index 681b8c71..516e5524 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt @@ -34,7 +34,7 @@ open class PageContentBuilder( kind: Kind = ContentKind.Main, styles: Set<Style> = emptySet(), extra: PropertyContainer<ContentNode> = PropertyContainer.empty(), - block: DocumentableContentBuilder.() -> Unit + block: DocumentableContentBuilder.() -> Unit = {} ): ContentGroup = DocumentableContentBuilder(d.dri, d.platformData.toSet(), styles, extra) .apply(block) diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt index 54bf663d..66328666 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt @@ -23,12 +23,15 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge is DFunction -> signature(documentable) is DProperty -> signature(documentable) is DClasslike -> signature(documentable) + is DEnumEntry -> signature(documentable) is DTypeParameter -> signature(documentable) else -> throw NotImplementedError( "Cannot generate signature for ${documentable::class.qualifiedName} ${documentable.name}" ) } + private fun signature(e: DEnumEntry)= contentBuilder.contentFor(e, ContentKind.Symbol, setOf(TextStyle.Monospace)) + private fun signature(c: DClasslike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) { platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " } |