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
|
package renderers.html
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jsoup.nodes.Element
import org.junit.jupiter.api.Test
import signatures.renderedContent
import utils.*
class BreadcrumbsTest : BaseAbstractTest() {
private val configuration = dokkaConfiguration {
sourceSets {
sourceSet {
sourceRoots = listOf("src/")
}
}
}
@Test
fun `should add breadcrumbs with current element`() {
val writerPlugin = TestOutputWriterPlugin()
testInline(
"""
|/src/main/kotlin/basic/TestClass.kt
|package testpackage
|
|class TestClass {
| fun foo() {}
|}
""".trimMargin(),
configuration,
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/testpackage/-test-class/foo.html").selectBreadcrumbs().match(
link("root"),
delimiter(),
link("testpackage"),
delimiter(),
link("TestClass"),
delimiter(),
current("foo"),
ignoreSpanWithTokenStyle = true
)
}
}
}
@Test
fun `should mark only one element as current even if more elements have the same name`() {
val writerPlugin = TestOutputWriterPlugin()
testInline(
"""
|/src/main/kotlin/basic/TestClass.kt
|package testpackage
|
|class testname {
| val testname: String = ""
|}
""".trimMargin(),
configuration,
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/testpackage/testname/testname.html").selectBreadcrumbs().match(
link("root"),
delimiter(),
link("testpackage"),
delimiter(),
link("testname"),
delimiter(),
current("testname"),
ignoreSpanWithTokenStyle = true
)
}
}
}
private fun Element.selectBreadcrumbs() = this.select("div.breadcrumbs").single()
private fun link(text: String): Tag = A(text)
private fun delimiter(): Tag = Span().withClasses("delimiter")
private fun current(text: String): Tag = Span(text).withClasses("current")
}
|