1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
package content
import junit.framework.Assert.assertEquals
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jetbrains.dokka.model.doc.*
import org.junit.jupiter.api.Test
import kotlin.test.assertTrue
class ContentInDescriptionTest : BaseAbstractTest() {
private val configuration = dokkaConfiguration {
sourceSets {
sourceSet {
sourceRoots = listOf("src/")
analysisPlatform = "jvm"
classpath += jvmStdlibPath!!
}
}
}
val expectedDescription = Description(
CustomDocTag(
listOf(
P(
listOf(
Text("Hello World! Docs with period issue, e.g."),
Text(String(Character.toChars(160)), params = mapOf("content-type" to "html")),
Text("this.")
)
)
),
params = emptyMap(),
name = "MARKDOWN_FILE"
)
)
@Test
fun `nbsp is handled as code in kotlin`() {
testInline(
"""
|/src/main/kotlin/sample/ParentKt.kt
|package sample;
|/**
| * Hello World! Docs with period issue, e.g. this.
| */
|public class ParentKt {
|}
""".trimIndent(), configuration
) {
documentablesMergingStage = {
val classlike = it.packages.flatMap { it.classlikes }.find { it.name == "ParentKt" }
assertTrue(classlike != null)
assertEquals(expectedDescription, classlike.documentation.values.first().children.first())
}
}
}
@Test
fun `nbsp is handled as code in java`() {
testInline(
"""
|/src/main/kotlin/sample/Parent.java
|package sample;
|/**
| * Hello World! Docs with period issue, e.g. this.
| */
|public class Parent {
|}
""".trimIndent(), configuration
) {
documentablesMergingStage = {
val classlike = it.packages.flatMap { it.classlikes }.find { it.name == "Parent" }
assertTrue(classlike != null)
assertEquals(expectedDescription, classlike.documentation.values.first().children.first())
}
}
}
@Test
fun `same documentation in java and kotlin when nbsp is present`() {
testInline(
"""
|/src/main/kotlin/sample/Parent.java
|package sample;
|/**
| * Hello World! Docs with period issue, e.g. this.
| */
|public class Parent {
|}
|
|/src/main/kotlin/sample/ParentKt.kt
|package sample;
|/**
| * Hello World! Docs with period issue, e.g. this.
| */
|public class ParentKt {
|}
""".trimIndent(),
configuration
) {
documentablesMergingStage = { module ->
val java = module.packages.flatMap { it.classlikes }.first { it.name == "Parent" }
val kotlin = module.packages.flatMap { it.classlikes }.first { it.name == "ParentKt" }
assertEquals(java.documentation.values.first(), kotlin.documentation.values.first())
}
}
}
@Test
fun `text surrounded by angle brackets is not removed`() {
testInline(
"""
|/src/main/kotlin/sample/Foo.kt
|package sample
|/**
| * My example `CodeInline<Bar>`
| * ```
| * CodeBlock<Bar>
| * ```
| */
|class Foo {
|}
""".trimIndent(),
configuration
) {
documentablesMergingStage = { module ->
val cls = module.packages.flatMap { it.classlikes }.first { it.name == "Foo" }
val documentation = cls.documentation.values.first()
val docTags = documentation.children.single().root.children
assertEquals("CodeInline<Bar>", ((docTags[0].children[1] as CodeInline).children.first() as Text).body)
assertEquals("CodeBlock<Bar>", ((docTags[1] as CodeBlock).children.first() as Text).body)
}
}
}
}
|