aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt2
-rw-r--r--plugins/base/src/test/kotlin/signatures/SignatureTest.kt85
2 files changed, 71 insertions, 16 deletions
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index 37e0ea83..8341fabd 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -85,7 +85,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
?: emptySet()),
sourceSets = setOf(sourceSet)
) {
- text("actual typealias ")
+ text("typealias ")
link(c.name.orEmpty(), c.dri)
text(" = ")
signatureForProjection(aliasedType)
diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
index 9f2ae435..04d4f88c 100644
--- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
@@ -1,7 +1,9 @@
package signatures
+import org.jetbrains.dokka.DokkaSourceSetID
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
import org.jsoup.Jsoup
+import org.jsoup.nodes.Element
import org.junit.jupiter.api.Test
import utils.*
@@ -35,7 +37,7 @@ class SignatureTest : AbstractCoreTest() {
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
- writerPlugin.writer.renderedContent("root/example/simple-fun.html").match(
+ writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
"fun ", A("simpleFun"), "(): ", A("String"), Span()
)
}
@@ -62,7 +64,7 @@ class SignatureTest : AbstractCoreTest() {
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
- writerPlugin.writer.renderedContent("root/example/simple-fun.html").match(
+ writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
"open fun ", A("simpleFun"), "(): ", A("String"), Span()
)
}
@@ -89,7 +91,7 @@ class SignatureTest : AbstractCoreTest() {
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
- writerPlugin.writer.renderedContent("root/example/simple-fun.html").match(
+ writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
"open suspend fun ", A("simpleFun"), "(): ", A("String"), Span()
)
}
@@ -116,7 +118,7 @@ class SignatureTest : AbstractCoreTest() {
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
- writerPlugin.writer.renderedContent("root/example/simple-fun.html").match(
+ writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
"fun ", A("simpleFun"), "(a: ", A("Int"),
", b: ", A("Boolean"), ", c: ", A("Any"),
"): ", A("String"), Span()
@@ -145,7 +147,7 @@ class SignatureTest : AbstractCoreTest() {
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
- writerPlugin.writer.renderedContent("root/example/simple-fun.html").match(
+ writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
"fun ", A("simpleFun"), "(a: (", A("Int"),
") -> ", A("String"), "): ", A("String"), Span()
)
@@ -173,7 +175,7 @@ class SignatureTest : AbstractCoreTest() {
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
- writerPlugin.writer.renderedContent("root/example/simple-fun.html").match(
+ writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
"fun <", A("T"), " : ", A("Any"), "?> ", A("simpleFun"), "(): ",
A("T"), Span()
)
@@ -201,7 +203,7 @@ class SignatureTest : AbstractCoreTest() {
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
- writerPlugin.writer.renderedContent("root/example/simple-fun.html").match(
+ writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
"fun <", A("T"), " : ", A("String"), "> ", A("simpleFun"),
"(): ", A("T"), Span()
)
@@ -229,7 +231,7 @@ class SignatureTest : AbstractCoreTest() {
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
- writerPlugin.writer.renderedContent("root/example/simple-fun.html").match(
+ writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
"inline suspend fun <", A("T"), " : ", A("String"), "> ", A("simpleFun"),
"(a: ", A("Int"), ", b: ", A("String"), "): ", A("T"), Span()
)
@@ -268,7 +270,7 @@ class SignatureTest : AbstractCoreTest() {
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
- writerPlugin.writer.renderedContent("root/example/simple-fun.html").match(
+ writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
Div(
Div("@", A("Marking"), "()")
),
@@ -315,6 +317,7 @@ class SignatureTest : AbstractCoreTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/simple-fun.html")
+ .firstSignature()
.match(
Div(
Div("@", A("Marking"), "(", Span("msg = ", Span("\"Nenya\"")), Wbr, ")"),
@@ -358,12 +361,15 @@ class SignatureTest : AbstractCoreTest() {
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
- writerPlugin.writer.renderedContent("root/example/simple-fun.html").match(
+ writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match(
Div(
- Div("@", A("Marking"), "(", Span("msg = [",
- Span(Span("\"Nenya\""), ", "), Wbr,
- Span(Span("\"Vilya\""), ", "), Wbr,
- Span(Span("\"Narya\"")), Wbr, "]"), Wbr, ")"
+ Div(
+ "@", A("Marking"), "(", Span(
+ "msg = [",
+ Span(Span("\"Nenya\""), ", "), Wbr,
+ Span(Span("\"Vilya\""), ", "), Wbr,
+ Span(Span("\"Narya\"")), Wbr, "]"
+ ), Wbr, ")"
)
),
"fun ", A("simpleFun"),
@@ -373,7 +379,56 @@ class SignatureTest : AbstractCoreTest() {
}
}
+ @Test
+ fun `type with an actual typealias`() {
+
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ moduleName = "test"
+ name = "common"
+ sourceRoots = listOf("src/main/kotlin/common/Test.kt")
+ }
+ sourceSet {
+ moduleName = "test"
+ name = "jvm"
+ dependentSourceSets = setOf(DokkaSourceSetID("test", "common"))
+ sourceRoots = listOf("src/main/kotlin/jvm/Test.kt")
+ }
+ }
+ }
+
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ """
+ |/src/main/kotlin/common/Test.kt
+ |package example
+ |
+ |expect class Foo
+ |
+ |/src/main/kotlin/jvm/Test.kt
+ |package example
+ |
+ |class Bar
+ |actual typealias Foo = Bar
+ |
+ """.trimMargin(),
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ writerPlugin.writer.renderedContent("test/example/-foo/index.html").signature().toList()[1].match(
+ "typealias ", A("Foo"), " = ", A("Bar"), Span()
+ )
+ }
+ }
+ }
+
private fun TestOutputWriter.renderedContent(path: String = "root/example.html") =
contents.getValue(path).let { Jsoup.parse(it) }.select("#content")
- .single().select("div.symbol div.monospace").first()
+ .single()
+
+ private fun Element.signature() = select("div.symbol.monospace")
+ private fun Element.firstSignature() = signature().first()
} \ No newline at end of file