aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src
diff options
context:
space:
mode:
authorBłażej Kardyś <bkardys@virtuslab.com>2020-03-25 23:11:54 +0100
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-03-26 12:38:55 +0100
commitaad9a75c6ace63e883c8f737a9c4bd0933688adf (patch)
treeaa2926fd59e71419e930676754372ce130e23547 /plugins/base/src
parent3f9dedbc9a0d559ab1320c395847ff88af7ad497 (diff)
downloaddokka-aad9a75c6ace63e883c8f737a9c4bd0933688adf.tar.gz
dokka-aad9a75c6ace63e883c8f737a9c4bd0933688adf.tar.bz2
dokka-aad9a75c6ace63e883c8f737a9c4bd0933688adf.zip
Fixing enum entries parsing for descriptors and presentation
Diffstat (limited to 'plugins/base/src')
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt3
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt4
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt32
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt2
4 files changed, 37 insertions, 4 deletions
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)