Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make current breadcrumb element not clickable and of default font col…
…or (#2588)
- Loading branch information
1 parent
f4d2bf4
commit 26dde5b
Showing
3 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
plugins/base/src/test/kotlin/renderers/html/BreadcrumbsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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") | ||
} |