aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/base-test-utils/src/main/kotlin/renderers/TestPage.kt28
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt13
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt22
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/GroupWrappingTest.kt8
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt16
5 files changed, 45 insertions, 42 deletions
diff --git a/plugins/base/base-test-utils/src/main/kotlin/renderers/TestPage.kt b/plugins/base/base-test-utils/src/main/kotlin/renderers/TestPage.kt
index 0dae8ce6..09ea6083 100644
--- a/plugins/base/base-test-utils/src/main/kotlin/renderers/TestPage.kt
+++ b/plugins/base/base-test-utils/src/main/kotlin/renderers/TestPage.kt
@@ -11,16 +11,8 @@ import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.base.signatures.KotlinSignatureProvider
import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter
-class TestPage(callback: PageContentBuilder.DocumentableContentBuilder.() -> Unit) : RootPageNode(), ContentPage {
- override val dri: Set<DRI> = setOf(DRI.topLevel)
- override val documentable: Documentable? = null
- override val embeddedResources: List<String> = emptyList()
- override val name: String
- get() = "testPage"
- override val children: List<PageNode>
- get() = emptyList()
-
- override val content: ContentNode = PageContentBuilder(
+fun testPage(callback: PageContentBuilder.DocumentableContentBuilder.() -> Unit): RawTestPage {
+ val content = PageContentBuilder(
EmptyCommentConverter,
KotlinSignatureProvider(EmptyCommentConverter, DokkaConsoleLogger),
DokkaConsoleLogger
@@ -30,15 +22,27 @@ class TestPage(callback: PageContentBuilder.DocumentableContentBuilder.() -> Uni
block = callback
)
+ return RawTestPage(content)
+}
+
+class RawTestPage(
+ override val content: ContentNode,
+ override val name: String = "testPage",
+ override val dri: Set<DRI> = setOf(DRI.topLevel),
+ override val documentable: Documentable? = null,
+ override val embeddedResources: List<String> = emptyList(),
+ override val children: List<PageNode> = emptyList(),
+): RootPageNode(), ContentPage {
override fun modified(
name: String,
content: ContentNode,
dri: Set<DRI>,
embeddedResources: List<String>,
children: List<PageNode>
- ) = this
+ ): ContentPage = this
+
+ override fun modified(name: String, children: List<PageNode>): RootPageNode = this
- override fun modified(name: String, children: List<PageNode>) = this
}
internal object EmptyCommentConverter : CommentsToContentConverter {
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index e10672a6..ddcbc7e9 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -346,15 +346,14 @@ open class HtmlRenderer(
override fun FlowContent.buildResource(
node: ContentEmbeddedResource,
pageContext: ContentPage
- ) { // TODO: extension point there
- return if (node.isImage()) {
+ ) = // TODO: extension point there
+ if (node.isImage()) {
//TODO: add imgAttrs parsing
val imgAttrs = node.extra.allOfType<SimpleAttr>().joinAttr()
img(src = node.address, alt = node.altText)
} else {
println("Unrecognized resource type: $node")
}
- }
private fun FlowContent.buildRow(
node: ContentGroup,
@@ -393,9 +392,9 @@ open class HtmlRenderer(
}
it.filter { it !is ContentLink }.takeIf { it.isNotEmpty() }?.let {
- if(pageContext is ModulePage || pageContext is MultimoduleRootPage){
+ if (pageContext is ModulePage || pageContext is MultimoduleRootPage) {
it.forEach {
- span(classes = if(it.dci.kind == ContentKind.Comment) "brief-comment" else "") {
+ span(classes = if (it.dci.kind == ContentKind.Comment) "brief-comment" else "") {
it.build(this, pageContext, sourceSetRestriction)
}
}
@@ -522,7 +521,7 @@ open class HtmlRenderer(
override fun FlowContent.buildNavigation(page: PageNode) =
div(classes = "breadcrumbs") {
val path = locationProvider.ancestors(page).filterNot { it is RendererSpecificPage }.asReversed()
- if(path.isNotEmpty()){
+ if (path.isNotEmpty()) {
buildNavigationElement(path.first(), page)
path.drop(1).forEach { node ->
text("/")
@@ -691,7 +690,7 @@ open class HtmlRenderer(
div {
id = "logo"
}
- if(page !is MultimoduleRootPage) {
+ if (page !is MultimoduleRootPage) {
div {
id = "paneSearch"
}
diff --git a/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt b/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt
index b4de5aed..ad0d421e 100644
--- a/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt
+++ b/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt
@@ -4,7 +4,7 @@ import org.jetbrains.dokka.base.renderers.html.HtmlRenderer
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.pages.ContentDivergentGroup
import org.junit.jupiter.api.Test
-import renderers.TestPage
+import renderers.testPage
import utils.Div
import utils.Span
import utils.match
@@ -13,7 +13,7 @@ class DivergentTest : HtmlRenderingOnlyTestBase() {
@Test
fun simpleWrappingCase() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(js)) {
divergent {
@@ -28,7 +28,7 @@ class DivergentTest : HtmlRenderingOnlyTestBase() {
@Test
fun noPlatformHintCase() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test"), implicitlySourceSetHinted = false) {
instance(setOf(DRI("test", "Test")), setOf(js)) {
divergent {
@@ -43,7 +43,7 @@ class DivergentTest : HtmlRenderingOnlyTestBase() {
@Test
fun divergentBetweenSourceSets() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(js)) {
divergent {
@@ -69,7 +69,7 @@ class DivergentTest : HtmlRenderingOnlyTestBase() {
@Test
fun divergentInOneSourceSet() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(js)) {
divergent {
@@ -95,7 +95,7 @@ class DivergentTest : HtmlRenderingOnlyTestBase() {
@Test
fun divergentInAndBetweenSourceSets() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(native)) {
divergent {
@@ -131,7 +131,7 @@ class DivergentTest : HtmlRenderingOnlyTestBase() {
@Test
fun divergentInAndBetweenSourceSetsWithGrouping() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(native)) {
divergent {
@@ -184,7 +184,7 @@ class DivergentTest : HtmlRenderingOnlyTestBase() {
@Test
fun divergentSameBefore() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(native)) {
before {
@@ -219,7 +219,7 @@ class DivergentTest : HtmlRenderingOnlyTestBase() {
@Test
fun divergentSameAfter() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(native)) {
divergent {
@@ -251,7 +251,7 @@ class DivergentTest : HtmlRenderingOnlyTestBase() {
@Test
fun divergentGroupedByBeforeAndAfter() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(native)) {
before {
@@ -290,7 +290,7 @@ class DivergentTest : HtmlRenderingOnlyTestBase() {
@Test
fun divergentDifferentBeforeAndAfter() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(native)) {
before {
diff --git a/plugins/base/src/test/kotlin/renderers/html/GroupWrappingTest.kt b/plugins/base/src/test/kotlin/renderers/html/GroupWrappingTest.kt
index c0c03998..244163ec 100644
--- a/plugins/base/src/test/kotlin/renderers/html/GroupWrappingTest.kt
+++ b/plugins/base/src/test/kotlin/renderers/html/GroupWrappingTest.kt
@@ -12,7 +12,7 @@ class GroupWrappingTest : HtmlRenderingOnlyTestBase() {
@Test
fun notWrapped() {
- val page = TestPage {
+ val page = testPage {
group {
text("a")
text("b")
@@ -27,7 +27,7 @@ class GroupWrappingTest : HtmlRenderingOnlyTestBase() {
@Test
fun paragraphWrapped() {
- val page = TestPage {
+ val page = testPage {
group(styles = setOf(TextStyle.Paragraph)) {
text("a")
text("b")
@@ -42,7 +42,7 @@ class GroupWrappingTest : HtmlRenderingOnlyTestBase() {
@Test
fun blockWrapped() {
- val page = TestPage {
+ val page = testPage {
group(styles = setOf(TextStyle.Block)) {
text("a")
text("b")
@@ -57,7 +57,7 @@ class GroupWrappingTest : HtmlRenderingOnlyTestBase() {
@Test
fun nested() {
- val page = TestPage {
+ val page = testPage {
group(styles = setOf(TextStyle.Block)) {
text("a")
group(styles = setOf(TextStyle.Block)) {
diff --git a/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt b/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt
index 6be3839d..633a59a7 100644
--- a/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt
+++ b/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt
@@ -4,7 +4,7 @@ import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.base.renderers.html.HtmlRenderer
import org.jetbrains.dokka.pages.TextStyle
import org.junit.jupiter.api.Test
-import renderers.TestPage
+import renderers.testPage
import testApi.testRunner.defaultSourceSet
import utils.Div
import utils.match
@@ -33,7 +33,7 @@ class SourceSetDependentHintTest : HtmlRenderingOnlyTestBase() {
@Test
fun platformIndependentCase() {
- val page = TestPage {
+ val page = testPage {
sourceSetDependentHint(sourceSets = setOf(pl1, pl2, pl3), styles = setOf(TextStyle.Block)) {
text("a")
text("b")
@@ -47,7 +47,7 @@ class SourceSetDependentHintTest : HtmlRenderingOnlyTestBase() {
@Test
fun completelyDivergentCase() {
- val page = TestPage {
+ val page = testPage {
sourceSetDependentHint(sourceSets = setOf(pl1, pl2, pl3), styles = setOf(TextStyle.Block)) {
text("a", sourceSets = setOf(pl1))
text("b", sourceSets = setOf(pl2))
@@ -61,7 +61,7 @@ class SourceSetDependentHintTest : HtmlRenderingOnlyTestBase() {
@Test
fun overlappingCase() {
- val page = TestPage {
+ val page = testPage {
sourceSetDependentHint(sourceSets = setOf(pl1, pl2), styles = setOf(TextStyle.Block)) {
text("a", sourceSets = setOf(pl1))
text("b", sourceSets = setOf(pl1, pl2))
@@ -75,7 +75,7 @@ class SourceSetDependentHintTest : HtmlRenderingOnlyTestBase() {
@Test
fun caseThatCanBeSimplified() {
- val page = TestPage {
+ val page = testPage {
sourceSetDependentHint(sourceSets = setOf(pl1, pl2), styles = setOf(TextStyle.Block)) {
text("a", sourceSets = setOf(pl1, pl2))
text("b", sourceSets = setOf(pl1))
@@ -89,7 +89,7 @@ class SourceSetDependentHintTest : HtmlRenderingOnlyTestBase() {
@Test
fun caseWithGroupBreakingSimplification() {
- val page = TestPage {
+ val page = testPage {
sourceSetDependentHint(sourceSets = setOf(pl1, pl2), styles = setOf(TextStyle.Block)) {
group(styles = setOf(TextStyle.Block)) {
text("a", sourceSets = setOf(pl1, pl2))
@@ -105,7 +105,7 @@ class SourceSetDependentHintTest : HtmlRenderingOnlyTestBase() {
@Test
fun caseWithGroupNotBreakingSimplification() {
- val page = TestPage {
+ val page = testPage {
sourceSetDependentHint(sourceSets = setOf(pl1, pl2)) {
group {
text("a", sourceSets = setOf(pl1, pl2))
@@ -121,7 +121,7 @@ class SourceSetDependentHintTest : HtmlRenderingOnlyTestBase() {
@Test
fun partiallyUnifiedCase() {
- val page = TestPage {
+ val page = testPage {
sourceSetDependentHint(sourceSets = setOf(pl1, pl2, pl3), styles = setOf(TextStyle.Block)) {
text("a", sourceSets = setOf(pl1))
text("a", sourceSets = setOf(pl2))