Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't expose enum constructor arguments to documentations #2497

Merged
merged 2 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -858,24 +858,6 @@ public final class org/jetbrains/dokka/model/CompositeSourceSetIDKt {
public static final fun plus (Lorg/jetbrains/dokka/DokkaSourceSetID;Lorg/jetbrains/dokka/DokkaSourceSetID;)Lorg/jetbrains/dokka/model/CompositeSourceSetID;
}

public final class org/jetbrains/dokka/model/ConstructorValues : org/jetbrains/dokka/model/properties/ExtraProperty {
public static final field Companion Lorg/jetbrains/dokka/model/ConstructorValues$Companion;
public fun <init> (Ljava/util/Map;)V
public final fun component1 ()Ljava/util/Map;
public final fun copy (Ljava/util/Map;)Lorg/jetbrains/dokka/model/ConstructorValues;
public static synthetic fun copy$default (Lorg/jetbrains/dokka/model/ConstructorValues;Ljava/util/Map;ILjava/lang/Object;)Lorg/jetbrains/dokka/model/ConstructorValues;
public fun equals (Ljava/lang/Object;)Z
public fun getKey ()Lorg/jetbrains/dokka/model/properties/ExtraProperty$Key;
public final fun getValues ()Ljava/util/Map;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class org/jetbrains/dokka/model/ConstructorValues$Companion : org/jetbrains/dokka/model/properties/ExtraProperty$Key {
public synthetic fun mergeStrategyFor (Ljava/lang/Object;Ljava/lang/Object;)Lorg/jetbrains/dokka/model/properties/MergeStrategy;
public fun mergeStrategyFor (Lorg/jetbrains/dokka/model/ConstructorValues;Lorg/jetbrains/dokka/model/ConstructorValues;)Lorg/jetbrains/dokka/model/properties/MergeStrategy$Replace;
}

public final class org/jetbrains/dokka/model/Contravariance : org/jetbrains/dokka/model/Variance {
public fun <init> (Lorg/jetbrains/dokka/model/Bound;)V
public final fun component1 ()Lorg/jetbrains/dokka/model/Bound;
Expand Down
9 changes: 0 additions & 9 deletions core/src/main/kotlin/model/additionalExtras.kt
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,3 @@ data class ActualTypealias(val underlyingType: SourceSetDependent<Bound>) : Extr

override val key: ExtraProperty.Key<DClasslike, ActualTypealias> = ActualTypealias
}

data class ConstructorValues(val values: SourceSetDependent<List<Expression>>) : ExtraProperty<DEnumEntry> {
companion object : ExtraProperty.Key<DEnumEntry, ConstructorValues> {
override fun mergeStrategyFor(left: ConstructorValues, right: ConstructorValues) =
MergeStrategy.Replace(ConstructorValues(left.values + right.values))
}

override val key: ExtraProperty.Key<DEnumEntry, ConstructorValues> = ConstructorValues
}
11 changes: 0 additions & 11 deletions plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,6 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
group(styles = setOf(TextStyle.Block)) {
annotationsBlock(e)
link(e.name, e.dri, styles = emptySet())
e.extra[ConstructorValues]?.let { constructorValues ->
constructorValues.values[it]?.let { values ->
list(
elements = values,
prefix = "(",
suffix = ")",
separator = ", ",
separatorStyles = mainStyles + TokenStyle.Punctuation,
) { highlightValue(it) }
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@ private class DokkaDescriptorVisitor(
expectPresentInSet = sourceSet.takeIf { isExpect },
extra = PropertyContainer.withAll(
descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(),
descriptor.getAnnotations().toSourceSetDependent().toAnnotations(),
ConstructorValues(descriptor.getAppliedConstructorParameters().toSourceSetDependent())
descriptor.getAnnotations().toSourceSetDependent().toAnnotations()
)
)
}
Expand Down
51 changes: 0 additions & 51 deletions plugins/base/src/test/kotlin/enums/EnumsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -276,52 +276,6 @@ class EnumsTest : BaseAbstractTest() {
}
}

@Test
fun enumWithConstructor() {
val configuration = dokkaConfiguration {
sourceSets {
sourceSet {
sourceRoots = listOf("src/")
}
}
}

testInline(
"""
|/src/main/kotlin/basic/TestEnum.kt
|package testpackage
|
|
|enum class TestEnum(name: String, index: Int, excluded: Boolean) {
| E1("e1", 1, true),
| E2("e2", 2, false);
|}
""".trimMargin(),
configuration
) {
documentablesTransformationStage = { m ->
m.packages.let { p ->
p.first().classlikes.let { c ->
val enum = c.first() as DEnum
val (first, second) = enum.entries.sortedBy { it.name }

assertEquals(1, first.extra.allOfType<ConstructorValues>().size)
assertEquals(1, second.extra.allOfType<ConstructorValues>().size)
assertEquals(listOf(StringConstant("e1"), IntegerConstant(1), BooleanConstant(true)), first.extra.allOfType<ConstructorValues>().first().values.values.first())
assertEquals(listOf(StringConstant("e2"), IntegerConstant(2), BooleanConstant(false)), second.extra.allOfType<ConstructorValues>().first().values.values.first())
}
}
}
pagesGenerationStage = { module ->
val entryPage = module.dfs { it.name == "E1" } as ClasslikePageNode
val signaturePart = (entryPage.content.dfs {
it is ContentGroup && it.dci.toString() == "[testpackage/TestEnum.E1///PointingToDeclaration/{\"org.jetbrains.dokka.links.EnumEntryDRIExtra\":{\"key\":\"org.jetbrains.dokka.links.EnumEntryDRIExtra\"}}][Symbol]"
} as ContentGroup)
assertEquals("(\"e1\", 1, true)", signaturePart.constructorSignature())
}
}
}

@Test
fun enumWithMethods() {
val configuration = dokkaConfiguration {
Expand Down Expand Up @@ -356,8 +310,6 @@ class EnumsTest : BaseAbstractTest() {
val enum = c.first { it is DEnum } as DEnum
val first = enum.entries.first()

assertEquals(1, first.extra.allOfType<ConstructorValues>().size)
assertEquals(emptyList<String>(), first.extra.allOfType<ConstructorValues>().first().values.values.first())
assertNotNull(first.functions.find { it.name == "toBeImplemented" })
}
}
Expand Down Expand Up @@ -414,7 +366,4 @@ class EnumsTest : BaseAbstractTest() {
}
}
}

private fun ContentGroup.constructorSignature(): String =
(children.single() as ContentGroup).children.drop(1).joinToString(separator = "") { (it as ContentText).text }
}
4 changes: 2 additions & 2 deletions plugins/base/src/test/kotlin/signatures/SignatureTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ class SignatureTest : BaseAbstractTest() {
}

@Test
fun `should have no empty parentheses for no-arg enum entry`() {
fun `should not expose enum constructor entry arguments`() {
val writerPlugin = TestOutputWriterPlugin()

testInline(
Expand Down Expand Up @@ -905,7 +905,7 @@ class SignatureTest : BaseAbstractTest() {
)

enumEntrySignatures[1].match(
A("WITH_ARG"), "(\"arg\")",
A("WITH_ARG"),
ignoreSpanWithTokenStyle = true
)
}
Expand Down