diff options
author | Marcin Aman <maman@virtuslab.com> | 2020-06-04 16:44:25 +0200 |
---|---|---|
committer | BarkingBad <32793002+BarkingBad@users.noreply.github.com> | 2020-06-09 10:43:38 +0200 |
commit | 23e0d26139a09c7e2e157d1e0099ceab58d9bb48 (patch) | |
tree | 6770e453866595b6e212c43a9f73bbe9e1b6c78c | |
parent | 435e34fe4d63b85ec8f93155153eda0ea2303d73 (diff) | |
download | dokka-23e0d26139a09c7e2e157d1e0099ceab58d9bb48.tar.gz dokka-23e0d26139a09c7e2e157d1e0099ceab58d9bb48.tar.bz2 dokka-23e0d26139a09c7e2e157d1e0099ceab58d9bb48.zip |
Make enum entry constructor sourceset dependent
5 files changed, 22 insertions, 22 deletions
diff --git a/core/src/main/kotlin/model/aditionalExtras.kt b/core/src/main/kotlin/model/aditionalExtras.kt index 055fc5a6..1023545d 100644 --- a/core/src/main/kotlin/model/aditionalExtras.kt +++ b/core/src/main/kotlin/model/aditionalExtras.kt @@ -61,12 +61,10 @@ data class ActualTypealias(val underlyingType: SourceSetDependent<Bound>) : Extr override val key: ExtraProperty.Key<DClasslike, ActualTypealias> = ActualTypealias } -data class ConstructorValues(val values: List<String>) : ExtraProperty<DEnumEntry>{ +data class ConstructorValues(val values: SourceSetDependent<List<String>>) : ExtraProperty<DEnumEntry>{ companion object : ExtraProperty.Key<DEnumEntry, ConstructorValues> { override fun mergeStrategyFor(left: ConstructorValues, right: ConstructorValues) = - MergeStrategy.Fail{ - throw IllegalArgumentException("Merging constructor parameters not applicable") - } + MergeStrategy.Replace(ConstructorValues(left.values + right.values)) } override val key: ExtraProperty.Key<DEnumEntry, ConstructorValues> = ConstructorValues diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index 367a7a95..c05dab3c 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -37,9 +37,9 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog group(styles = setOf(TextStyle.Block)){ annotationsBlock(e) link(e.name, e.dri, styles = emptySet()) - e.extra[ConstructorValues]?.let { - list(it.values, prefix = "(", suffix = ")"){ - text(it) + e.extra[ConstructorValues]?.let { constructorValues -> + platformText(constructorValues.values, constructorValues.values.keys){ + it.joinToString(prefix = "(", postfix = ")") } } } diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index a56eb454..f3b047bc 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -219,7 +219,7 @@ private class DokkaDescriptorVisitor( extra = PropertyContainer.withAll( descriptor.additionalExtras(), descriptor.getAnnotations(), - ConstructorValues(descriptor.getAppliedConstructorParameters()) + ConstructorValues(descriptor.getAppliedConstructorParameters().toSourceSetDependent()) ) ) } diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 7f9a8074..1954cec9 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -141,8 +141,10 @@ open class DefaultPageCreator( protected open fun contentForEnumEntry(e: DEnumEntry) = contentBuilder.contentFor(e) { group(kind = ContentKind.Cover) { header(1, e.name) - +buildSignature(e) - +contentForDescription(e) + sourceSetDependentHint(e.dri, e.sourceSets.toSet()) { + +buildSignature(e) + +contentForDescription(e) + } } group(styles = setOf(ContentStyle.TabbedContent)){ +contentForComments(e) diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt index 6c44dc35..74fc18c4 100644 --- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -1,9 +1,6 @@ package enums -import matchers.content.assertNode -import matchers.content.group -import matchers.content.header -import matchers.content.link +import matchers.content.* import org.jetbrains.dokka.model.ConstructorValues import org.jetbrains.dokka.model.DEnum import org.jetbrains.dokka.pages.* @@ -121,8 +118,8 @@ class EnumsTest : AbstractCoreTest() { assertEquals(1, first.extra.allOfType<ConstructorValues>().size) assertEquals(1, second.extra.allOfType<ConstructorValues>().size) - assertEquals(listOf("\"e1\"", "1", "true"), first.extra.allOfType<ConstructorValues>().first().values) - assertEquals(listOf("\"e2\"", "2", "false"), second.extra.allOfType<ConstructorValues>().first().values) + assertEquals(listOf("\"e1\"", "1", "true"), first.extra.allOfType<ConstructorValues>().first().values.values.first()) + assertEquals(listOf("\"e2\"", "2", "false"), second.extra.allOfType<ConstructorValues>().first().values.values.first()) } } } @@ -171,7 +168,7 @@ class EnumsTest : AbstractCoreTest() { val first = enum.entries.first() assertEquals(1, first.extra.allOfType<ConstructorValues>().size) - assertEquals(emptyList<String>(), first.extra.allOfType<ConstructorValues>().first().values) + assertEquals(emptyList<String>(), first.extra.allOfType<ConstructorValues>().first().values.values.first()) assertNotNull(first.functions.find { it.name == "toBeImplemented" }) } } @@ -207,13 +204,16 @@ class EnumsTest : AbstractCoreTest() { signature.assertNode { header(1) { +"E1" } - group { - mapOf("SinceKotlin" to setOf("version")).entries.forEach { - group { + platformHinted { + group { + mapOf("SinceKotlin" to setOf("version")).entries.forEach { group { - unwrapAnnotation(it) + group { + unwrapAnnotation(it) + } + link { +"E1" } + +"()" } - link { +"E1" } } } } |