aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src')
-rw-r--r--plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt (renamed from plugins/base/src/main/kotlin/signatures/JvmSingatureUtils.kt)22
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt5
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt9
-rw-r--r--plugins/base/src/main/kotlin/signatures/SignatureProvider.kt4
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt66
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt6
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt17
-rw-r--r--plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt5
-rw-r--r--plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt26
-rw-r--r--plugins/base/src/test/kotlin/model/ClassesTest.kt10
-rw-r--r--plugins/base/src/test/kotlin/model/FunctionsTest.kt45
-rw-r--r--plugins/base/src/test/kotlin/model/JavaTest.kt10
-rw-r--r--plugins/base/src/test/kotlin/model/PropertyTest.kt2
-rw-r--r--plugins/base/src/test/kotlin/utils/contentUtils.kt38
14 files changed, 146 insertions, 119 deletions
diff --git a/plugins/base/src/main/kotlin/signatures/JvmSingatureUtils.kt b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt
index dde553b9..0ae72109 100644
--- a/plugins/base/src/main/kotlin/signatures/JvmSingatureUtils.kt
+++ b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt
@@ -1,11 +1,10 @@
package org.jetbrains.dokka.base.signatures
-import javaslang.Tuple2
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.properties.WithExtraProperties
-interface JvmSingatureUtils {
+interface JvmSignatureUtils {
fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: Documentable)
@@ -20,7 +19,7 @@ interface JvmSingatureUtils {
extra[Annotations]?.content ?: emptyList()
private fun Annotations.Annotation.toSignatureString(): String =
- "@${this.dri.classNames}(${this.params.entries.joinToString { it.key + "=" + it.value }})"
+ "@" + this.dri.classNames + "(" + this.params.entries.joinToString { it.key + "=" + it.value } + ")"
private fun PageContentBuilder.DocumentableContentBuilder.annotations(
d: Documentable,
@@ -45,15 +44,10 @@ interface JvmSingatureUtils {
}
} ?: Unit
- fun <T : Documentable> WithExtraProperties<T>.modifiersWithFilter(
- filter: Set<ExtraModifiers> = ExtraModifiers.values().toSet()
- ): Set<ExtraModifiers> =
- extra[AdditionalModifiers]?.content?.filter { it in filter }?.toSet() ?: emptySet()
-
fun PageContentBuilder.DocumentableContentBuilder.toSignatureString(
a: Annotations.Annotation,
renderAtStrategy: AtStrategy,
- listBrackets: Tuple2<Char, Char>,
+ listBrackets: Pair<Char, Char>,
classExtension: String
) {
when (renderAtStrategy) {
@@ -78,17 +72,17 @@ interface JvmSingatureUtils {
private fun PageContentBuilder.DocumentableContentBuilder.valueToSignature(
a: AnnotationParameterValue,
renderAtStrategy: AtStrategy,
- listBrackets: Tuple2<Char, Char>,
+ listBrackets: Pair<Char, Char>,
classExtension: String
): Unit = when (a) {
is AnnotationValue -> toSignatureString(a.annotation, renderAtStrategy, listBrackets, classExtension)
is ArrayValue -> {
- text(listBrackets._1.toString())
+ text(listBrackets.first.toString())
a.value.forEachIndexed { i, it ->
valueToSignature(it, renderAtStrategy, listBrackets, classExtension)
if (i != a.value.size - 1) text(", ")
}
- text(listBrackets._2.toString())
+ text(listBrackets.second.toString())
}
is EnumValue -> link(a.enumName, a.enumDri)
is ClassValue -> link(a.className + classExtension, a.classDRI)
@@ -99,7 +93,7 @@ interface JvmSingatureUtils {
d: Documentable,
ignored: Set<Annotations.Annotation>,
renderAtStrategy: AtStrategy,
- listBrackets: Tuple2<Char, Char>,
+ listBrackets: Pair<Char, Char>,
classExtension: String
) {
annotations(d, ignored) {
@@ -113,7 +107,7 @@ interface JvmSingatureUtils {
d: Documentable,
ignored: Set<Annotations.Annotation>,
renderAtStrategy: AtStrategy,
- listBrackets: Tuple2<Char, Char>,
+ listBrackets: Pair<Char, Char>,
classExtension: String
) {
annotations(d, ignored) {
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index 4c689abc..33c82458 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -6,7 +6,6 @@ import org.jetbrains.dokka.links.*
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.Nullable
import org.jetbrains.dokka.model.TypeConstructor
-import org.jetbrains.dokka.model.properties.ExtraProperty
import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.ContentKind
import org.jetbrains.dokka.pages.ContentNode
@@ -15,7 +14,7 @@ import org.jetbrains.dokka.utilities.DokkaLogger
import kotlin.text.Typography.nbsp
class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogger) : SignatureProvider,
- JvmSingatureUtils by KotlinSignatureUtils {
+ JvmSignatureUtils by KotlinSignatureUtils {
private val contentBuilder = PageContentBuilder(ctcc, this, logger)
private val ignoredVisibilities = setOf(JavaVisibility.Public, KotlinVisibility.Public)
@@ -69,7 +68,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
if (c is DClass) {
platformText(c.modifier, sourceSets) {
if (it !in ignoredModifiers)
- if (c.extra[AdditionalModifiers]?.content?.contains(ExtraModifiers.DATA) == true) ""
+ if (c.extra[AdditionalModifiers]?.content?.contains(ExtraModifiers.KotlinOnlyModifiers.Data) == true) ""
else (if (it is JavaModifier.Empty) KotlinModifier.Open else it).let { it.name + " " }
else
""
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
index 3ce4be0a..48cfe304 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
@@ -1,16 +1,15 @@
package org.jetbrains.dokka.base.signatures
-import javaslang.Tuple2
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
+import org.jetbrains.dokka.model.AdditionalModifiers
import org.jetbrains.dokka.model.Documentable
import org.jetbrains.dokka.model.ExtraModifiers
-import org.jetbrains.dokka.model.ExtraModifiers.Companion.kotlinOnlyModifiers
import org.jetbrains.dokka.model.properties.WithExtraProperties
-object KotlinSignatureUtils : JvmSingatureUtils {
+object KotlinSignatureUtils : JvmSignatureUtils {
private val strategy = OnlyOnce
- private val listBrackets = Tuple2('[', ']')
+ private val listBrackets = Pair('[', ']')
private val classExtension = "::class"
override fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: Documentable) =
@@ -20,5 +19,5 @@ object KotlinSignatureUtils : JvmSingatureUtils {
annotationsInlineWithIgnored(d, emptySet(), strategy, listBrackets, classExtension)
override fun <T : Documentable> WithExtraProperties<T>.modifiers() =
- modifiersWithFilter(kotlinOnlyModifiers)
+ extra[AdditionalModifiers]?.content?.filterIsInstance<ExtraModifiers.KotlinOnlyModifiers>()?.toSet() ?: emptySet()
} \ No newline at end of file
diff --git a/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt
index 7d7995b7..c04b6ecf 100644
--- a/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt
@@ -1,11 +1,7 @@
package org.jetbrains.dokka.base.signatures
-import javaslang.Tuple2
-import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.model.*
-import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.ContentNode
-import org.jetbrains.dokka.pages.TextStyle
interface SignatureProvider {
fun signature(documentable: Documentable): ContentNode
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index c24a3384..65b83200 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -46,7 +46,7 @@ import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeProjection
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
import java.nio.file.Paths
-import java.lang.IllegalArgumentException
+import kotlin.IllegalArgumentException
import kotlin.reflect.jvm.internal.impl.resolve.constants.KClassValue
object DefaultDescriptorToDocumentableTranslator : SourceToDocumentableTranslator {
@@ -546,9 +546,7 @@ private class DokkaDescriptorVisitor(
is TypeParameterDescriptor -> OtherParameter(
declarationDRI = DRI.from(ctor.containingDeclaration),
name = ctor.name.asString()
- ).let {
- if (isMarkedNullable) Nullable(it) else it
- }
+ )
else -> TypeConstructor(
DRI.from(constructor.declarationDescriptor!!), // TODO: remove '!!'
arguments.map { it.toProjection() },
@@ -556,6 +554,8 @@ private class DokkaDescriptorVisitor(
else if (isFunctionType) FunctionModifiers.FUNCTION
else FunctionModifiers.NONE
)
+ }.let {
+ if (isMarkedNullable) Nullable(it) else it
}
}
@@ -593,43 +593,43 @@ private class DokkaDescriptorVisitor(
DescriptorDocumentableSource(this).toSourceSetDependent()
private fun FunctionDescriptor.additionalExtras() = listOfNotNull(
- ExtraModifiers.INFIX.takeIf { isInfix },
- ExtraModifiers.INLINE.takeIf { isInline },
- ExtraModifiers.SUSPEND.takeIf { isSuspend },
- ExtraModifiers.OPERATOR.takeIf { isOperator },
- ExtraModifiers.STATIC.takeIf { isJvmStaticInObjectOrClassOrInterface() },
- ExtraModifiers.TAILREC.takeIf { isTailrec },
- ExtraModifiers.EXTERNAL.takeIf { isExternal },
- ExtraModifiers.OVERRIDE.takeIf { DescriptorUtils.isOverride(this) }
+ ExtraModifiers.KotlinOnlyModifiers.Infix.takeIf { isInfix },
+ ExtraModifiers.KotlinOnlyModifiers.Inline.takeIf { isInline },
+ ExtraModifiers.KotlinOnlyModifiers.Suspend.takeIf { isSuspend },
+ ExtraModifiers.KotlinOnlyModifiers.Operator.takeIf { isOperator },
+ ExtraModifiers.JavaOnlyModifiers.Static.takeIf { isJvmStaticInObjectOrClassOrInterface() },
+ ExtraModifiers.KotlinOnlyModifiers.TailRec.takeIf { isTailrec },
+ ExtraModifiers.KotlinOnlyModifiers.External.takeIf { isExternal },
+ ExtraModifiers.KotlinOnlyModifiers.Override.takeIf { DescriptorUtils.isOverride(this) }
).toProperty()
private fun ClassDescriptor.additionalExtras() = listOfNotNull(
- ExtraModifiers.INLINE.takeIf { isInline },
- ExtraModifiers.EXTERNAL.takeIf { isExternal },
- ExtraModifiers.INNER.takeIf { isInner },
- ExtraModifiers.DATA.takeIf { isData }
+ ExtraModifiers.KotlinOnlyModifiers.Inline.takeIf { isInline },
+ ExtraModifiers.KotlinOnlyModifiers.External.takeIf { isExternal },
+ ExtraModifiers.KotlinOnlyModifiers.Inner.takeIf { isInner },
+ ExtraModifiers.KotlinOnlyModifiers.Data.takeIf { isData }
).toProperty()
private fun ValueParameterDescriptor.additionalExtras() =
listOfNotNull(
- ExtraModifiers.NOINLINE.takeIf { isNoinline },
- ExtraModifiers.CROSSINLINE.takeIf { isCrossinline },
- ExtraModifiers.CONST.takeIf { isConst },
- ExtraModifiers.LATEINIT.takeIf { isLateInit },
- ExtraModifiers.VARARG.takeIf { isVararg }
+ ExtraModifiers.KotlinOnlyModifiers.NoInline.takeIf { isNoinline },
+ ExtraModifiers.KotlinOnlyModifiers.CrossInline.takeIf { isCrossinline },
+ ExtraModifiers.KotlinOnlyModifiers.Const.takeIf { isConst },
+ ExtraModifiers.KotlinOnlyModifiers.LateInit.takeIf { isLateInit },
+ ExtraModifiers.KotlinOnlyModifiers.VarArg.takeIf { isVararg }
).toProperty()
private fun TypeParameterDescriptor.additionalExtras() =
listOfNotNull(
- ExtraModifiers.REIFIED.takeIf { isReified }
+ ExtraModifiers.KotlinOnlyModifiers.Reified.takeIf { isReified }
).toProperty()
private fun PropertyDescriptor.additionalExtras() = listOfNotNull(
- ExtraModifiers.CONST.takeIf { isConst },
- ExtraModifiers.LATEINIT.takeIf { isLateInit },
- ExtraModifiers.STATIC.takeIf { isJvmStaticInObjectOrClassOrInterface() },
- ExtraModifiers.EXTERNAL.takeIf { isExternal },
- ExtraModifiers.OVERRIDE.takeIf { DescriptorUtils.isOverride(this) }
+ ExtraModifiers.KotlinOnlyModifiers.Const.takeIf { isConst },
+ ExtraModifiers.KotlinOnlyModifiers.LateInit.takeIf { isLateInit },
+ ExtraModifiers.JavaOnlyModifiers.Static.takeIf { isJvmStaticInObjectOrClassOrInterface() },
+ ExtraModifiers.KotlinOnlyModifiers.External.takeIf { isExternal },
+ ExtraModifiers.KotlinOnlyModifiers.Override.takeIf { DescriptorUtils.isOverride(this) }
)
private fun List<ExtraModifiers>.toProperty() =
@@ -640,11 +640,12 @@ private class DokkaDescriptorVisitor(
private fun Annotated.getListOfAnnotations() = annotations.map { it.toAnnotation() }
private fun ConstantValue<*>.toValue(): AnnotationParameterValue = when (this) {
- is ConstantsAnnotationValue -> AnnotationValue(value.let { it.toAnnotation() })
+ is ConstantsAnnotationValue -> AnnotationValue(value.toAnnotation())
is ConstantsArrayValue -> ArrayValue(value.map { it.toValue() })
is ConstantsEnumValue -> EnumValue(
- enumEntryName.identifier,
- enumClassId.let { DRI(it.packageFqName.asString(), it.relativeClassName.asString()) })
+ fullEnumEntryName(),
+ DRI(enumClassId.packageFqName.asString(), fullEnumEntryName())
+ )
is ConstantsKtClassValue -> when(value) {
is NormalClass -> (value as NormalClass).value.classId.let {
ClassValue(
@@ -672,7 +673,7 @@ private class DokkaDescriptorVisitor(
private fun FieldDescriptor.getAnnotationsAsExtraModifiers() = getAnnotations().content.mapNotNull {
try {
- ExtraModifiers.valueOf(it.dri.classNames?.toUpperCase() ?: "")
+ ExtraModifiers.valueOf(it.dri.classNames?.toLowerCase() ?: "")
} catch (e: IllegalArgumentException) {
null
}
@@ -690,4 +691,7 @@ private class DokkaDescriptorVisitor(
Visibilities.PRIVATE -> KotlinVisibility.Private
else -> KotlinVisibility.Public
}
+
+ private fun ConstantsEnumValue.fullEnumEntryName() =
+ "${this.enumClassId.relativeClassName.asString()}.${this.enumEntryName.identifier}"
}
diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
index 658a86f2..5ff5a954 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
@@ -338,8 +338,10 @@ open class PageContentBuilder(
value: SourceSetDependent<T>,
platforms: Set<SourceSetData> = value.keys,
transform: (T) -> String
- ) = value.entries.filter { it.key in platforms }.forEach { (p, v) ->
- transform(v).takeIf { it.isNotBlank() }?.also { text(it, sourceSets = setOf(p)) }
+ ) = value.entries.filter { it.key in platforms }.mapNotNull { (p, v) ->
+ transform(v).takeIf { it.isNotBlank() }?.let { it to p }
+ }.groupBy({ it.first }) { it.second }.forEach {
+ text(it.key, sourceSets = it.value.toSet())
}
}
diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
index 0f8fc011..9c731528 100644
--- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka.base.translators.psi
+import com.intellij.icons.AllIcons.Nodes.Static
import com.intellij.lang.jvm.annotation.JvmAnnotationAttribute
import com.intellij.lang.jvm.JvmModifier
import com.intellij.lang.jvm.types.JvmReferenceType
@@ -275,18 +276,18 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator {
private fun PsiModifierListOwner.additionalExtras() = AdditionalModifiers(
listOfNotNull(
- ExtraModifiers.STATIC.takeIf { hasModifier(JvmModifier.STATIC) },
- ExtraModifiers.NATIVE.takeIf { hasModifier(JvmModifier.NATIVE) },
- ExtraModifiers.SYNCHRONIZED.takeIf { hasModifier(JvmModifier.SYNCHRONIZED) },
- ExtraModifiers.STRICTFP.takeIf { hasModifier(JvmModifier.STRICTFP) },
- ExtraModifiers.TRANSIENT.takeIf { hasModifier(JvmModifier.TRANSIENT) },
- ExtraModifiers.VOLATILE.takeIf { hasModifier(JvmModifier.VOLATILE) },
- ExtraModifiers.TRANSITIVE.takeIf { hasModifier(JvmModifier.TRANSITIVE) }
+ ExtraModifiers.JavaOnlyModifiers.Static.takeIf { hasModifier(JvmModifier.STATIC) },
+ ExtraModifiers.JavaOnlyModifiers.Native.takeIf { hasModifier(JvmModifier.NATIVE) },
+ ExtraModifiers.JavaOnlyModifiers.Synchronized.takeIf { hasModifier(JvmModifier.SYNCHRONIZED) },
+ ExtraModifiers.JavaOnlyModifiers.StrictFP.takeIf { hasModifier(JvmModifier.STRICTFP) },
+ ExtraModifiers.JavaOnlyModifiers.Transient.takeIf { hasModifier(JvmModifier.TRANSIENT) },
+ ExtraModifiers.JavaOnlyModifiers.Volatile.takeIf { hasModifier(JvmModifier.VOLATILE) },
+ ExtraModifiers.JavaOnlyModifiers.Transitive.takeIf { hasModifier(JvmModifier.TRANSITIVE) }
).toSet()
)
private fun AdditionalModifiers.toListOfAnnotations() = this.content.map {
- if (it.name != "STATIC")
+ if (it !is ExtraModifiers.JavaOnlyModifiers.Static)
Annotations.Annotation(DRI("kotlin.jvm", it.name.toLowerCase().capitalize()), emptyMap())
else
Annotations.Annotation(DRI("kotlin.jvm", "JvmStatic"), emptyMap())
diff --git a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
index c4640824..98f572b4 100644
--- a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
+++ b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
@@ -49,8 +49,9 @@ class ContentForAnnotationsTest : AbstractCoreTest() {
val page = module.children.single { it.name == "test" }
.children.single { it.name == "function" } as ContentPage
page.content.assertNode {
-
- header(1) { +"function" }
+ group {
+ header(1) { +"function" }
+ }
divergentGroup {
divergentInstance {
divergent {
diff --git a/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt b/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt
index 3f0edec3..68042fd4 100644
--- a/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt
+++ b/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt
@@ -40,8 +40,9 @@ class ContentForSignaturesTest : AbstractCoreTest() {
val page = module.children.single { it.name == "test" }
.children.single { it.name == "function" } as ContentPage
page.content.assertNode {
-
- header(1) { +"function" }
+ group {
+ header(1) { +"function" }
+ }
divergentGroup {
divergentInstance {
divergent {
@@ -78,7 +79,9 @@ class ContentForSignaturesTest : AbstractCoreTest() {
val page = module.children.single { it.name == "test" }
.children.single { it.name == "function" } as ContentPage
page.content.assertNode {
- header(1) { +"function" }
+ group {
+ header(1) { +"function" }
+ }
divergentGroup {
divergentInstance {
divergent {
@@ -115,7 +118,9 @@ class ContentForSignaturesTest : AbstractCoreTest() {
val page = module.children.single { it.name == "test" }
.children.single { it.name == "function" } as ContentPage
page.content.assertNode {
- header(1) { +"function" }
+ group {
+ header(1) { +"function" }
+ }
divergentGroup {
divergentInstance {
divergent {
@@ -152,8 +157,9 @@ class ContentForSignaturesTest : AbstractCoreTest() {
val page = module.children.single { it.name == "test" }
.children.single { it.name == "function" } as ContentPage
page.content.assertNode {
-
- header(1) { +"function" }
+ group {
+ header(1) { +"function" }
+ }
divergentGroup {
divergentInstance {
divergent {
@@ -190,7 +196,9 @@ class ContentForSignaturesTest : AbstractCoreTest() {
val page = module.children.single { it.name == "test" }
.children.single { it.name == "function" } as ContentPage
page.content.assertNode {
- header(1) { +"function" }
+ group {
+ header(1) { +"function" }
+ }
divergentGroup {
divergentInstance {
divergent {
@@ -227,7 +235,9 @@ class ContentForSignaturesTest : AbstractCoreTest() {
val page = module.children.single { it.name == "test" }
.children.single { it.name == "function" } as ContentPage
page.content.assertNode {
- header(1) { +"function" }
+ group {
+ header(1) { +"function" }
+ }
divergentGroup {
divergentInstance {
divergent {
diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt
index 405ec8b6..4ca34b00 100644
--- a/plugins/base/src/test/kotlin/model/ClassesTest.kt
+++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt
@@ -152,7 +152,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
visibility.values allEquals KotlinVisibility.Public
with(extra[AdditionalModifiers].assertNotNull("Extras")) {
content counts 1
- content.first() equals ExtraModifiers.DATA
+ content.first() equals ExtraModifiers.KotlinOnlyModifiers.Data
}
}
}
@@ -185,7 +185,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
with(content.first()) {
dri.classNames equals "Deprecated"
params.entries counts 1
-// params["message"].assertNotNull("message") equals "should no longer be used"
+ (params["message"].assertNotNull("message") as StringValue).value equals "\"should no longer be used\""
}
}
}
@@ -275,7 +275,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
with((this / "D").cast<DClass>()) {
with(extra[AdditionalModifiers].assertNotNull("AdditionalModifiers")) {
content counts 1
- content.first() equals ExtraModifiers.INNER
+ content.first() equals ExtraModifiers.KotlinOnlyModifiers.Inner
}
}
}
@@ -426,9 +426,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
with((this / "classes" / "Foo").cast<DClass>()) {
with(extra[Annotations]?.content?.firstOrNull().assertNotNull("annotations")) {
dri.toString() equals "kotlin/Suppress///PointingToDeclaration/"
-// with(params["names"].assertNotNull("param")) {
-// this equals "[\"abc\"]"
-// }
+ (params["names"].assertNotNull("param") as ArrayValue).value equals listOf(StringValue("\"abc\""))
}
}
}
diff --git a/plugins/base/src/test/kotlin/model/FunctionsTest.kt b/plugins/base/src/test/kotlin/model/FunctionsTest.kt
index 6cbb84f7..38f64df5 100644
--- a/plugins/base/src/test/kotlin/model/FunctionsTest.kt
+++ b/plugins/base/src/test/kotlin/model/FunctionsTest.kt
@@ -1,5 +1,6 @@
package model
+import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.*
import org.junit.jupiter.api.Test
import utils.AbstractModelTest
@@ -145,7 +146,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
with(content.first()) {
dri.classNames equals "Suppress"
params.entries counts 1
-// params["names"].assertNotNull("names") equals "[\"FOO\"]"
+ (params["names"].assertNotNull("param") as ArrayValue).value equals listOf(StringValue("\"FOO\""))
}
}
}
@@ -161,7 +162,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
) {
with((this / "function" / "f").cast<DFunction>()) {
extra[AdditionalModifiers]?.content counts 1
- extra[AdditionalModifiers]?.content exists ExtraModifiers.INLINE
+ extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.Inline
}
}
}
@@ -175,7 +176,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
) {
with((this / "function" / "f").cast<DFunction>()) {
extra[AdditionalModifiers]?.content counts 1
- extra[AdditionalModifiers]?.content exists ExtraModifiers.SUSPEND
+ extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.Suspend
}
}
}
@@ -189,8 +190,8 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
) {
with((this / "function" / "f").cast<DFunction>()) {
extra[AdditionalModifiers]?.content counts 2
- extra[AdditionalModifiers]?.content exists ExtraModifiers.SUSPEND
- extra[AdditionalModifiers]?.content exists ExtraModifiers.INLINE
+ extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.Suspend
+ extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.Inline
}
}
}
@@ -205,8 +206,8 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
with((this / "function" / "f").cast<DFunction>()) {
with(extra[AdditionalModifiers].assertNotNull("AdditionalModifiers")) {
content counts 2
- content exists ExtraModifiers.SUSPEND
- content exists ExtraModifiers.INLINE
+ content exists ExtraModifiers.KotlinOnlyModifiers.Suspend
+ content exists ExtraModifiers.KotlinOnlyModifiers.Inline
}
}
}
@@ -229,10 +230,18 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
content counts 3
with(content.map { it.dri.classNames to it }.toMap()) {
with(this["Target"].assertNotNull("Target")) {
-// params["allowedTargets"].assertNotNull("allowedTargets") equals "[AnnotationTarget.VALUE_PARAMETER]"
+ (params["allowedTargets"].assertNotNull("allowedTargets") as ArrayValue).value equals listOf(
+ EnumValue(
+ "AnnotationTarget.VALUE_PARAMETER",
+ DRI("kotlin.annotation", "AnnotationTarget.VALUE_PARAMETER")
+ )
+ )
}
with(this["Retention"].assertNotNull("Retention")) {
-// params["value"].assertNotNull("value") equals "(kotlin/annotation/AnnotationRetention, SOURCE)"
+ (params["value"].assertNotNull("value") as EnumValue) equals EnumValue(
+ "AnnotationRetention.SOURCE",
+ DRI("kotlin.annotation", "AnnotationRetention.SOURCE")
+ )
}
this["MustBeDocumented"].assertNotNull("MustBeDocumented").params.entries counts 0
}
@@ -260,7 +269,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
) {
with((this / "function" / "f" / "notInlined").cast<DParameter>()) {
extra[AdditionalModifiers]?.content counts 1
- extra[AdditionalModifiers]?.content exists ExtraModifiers.NOINLINE
+ extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.NoInline
}
}
}
@@ -291,10 +300,18 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
content counts 3
with(content.map { it.dri.classNames to it }.toMap()) {
with(this["Target"].assertNotNull("Target")) {
-// params["allowedTargets"].assertNotNull("allowedTargets") equals "[AnnotationTarget.VALUE_PARAMETER]"
+ (params["allowedTargets"].assertNotNull("allowedTargets") as ArrayValue).value equals listOf(
+ EnumValue(
+ "AnnotationTarget.VALUE_PARAMETER",
+ DRI("kotlin.annotation", "AnnotationTarget.VALUE_PARAMETER")
+ )
+ )
}
with(this["Retention"].assertNotNull("Retention")) {
-// params["value"].assertNotNull("value") equals "(kotlin/annotation/AnnotationRetention, SOURCE)"
+ (params["value"].assertNotNull("value") as EnumValue) equals EnumValue(
+ "AnnotationRetention.SOURCE",
+ DRI("kotlin.annotation", "AnnotationRetention.SOURCE")
+ )
}
this["MustBeDocumented"].assertNotNull("MustBeDocumented").params.entries counts 0
}
@@ -307,7 +324,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
with(content.first()) {
dri.classNames equals "Fancy"
params.entries counts 1
-// params["size"] equals "1"
+ (params["size"] as StringValue).value equals "1"
}
}
}
@@ -369,7 +386,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
with(content.first()) {
dri.classNames equals "SinceKotlin"
params.entries counts 1
-// params["version"].assertNotNull("version") equals "1.1"
+ (params["version"].assertNotNull("version") as StringValue).value equals "\"1.1\""
}
}
}
diff --git a/plugins/base/src/test/kotlin/model/JavaTest.kt b/plugins/base/src/test/kotlin/model/JavaTest.kt
index 07af7913..fd293b5c 100644
--- a/plugins/base/src/test/kotlin/model/JavaTest.kt
+++ b/plugins/base/src/test/kotlin/model/JavaTest.kt
@@ -1,9 +1,9 @@
package model
import org.jetbrains.dokka.base.transformers.documentables.InheritorsInfo
+import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.*
import org.junit.jupiter.api.Assertions.assertTrue
-import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import utils.AbstractModelTest
import utils.assertNotNull
@@ -297,7 +297,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
with((this / "java" / "C" / "foo").cast<DFunction>()) {
with(extra[AdditionalModifiers].assertNotNull("AdditionalModifiers")) {
content counts 1
- content.first() equals ExtraModifiers.STATIC
+ content.first() equals ExtraModifiers.JavaOnlyModifiers.Static
}
}
}
@@ -338,7 +338,11 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
with(extra[Annotations].assertNotNull("Annotations")) {
with(content.single()) {
dri.classNames equals "Target"
-// params["value"].assertNotNull("value") equals "{ElementType.FIELD, ElementType.TYPE, ElementType.METHOD}"
+ (params["value"].assertNotNull("value") as ArrayValue).value equals listOf(
+ EnumValue("ElementType.FIELD", DRI("java.lang.annotation", "ElementType")),
+ EnumValue("ElementType.TYPE", DRI("java.lang.annotation", "ElementType")),
+ EnumValue("ElementType.METHOD", DRI("java.lang.annotation", "ElementType"))
+ )
}
}
}
diff --git a/plugins/base/src/test/kotlin/model/PropertyTest.kt b/plugins/base/src/test/kotlin/model/PropertyTest.kt
index 7429257b..90a9d782 100644
--- a/plugins/base/src/test/kotlin/model/PropertyTest.kt
+++ b/plugins/base/src/test/kotlin/model/PropertyTest.kt
@@ -155,7 +155,7 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro
with(content.first()) {
dri.classNames equals "SinceKotlin"
params.entries counts 1
-// params["version"].assertNotNull("version") equals "1.1"
+ (params["version"].assertNotNull("version") as StringValue).value equals "\"1.1\""
}
}
}
diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt
index a1141832..ec119ebb 100644
--- a/plugins/base/src/test/kotlin/utils/contentUtils.kt
+++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt
@@ -139,26 +139,28 @@ fun ContentMatcherBuilder<*>.propertySignature(
header { +"Package test" }
}
group {
- skipAllNotMatching()
- header { +"Properties" }
- table {
- group {
- link { +name }
- platformHinted {
- group {
+ group {
+ skipAllNotMatching()
+ header { +"Properties" }
+ table {
+ group {
+ link { +name }
+ platformHinted {
group {
- annotations.entries.forEach {
- group {
- unwrapAnnotation(it)
+ group {
+ annotations.entries.forEach {
+ group {
+ unwrapAnnotation(it)
+ }
}
- }
- +("$visibility $modifier ${keywords.joinToString("") { "$it " }} $preposition")
- link { +name }
- if (type != null) {
- +(": ")
- group {
- link {
- +(type)
+ +("$visibility $modifier ${keywords.joinToString("") { "$it " }} $preposition")
+ link { +name }
+ if (type != null) {
+ +(": ")
+ group {
+ link {
+ +(type)
+ }
}
}
}