Skip to content

Commit

Permalink
HTML: fix of redundant dot and related autotest (#2289)
Browse files Browse the repository at this point in the history
  • Loading branch information
dambatenne committed Jul 3, 2023
1 parent cbd9733 commit f20f2ff
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
Expand Up @@ -30,7 +30,7 @@ open class SearchbarDataInstaller(val context: DokkaContext) : PageTransformer {
val id: String
get() = with(driWithSourceSets.dri) {
listOfNotNull(
packageName,
packageName?.takeIf { it.isNotBlank() },
classNames,
callable?.name
).joinToString(".")
Expand Down
@@ -0,0 +1,46 @@
package renderers.html

import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.junit.Test
import org.junit.jupiter.api.Assertions
import utils.TestOutputWriterPlugin
import utils.pagesJson

class SearchbarDataInstallerTest: BaseAbstractTest() {

@Test
fun `should be displayed without leading dot`() {
val configuration = dokkaConfiguration {
moduleName = "Dokka Module"

sourceSets {
sourceSet {
sourceRoots = listOf("src/kotlin/Test.kt")
}
}
}

val source = """
|/src/kotlin/Test.kt
|
|class Test
|
""".trimIndent()

val writerPlugin = TestOutputWriterPlugin()
testInline(
source,
configuration,
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
val searchRecords = writerPlugin.writer.pagesJson("scripts/pages.json")

Assertions.assertEquals(
"Test",
searchRecords.find { record -> record.name == "class Test" }?.description ?: ""
)
}
}
}
}
5 changes: 5 additions & 0 deletions plugins/base/src/test/kotlin/utils/HtmlUtils.kt
@@ -1,11 +1,16 @@
package utils

import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import org.jetbrains.dokka.base.renderers.html.SearchRecord
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
import org.jsoup.select.Elements

internal fun TestOutputWriter.navigationHtml(): Element = contents.getValue("navigation.html").let { Jsoup.parse(it) }

internal fun TestOutputWriter.pagesJson(fileName: String): List<SearchRecord> = jacksonObjectMapper().readValue(contents.getValue(fileName))

internal fun Elements.selectNavigationGrid(): Element {
return this.select("div.overview").select("span.nav-link-grid").single()
}

0 comments on commit f20f2ff

Please sign in to comment.