aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt81
-rw-r--r--plugins/base/src/test/kotlin/content/annotations/DepredatedAndSinceKotlinTest.kt107
-rw-r--r--plugins/base/src/test/kotlin/enums/EnumsTest.kt16
3 files changed, 185 insertions, 19 deletions
diff --git a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
index ff4e3024..7add4119 100644
--- a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
+++ b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
@@ -4,11 +4,9 @@ import matchers.content.*
import org.jetbrains.dokka.pages.ContentPage
import org.jetbrains.dokka.pages.PackagePageNode
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
-import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import utils.ParamAttributes
import utils.bareSignature
-import utils.functionSignature
import utils.propertySignature
@@ -25,7 +23,7 @@ class ContentForAnnotationsTest : AbstractCoreTest() {
}
@Test
- fun `function`() {
+ fun `function with documented annotation`() {
testInline(
"""
|/src/main/kotlin/test/source.kt
@@ -73,9 +71,55 @@ class ContentForAnnotationsTest : AbstractCoreTest() {
}
}
- @Disabled
@Test
- fun `property`() {
+ fun `function with undocumented annotation`() {
+ testInline(
+ """
+ |/src/main/kotlin/test/source.kt
+ |package test
+ |
+ |@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION,
+ | AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD
+ |)
+ |@Retention(AnnotationRetention.SOURCE)
+ |annotation class Fancy
+ |
+ |@Fancy
+ |fun function(@Fancy abc: String): String {
+ | return "Hello, " + abc
+ |}
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.children.single { it.name == "test" }
+ .children.single { it.name == "function" } as ContentPage
+ page.content.assertNode {
+ group {
+ header(1) { +"function" }
+ }
+ divergentGroup {
+ divergentInstance {
+ divergent {
+ bareSignature(
+ emptyMap(),
+ "",
+ "",
+ emptySet(),
+ "function",
+ "String",
+ "abc" to ParamAttributes(emptyMap(), emptySet(), "String")
+ )
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ @Test
+ fun `property with undocumented annotation`() {
testInline(
"""
|/src/main/kotlin/test/source.kt
@@ -88,7 +132,30 @@ class ContentForAnnotationsTest : AbstractCoreTest() {
pagesTransformationStage = { module ->
val page = module.children.single { it.name == "test" } as PackagePageNode
page.content.assertNode {
- propertySignature(mapOf("Suppress" to setOf("names")), "", "", emptySet(), "val", "property", "Int")
+ propertySignature(emptyMap(), "", "", emptySet(), "val", "property", "Int")
+ }
+ }
+ }
+ }
+
+ @Test
+ fun `property with documented annotation`() {
+ testInline(
+ """
+ |/src/main/kotlin/test/source.kt
+ |package test
+ |
+ |@MustBeDocumented
+ |annotation class Fancy
+ |
+ |@Fancy
+ |val property: Int = 6
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.children.single { it.name == "test" } as PackagePageNode
+ page.content.assertNode {
+ propertySignature(mapOf("Fancy" to emptySet()), "", "", emptySet(), "val", "property", "Int")
}
}
}
@@ -96,7 +163,7 @@ class ContentForAnnotationsTest : AbstractCoreTest() {
@Test
- fun `rich annotation`() {
+ fun `rich documented annotation`() {
testInline(
"""
|/src/main/kotlin/test/source.kt
diff --git a/plugins/base/src/test/kotlin/content/annotations/DepredatedAndSinceKotlinTest.kt b/plugins/base/src/test/kotlin/content/annotations/DepredatedAndSinceKotlinTest.kt
new file mode 100644
index 00000000..b5150ed1
--- /dev/null
+++ b/plugins/base/src/test/kotlin/content/annotations/DepredatedAndSinceKotlinTest.kt
@@ -0,0 +1,107 @@
+package content.annotations
+
+
+import matchers.content.*
+import org.jetbrains.dokka.pages.ContentPage
+import org.jetbrains.dokka.pages.PackagePageNode
+import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
+import org.junit.jupiter.api.Test
+import utils.ParamAttributes
+import utils.bareSignature
+import utils.propertySignature
+
+
+class DepredatedAndSinceKotlinTest : AbstractCoreTest() {
+
+ private val testConfiguration = dokkaConfiguration {
+ passes {
+ pass {
+ sourceRoots = listOf("src/")
+ analysisPlatform = "jvm"
+ targets = listOf("jvm")
+ }
+ }
+ }
+
+ @Test
+ fun `function with deprecated annotation`() {
+ testInline(
+ """
+ |/src/main/kotlin/test/source.kt
+ |package test
+ |
+ |@Deprecated("And some things that should not have been forgotten were lost. History became legend. Legend became myth.")
+ |fun ring(abc: String): String {
+ | return "My precious " + abc
+ |}
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.children.single { it.name == "test" }
+ .children.single { it.name == "ring" } as ContentPage
+ page.content.assertNode {
+ group {
+ header(1) { +"ring" }
+ }
+ divergentGroup {
+ divergentInstance {
+ divergent {
+ bareSignature(
+ emptyMap(),
+ "",
+ "",
+ emptySet(),
+ "ring",
+ "String",
+ "abc" to ParamAttributes(emptyMap(), emptySet(), "String")
+ )
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ @Test
+ fun `function with since kotlin annotation`() {
+ testInline(
+ """
+ |/src/main/kotlin/test/source.kt
+ |package test
+ |
+ |@SinceKotlin("1.3")
+ |fun ring(abc: String): String {
+ | return "My precious " + abc
+ |}
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val page = module.children.single { it.name == "test" }
+ .children.single { it.name == "ring" } as ContentPage
+ page.content.assertNode {
+ group {
+ header(1) { +"ring" }
+ }
+ divergentGroup {
+ divergentInstance {
+ divergent {
+ bareSignature(
+ emptyMap(),
+ "",
+ "",
+ emptySet(),
+ "ring",
+ "String",
+ "abc" to ParamAttributes(emptyMap(), emptySet(), "String")
+ )
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt
index 7feba710..695a8fd2 100644
--- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt
+++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt
@@ -6,9 +6,7 @@ import org.jetbrains.dokka.model.DEnum
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
import org.junit.jupiter.api.Assertions.*
-import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
-import utils.unwrapAnnotation
class EnumsTest : AbstractCoreTest() {
@@ -177,7 +175,6 @@ class EnumsTest : AbstractCoreTest() {
}
}
- @Disabled
@Test
fun enumWithAnnotationsOnEntries(){
val configuration = dokkaConfiguration {
@@ -197,7 +194,7 @@ class EnumsTest : AbstractCoreTest() {
| /**
| Sample docs for E1
| **/
- | @SinceKotlin("1.3")
+ | @SinceKotlin("1.3") // This annotation is transparent due to lack of @MustBeDocumented annotation
| E1
|}
""".trimMargin(),
@@ -216,14 +213,9 @@ class EnumsTest : AbstractCoreTest() {
}
}
group {
- mapOf("SinceKotlin" to setOf("version")).entries.forEach {
- group {
- group {
- unwrapAnnotation(it)
- }
- link { +"E1" }
- +"()"
- }
+ group {
+ link { +"E1" }
+ +"()"
}
}
}