From e99be615ce7c2c2b5c3ee5e3f8941c41c1e7a944 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Fri, 31 Jan 2020 00:37:29 +0100 Subject: Bump Gradle version, migrate to Kotlin DSL, refactor publishing --- plugins/build.gradle.kts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 plugins/build.gradle.kts (limited to 'plugins/build.gradle.kts') diff --git a/plugins/build.gradle.kts b/plugins/build.gradle.kts new file mode 100644 index 00000000..5f2f6dcb --- /dev/null +++ b/plugins/build.gradle.kts @@ -0,0 +1,11 @@ +subprojects { + apply { + plugin("maven-publish") + } + + dependencies { + compileOnly(project(":core")) + compileOnly(kotlin("stdlib-jdk8")) + testImplementation(project(":testApi")) + } +} \ No newline at end of file -- cgit From e730b82c4db6306a5b9e552d8a4c6578b0c1e01a Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Thu, 13 Feb 2020 12:52:39 +0100 Subject: Update packaging structure, fix testAPI publication, simplify dependencies handling in plugins Fixes #627 This commit removes repackaging `dokka-core` with all its dependencies by creating a publication for those dependencies. Moreover it moves `kotlinx-markdown` dependency to `coreDependencies` as this library is only present in Kotlin Bintray repository. TestAPI now publishes correctly --- core/build.gradle.kts | 18 ++++-------------- coreDependencies/build.gradle.kts | 17 +++++++++++++++++ plugins/build.gradle.kts | 4 ++++ plugins/kotlin-as-java/build.gradle.kts | 9 --------- testApi/build.gradle.kts | 4 ++-- 5 files changed, 27 insertions(+), 25 deletions(-) (limited to 'plugins/build.gradle.kts') diff --git a/core/build.gradle.kts b/core/build.gradle.kts index e70791f3..c8cae2d6 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -7,30 +7,20 @@ plugins { } dependencies { - implementation(project(":coreDependencies", configuration = "shadow")) + api(project(":coreDependencies", configuration = "shadow")) val kotlin_version: String by project - implementation("org.jetbrains.kotlin:kotlin-compiler:$kotlin_version") - implementation("org.jetbrains.kotlin:kotlin-script-runtime:$kotlin_version") + api("org.jetbrains.kotlin:kotlin-compiler:$kotlin_version") + implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.10") implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version") implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version") implementation("org.jsoup:jsoup:1.12.1") implementation("com.google.code.gson:gson:2.8.5") - implementation("org.jetbrains:markdown:0.1.41") - implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.10") testImplementation(project(":testApi")) testImplementation("junit:junit:4.13") } -tasks { - shadowJar { - val dokka_version: String by project - archiveFileName.set("dokka-core-$dokka_version.jar") - archiveClassifier.set("") - } -} - val sourceJar by tasks.registering(Jar::class) { archiveClassifier.set("sources") from(sourceSets["main"].allSource) @@ -40,7 +30,7 @@ publishing { publications { register("dokkaCore") { artifactId = "dokka-core" - project.shadow.component(this) + from(components["java"]) artifact(sourceJar.get()) } } diff --git a/coreDependencies/build.gradle.kts b/coreDependencies/build.gradle.kts index 514c7ae1..73b04554 100644 --- a/coreDependencies/build.gradle.kts +++ b/coreDependencies/build.gradle.kts @@ -1,6 +1,9 @@ +import org.jetbrains.configureBintrayPublication + plugins { id("com.github.johnrengelman.shadow") `maven-publish` + id("com.jfrog.bintray") } val intellijCore: Configuration by configurations.creating @@ -24,6 +27,9 @@ dependencies { //TODO: parametrize ij version after 1.3.70 isTransitive = false } + implementation("org.jetbrains:markdown:0.1.41") { + because("it's published only on bintray") + } } tasks { @@ -41,3 +47,14 @@ tasks { exclude("src/**") } } + +publishing { + publications { + register("dokkaCoreDependencies") { + artifactId = "dokka-core-dependencies" + project.shadow.component(this) + } + } +} + +configureBintrayPublication("dokkaCoreDependencies") \ No newline at end of file diff --git a/plugins/build.gradle.kts b/plugins/build.gradle.kts index 5f2f6dcb..e29f1355 100644 --- a/plugins/build.gradle.kts +++ b/plugins/build.gradle.kts @@ -6,6 +6,10 @@ subprojects { dependencies { compileOnly(project(":core")) compileOnly(kotlin("stdlib-jdk8")) +// compileOnly(project(":coreDependencies", configuration = "shadow")) // uncomment if IntelliJ does not recognize pacakges from IntelliJ + testImplementation(project(":testApi")) + testImplementation(kotlin("stdlib-jdk8")) + testImplementation("junit:junit:4.13") } } \ No newline at end of file diff --git a/plugins/kotlin-as-java/build.gradle.kts b/plugins/kotlin-as-java/build.gradle.kts index 5d04060f..3b281d53 100644 --- a/plugins/kotlin-as-java/build.gradle.kts +++ b/plugins/kotlin-as-java/build.gradle.kts @@ -5,13 +5,4 @@ publishing { from(components["java"]) } } -} - -dependencies { - implementation(kotlin("stdlib-jdk8")) - compileOnly(project(":coreDependencies", configuration = "shadow")) - testImplementation(project(":core")) - testImplementation(project(":coreDependencies", configuration = "shadow")) - testImplementation(project(":testApi")) - testImplementation("junit:junit:4.13") } \ No newline at end of file diff --git a/testApi/build.gradle.kts b/testApi/build.gradle.kts index db861b90..43c984b5 100644 --- a/testApi/build.gradle.kts +++ b/testApi/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } dependencies { - implementation(project(":core")) + api(project(":core")) implementation("junit:junit:4.13") // TODO: remove dependency to junit implementation(kotlin("stdlib")) } @@ -20,7 +20,7 @@ publishing { publications { register("dokkaTestAPI") { artifactId = "dokka-test-api" - components["java"] + from(components["java"]) artifact(sourceJar.get()) } } -- cgit From 46b4bbb68ce1285a1aea700cc0d0000c6b7ed97b Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Wed, 12 Feb 2020 18:05:24 +0100 Subject: Moves all core tests to base plugin --- core/src/test/kotlin/basic/DRITest.kt | 168 ---- core/src/test/kotlin/basic/DokkaBasicTests.kt | 41 - core/src/test/kotlin/enums/EnumsTest.kt | 45 - core/src/test/kotlin/markdown/KDocTest.kt | 48 -- core/src/test/kotlin/markdown/ParserTest.kt | 940 --------------------- .../kotlin/multiplatform/BasicMultiplatformTest.kt | 55 -- .../test/kotlin/pageMerger/PageNodeMergerTest.kt | 127 --- .../commonMain/kotlin/Clock.kt | 15 - .../commonMain/kotlin/House.kt | 24 - .../basicMultiplatformTest/jsMain/kotlin/Clock.kt | 21 - .../jvmAndJsSecondCommonMain/kotlin/Greeter.kt | 10 - .../jvmMain/kotlin/example/Clock.kt | 34 - .../jvmMain/kotlin/example/ClockDays.kt | 15 - .../jvmMain/kotlin/example/ParticularClock.kt | 32 - plugins/base/src/test/kotlin/basic/DRITest.kt | 168 ++++ .../base/src/test/kotlin/basic/DokkaBasicTests.kt | 41 + plugins/base/src/test/kotlin/enums/EnumsTest.kt | 45 + plugins/base/src/test/kotlin/markdown/KDocTest.kt | 48 ++ .../base/src/test/kotlin/markdown/ParserTest.kt | 940 +++++++++++++++++++++ .../kotlin/multiplatform/BasicMultiplatformTest.kt | 55 ++ .../test/kotlin/pageMerger/PageNodeMergerTest.kt | 127 +++ .../commonMain/kotlin/Clock.kt | 15 + .../commonMain/kotlin/House.kt | 24 + .../basicMultiplatformTest/jsMain/kotlin/Clock.kt | 21 + .../jvmAndJsSecondCommonMain/kotlin/Greeter.kt | 10 + .../jvmMain/kotlin/example/Clock.kt | 34 + .../jvmMain/kotlin/example/ClockDays.kt | 15 + .../jvmMain/kotlin/example/ParticularClock.kt | 32 + plugins/build.gradle.kts | 5 +- 29 files changed, 1578 insertions(+), 1577 deletions(-) delete mode 100644 core/src/test/kotlin/basic/DRITest.kt delete mode 100644 core/src/test/kotlin/basic/DokkaBasicTests.kt delete mode 100644 core/src/test/kotlin/enums/EnumsTest.kt delete mode 100644 core/src/test/kotlin/markdown/KDocTest.kt delete mode 100644 core/src/test/kotlin/markdown/ParserTest.kt delete mode 100644 core/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt delete mode 100644 core/src/test/kotlin/pageMerger/PageNodeMergerTest.kt delete mode 100644 core/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/Clock.kt delete mode 100644 core/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/House.kt delete mode 100644 core/src/test/resources/multiplatform/basicMultiplatformTest/jsMain/kotlin/Clock.kt delete mode 100644 core/src/test/resources/multiplatform/basicMultiplatformTest/jvmAndJsSecondCommonMain/kotlin/Greeter.kt delete mode 100644 core/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt delete mode 100644 core/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ClockDays.kt delete mode 100644 core/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ParticularClock.kt create mode 100644 plugins/base/src/test/kotlin/basic/DRITest.kt create mode 100644 plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt create mode 100644 plugins/base/src/test/kotlin/enums/EnumsTest.kt create mode 100644 plugins/base/src/test/kotlin/markdown/KDocTest.kt create mode 100644 plugins/base/src/test/kotlin/markdown/ParserTest.kt create mode 100644 plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt create mode 100644 plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt create mode 100644 plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/Clock.kt create mode 100644 plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/House.kt create mode 100644 plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jsMain/kotlin/Clock.kt create mode 100644 plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmAndJsSecondCommonMain/kotlin/Greeter.kt create mode 100644 plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt create mode 100644 plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ClockDays.kt create mode 100644 plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ParticularClock.kt (limited to 'plugins/build.gradle.kts') diff --git a/core/src/test/kotlin/basic/DRITest.kt b/core/src/test/kotlin/basic/DRITest.kt deleted file mode 100644 index c7dc85fb..00000000 --- a/core/src/test/kotlin/basic/DRITest.kt +++ /dev/null @@ -1,168 +0,0 @@ -package basic - -import org.jetbrains.dokka.links.* -import org.jetbrains.dokka.pages.ContentPage -import org.jetbrains.dokka.pages.asSequence -import org.junit.Assert.assertEquals -import org.junit.Test -import testApi.testRunner.AbstractCoreTest - -class DRITest : AbstractCoreTest() { - @Test - fun `#634`() { - val configuration = dokkaConfiguration { - passes { - pass { - sourceRoots = listOf("src/") - } - } - } - - testInline( - """ - |/src/main/kotlin/basic/Test.kt - |package toplevel - | - |inline fun > Array.mySortBy( - | crossinline selector: (T) -> R?): Array = TODO() - |} - """.trimMargin(), - configuration - ) { - documentablesMergingStage = { module -> - val expected = TypeConstructor( - "kotlin.Function1", listOf( - TypeParam(listOf(Nullable(TypeConstructor("kotlin.Any", emptyList())))), - Nullable(TypeParam(listOf(TypeConstructor("kotlin.Comparable", listOf(SelfType))))) - ) - ) - val actual = module.packages.single() - .functions.single() - .dri.callable?.params?.single() - assertEquals(expected, actual) - } - } - } - - @Test - fun `#634 with immediate nullable self`() { - val configuration = dokkaConfiguration { - passes { - pass { - sourceRoots = listOf("src/") - } - } - } - - testInline( - """ - |/src/main/kotlin/basic/Test.kt - |package toplevel - | - |fun > Array.doSomething(t: T?): Array = TODO() - |} - """.trimMargin(), - configuration - ) { - documentablesMergingStage = { module -> - val expected = Nullable(TypeParam(listOf(TypeConstructor("kotlin.Comparable", listOf(SelfType))))) - val actual = module.packages.single() - .functions.single() - .dri.callable?.params?.single() - assertEquals(expected, actual) - } - } - } - - @Test - fun `#634 with generic nullable receiver`() { - val configuration = dokkaConfiguration { - passes { - pass { - sourceRoots = listOf("src/") - } - } - } - - testInline( - """ - |/src/main/kotlin/basic/Test.kt - |package toplevel - | - |fun > T?.doSomethingWithNullable() = TODO() - |} - """.trimMargin(), - configuration - ) { - documentablesMergingStage = { module -> - val expected = Nullable(TypeParam(listOf(TypeConstructor("kotlin.Comparable", listOf(SelfType))))) - val actual = module.packages.single() - .functions.single() - .dri.callable?.receiver - assertEquals(expected, actual) - } - } - } - - @Test - fun `#642 with * and Any?`() { - val configuration = dokkaConfiguration { - passes { - pass { - analysisPlatform = "js" - sourceRoots = listOf("src/") - } - } - } - - testInline( - """ - |/src/main/kotlin/Test.kt - | - |open class Bar - |class ReBarBar : Bar() - |class Foo, R : List>> - | - |fun > Foo.qux(): String = TODO() - |fun > Foo.qux(): String = TODO() - | - """.trimMargin(), - configuration - ) { - pagesGenerationStage = { module -> - // DRI(//qux/Foo[TypeParam(bounds=[kotlin.Comparable[kotlin.Any?]]),kotlin.Any?]#//) - val expectedDRI = DRI( - "", - null, - Callable( - "qux", - TypeConstructor( - "Foo", - listOf( - TypeParam( - listOf( - TypeConstructor( - "kotlin.Comparable", - listOf( - Nullable(TypeConstructor("kotlin.Any", emptyList())) - ) - ) - ) - ), - Nullable(TypeConstructor("kotlin.Any", emptyList())) - ) - ), - emptyList() - ) - ) - - val driCount = module - .asSequence() - .filterIsInstance() - .sumBy { it.dri.count { dri -> dri == expectedDRI } } - - assertEquals(1, driCount) - } - } - } -} \ No newline at end of file diff --git a/core/src/test/kotlin/basic/DokkaBasicTests.kt b/core/src/test/kotlin/basic/DokkaBasicTests.kt deleted file mode 100644 index 021f110c..00000000 --- a/core/src/test/kotlin/basic/DokkaBasicTests.kt +++ /dev/null @@ -1,41 +0,0 @@ -package basic - -import org.jetbrains.dokka.pages.ClasslikePageNode -import org.jetbrains.dokka.pages.ModulePageNode -import org.junit.Test -import testApi.testRunner.AbstractCoreTest - -class DokkaBasicTests : AbstractCoreTest() { - - @Test - fun basic1() { - val configuration = dokkaConfiguration { - passes { - pass { - sourceRoots = listOf("src/main/kotlin/basic/Test.kt") - } - } - } - - testInline( - """ - |/src/main/kotlin/basic/Test.kt - |package basic - | - |class Test { - | val tI = 1 - | fun tF() = 2 - |} - """.trimMargin(), - configuration - ) { - pagesGenerationStage = { - println(it.dri) - assert(it.getClasslikeToMemberMap().filterKeys { it.name == "Test" }.entries.firstOrNull()?.value?.size == 5) - } - } - } - - fun ModulePageNode.getClasslikeToMemberMap() = - this.parentMap.filterValues { it is ClasslikePageNode }.entries.groupBy ({it.value}){it.key} -} \ No newline at end of file diff --git a/core/src/test/kotlin/enums/EnumsTest.kt b/core/src/test/kotlin/enums/EnumsTest.kt deleted file mode 100644 index efc46595..00000000 --- a/core/src/test/kotlin/enums/EnumsTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -package enums - -import org.jetbrains.dokka.pages.ClasslikePageNode -import org.jetbrains.dokka.pages.ModulePageNode -import org.junit.Test -import testApi.testRunner.AbstractCoreTest - -class EnumsTest : AbstractCoreTest() { - - @Test - fun basicEnums() { - val configuration = dokkaConfiguration { - passes { - pass { - sourceRoots = listOf("src/") - } - } - } - - testInline( - """ - |/src/main/kotlin/basic/Test.kt - |package enums - | - |enum class Test { - | E1, - | E2 - |} - """.trimMargin(), - configuration - ) { - pagesGenerationStage = { - val map = it.getClasslikeToMemberMap() - val test = map.filterKeys { it.name == "Test" }.values.firstOrNull() - assert(test != null) { "Test not found" } - assert(test!!.any { it.name == "E1" } && test.any { it.name == "E2" }) { "Enum entries missing in parent" } - assert(map.keys.any { it.name == "E1" } && map.keys.any { it.name == "E2" }) { "Enum entries missing" } - } - } - } - - - fun ModulePageNode.getClasslikeToMemberMap() = - this.parentMap.filterValues { it is ClasslikePageNode }.entries.groupBy({ it.value }) { it.key } -} \ No newline at end of file diff --git a/core/src/test/kotlin/markdown/KDocTest.kt b/core/src/test/kotlin/markdown/KDocTest.kt deleted file mode 100644 index c58c4e30..00000000 --- a/core/src/test/kotlin/markdown/KDocTest.kt +++ /dev/null @@ -1,48 +0,0 @@ -package markdown - -import org.jetbrains.dokka.model.Package -import org.jetbrains.dokka.model.doc.DocumentationNode -import org.jetbrains.dokka.pages.ModulePageNode -import org.junit.Assert -import testApi.testRunner.AbstractCoreTest - -open class KDocTest : AbstractCoreTest() { - - private val configuration = dokkaConfiguration { - passes { - pass { - sourceRoots = listOf("src/main/kotlin/example/Test.kt") - } - } - } - - private fun interpolateKdoc(kdoc: String) = """ - |/src/main/kotlin/example/Test.kt - |package example - | /** - ${kdoc.split("\n").joinToString("") { "| *$it\n" } } - | */ - |class Test - """.trimMargin() - - private fun actualDocumentationNode(modulePageNode: ModulePageNode) = - (modulePageNode.documentable?.children?.first() as Package) - .classlikes.first() - .platformInfo.first() - .documentationNode - - - protected fun executeTest(kdoc: String, expectedDocumentationNode: DocumentationNode) { - testInline( - interpolateKdoc(kdoc), - configuration - ) { - pagesGenerationStage = { - Assert.assertEquals( - expectedDocumentationNode, - actualDocumentationNode(it) - ) - } - } - } -} \ No newline at end of file diff --git a/core/src/test/kotlin/markdown/ParserTest.kt b/core/src/test/kotlin/markdown/ParserTest.kt deleted file mode 100644 index dee8e907..00000000 --- a/core/src/test/kotlin/markdown/ParserTest.kt +++ /dev/null @@ -1,940 +0,0 @@ -package org.jetbrains.dokka.tests - -import markdown.KDocTest -import org.jetbrains.dokka.model.doc.* -import org.junit.Ignore -import org.junit.Test - - -class ParserTest : KDocTest() { - - @Test fun `Simple text`() { - val kdoc = """ - | This is simple test of string - | Next line - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf(Text("This is simple test of string Next line"))) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Simple text with new line`() { - val kdoc = """ - | This is simple test of string\ - | Next line - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - Text("This is simple test of string"), - Br, - Text("Next line") - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Text with Bold and Emphasis decorators`() { - val kdoc = """ - | This is **simple** test of _string_ - | Next **_line_** - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P( - listOf( - Text("This is "), - B(listOf(Text("simple"))), - Text(" test of "), - I(listOf(Text("string"))), - Text(" Next "), - B(listOf(I(listOf(Text("line"))))) - ) - ) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Text with Colon`() { - val kdoc = """ - | This is simple text with: colon! - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf(Text("This is simple text with: colon!"))) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Multilined text`() { - val kdoc = """ - | Text - | and - | String - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf(Text("Text and String"))) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Paragraphs`() { - val kdoc = """ - | Paragraph number - | one - | - | Paragraph\ - | number two - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P( - listOf( - P(listOf(Text("Paragraph number one"))), - P(listOf(Text("Paragraph"), Br, Text("number two"))) - ) - ) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Emphasis with star`() { - val kdoc = " *text*" - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf(I(listOf(Text("text"))))) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Underscores that are not Emphasis`() { - val kdoc = "text_with_underscores" - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf(Text("text_with_underscores"))) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Emphasis with underscores`() { - val kdoc = "_text_" - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf(I(listOf(Text("text"))))) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Embedded star`() { - val kdoc = "Embedded*Star" - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf(Text("Embedded*Star"))) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - - @Test fun `Unordered list`() { - val kdoc = """ - | * list item 1 - | * list item 2 - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - Ul( - listOf( - Li(listOf(P(listOf(Text("list item 1"))))), - Li(listOf(P(listOf(Text("list item 2"))))) - ) - ) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Unordered list with multilines`() { - val kdoc = """ - | * list item 1 - | continue 1 - | * list item 2\ - | continue 2 - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - Ul( - listOf( - Li(listOf(P(listOf(Text("list item 1 continue 1"))))), - Li(listOf(P(listOf(Text("list item 2"), Br, Text("continue 2"))))) - ) - ) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Unordered list with Bold`() { - val kdoc = """ - | * list **item** 1 - | continue 1 - | * list __item__ 2 - | continue 2 - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - Ul(listOf( - Li(listOf(P(listOf( - Text("list "), - B(listOf(Text("item"))), - Text(" 1 continue 1") - )))), - Li(listOf(P(listOf( - Text("list "), - B(listOf(Text("item"))), - Text(" 2 continue 2") - )))) - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Unordered list with nested bullets`() { - val kdoc = """ - | * Outer first - | Outer next line - | * Outer second - | - Middle first - | Middle next line - | - Middle second - | + Inner first - | Inner next line - | - Middle third - | * Outer third - | - | New paragraph""".trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - Ul(listOf( - Li(listOf(P(listOf(Text("Outer first Outer next line"))))), - Li(listOf(P(listOf(Text("Outer second"))))), - Ul(listOf( - Li(listOf(P(listOf(Text("Middle first Middle next line"))))), - Li(listOf(P(listOf(Text("Middle second"))))), - Ul(listOf( - Li(listOf(P(listOf(Text("Inner first Inner next line"))))) - )), - Li(listOf(P(listOf(Text("Middle third"))))) - )), - Li(listOf(P(listOf(Text("Outer third"))))) - )), - P(listOf(Text("New paragraph"))) - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Ordered list`() { - val kdoc = """ - | 1. list item 1 - | 2. list item 2 - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - Ol( - listOf( - Li(listOf(P(listOf(Text("list item 1"))))), - Li(listOf(P(listOf(Text("list item 2"))))) - ), - mapOf("start" to "1") - ) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - - @Test fun `Ordered list beginning from other number`() { - val kdoc = """ - | 9. list item 1 - | 12. list item 2 - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - Ol( - listOf( - Li(listOf(P(listOf(Text("list item 1"))))), - Li(listOf(P(listOf(Text("list item 2"))))) - ), - mapOf("start" to "9") - ) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Ordered list with multilines`() { - val kdoc = """ - | 2. list item 1 - | continue 1 - | 3. list item 2 - | continue 2 - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - Ol( - listOf( - Li(listOf(P(listOf(Text("list item 1 continue 1"))))), - Li(listOf(P(listOf(Text("list item 2 continue 2"))))) - ), - mapOf("start" to "2") - ) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Ordered list with Bold`() { - val kdoc = """ - | 1. list **item** 1 - | continue 1 - | 2. list __item__ 2 - | continue 2 - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - Ol(listOf( - Li(listOf(P(listOf( - Text("list "), - B(listOf(Text("item"))), - Text(" 1 continue 1") - )))), - Li(listOf(P(listOf( - Text("list "), - B(listOf(Text("item"))), - Text(" 2 continue 2") - )))) - ), - mapOf("start" to "1") - ) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Ordered list with nested bullets`() { - val kdoc = """ - | 1. Outer first - | Outer next line - | 2. Outer second - | 1. Middle first - | Middle next line - | 2. Middle second - | 1. Inner first - | Inner next line - | 5. Middle third - | 4. Outer third - | - | New paragraph""".trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - Ol(listOf( - Li(listOf(P(listOf(Text("Outer first Outer next line"))))), - Li(listOf(P(listOf(Text("Outer second"))))), - Ol(listOf( - Li(listOf(P(listOf(Text("Middle first Middle next line"))))), - Li(listOf(P(listOf(Text("Middle second"))))), - Ol(listOf( - Li(listOf(P(listOf(Text("Inner first Inner next line"))))) - ), - mapOf("start" to "1") - ), - Li(listOf(P(listOf(Text("Middle third"))))) - ), - mapOf("start" to "1") - ), - Li(listOf(P(listOf(Text("Outer third"))))) - ), - mapOf("start" to "1") - ), - P(listOf(Text("New paragraph"))) - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Ordered nested in Unordered nested in Ordered list`() { - val kdoc = """ - | 1. Outer first - | Outer next line - | 2. Outer second - | + Middle first - | Middle next line - | + Middle second - | 1. Inner first - | Inner next line - | + Middle third - | 4. Outer third - | - | New paragraph""".trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - Ol(listOf( - Li(listOf(P(listOf(Text("Outer first Outer next line"))))), - Li(listOf(P(listOf(Text("Outer second"))))), - Ul(listOf( - Li(listOf(P(listOf(Text("Middle first Middle next line"))))), - Li(listOf(P(listOf(Text("Middle second"))))), - Ol(listOf( - Li(listOf(P(listOf(Text("Inner first Inner next line"))))) - ), - mapOf("start" to "1") - ), - Li(listOf(P(listOf(Text("Middle third"))))) - )), - Li(listOf(P(listOf(Text("Outer third"))))) - ), - mapOf("start" to "1") - ), - P(listOf(Text("New paragraph"))) - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Header and two paragraphs`() { - val kdoc = """ - | # Header 1 - | Following text - | - | New paragraph - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - H1(listOf(Text("Header 1"))), - P(listOf(Text("Following text"))), - P(listOf(Text("New paragraph"))) - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Ignore //TODO: ATX_2 to ATX_6 and sometimes ATX_1 from jetbrains parser consumes white space. Need to handle it in their library - @Test fun `All headers`() { - val kdoc = """ - | # Header 1 - | Text 1 - | ## Header 2 - | Text 2 - | ### Header 3 - | Text 3 - | #### Header 4 - | Text 4 - | ##### Header 5 - | Text 5 - | ###### Header 6 - | Text 6 - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - H1(listOf(Text("Header 1"))), - P(listOf(Text("Text 1"))), - H2(listOf(Text("Header 2"))), - P(listOf(Text("Text 2"))), - H3(listOf(Text("Header 3"))), - P(listOf(Text("Text 3"))), - H4(listOf(Text("Header 4"))), - P(listOf(Text("Text 4"))), - H5(listOf(Text("Header 5"))), - P(listOf(Text("Text 5"))), - H6(listOf(Text("Header 6"))), - P(listOf(Text("Text 6"))) - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Bold New Line Bold`() { - val kdoc = """ - | **line 1**\ - | **line 2** - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - B(listOf(Text("line 1"))), - Br, - B(listOf(Text("line 2"))) - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Horizontal rule`() { - val kdoc = """ - | *** - | text 1 - | ___ - | text 2 - | *** - | text 3 - | ___ - | text 4 - | *** - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - HorizontalRule, - P(listOf(Text("text 1"))), - HorizontalRule, - P(listOf(Text("text 2"))), - HorizontalRule, - P(listOf(Text("text 3"))), - HorizontalRule, - P(listOf(Text("text 4"))), - HorizontalRule - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Blockquote`() { - val kdoc = """ - | > Blockquotes are very handy in email to emulate reply text. - | > This line is part of the same quote. - | - | Quote break. - | - | > Quote - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - BlockQuote(listOf( - P(listOf( - Text("Blockquotes are very handy in email to emulate reply text. This line is part of the same quote.") - )) - )), - P(listOf(Text("Quote break."))), - BlockQuote(listOf( - P(listOf(Text("Quote"))) - )) - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - - @Test fun `Blockquote nested`() { - val kdoc = """ - | > text 1 - | > text 2 - | >> text 3 - | >> text 4 - | > - | > text 5 - | - | Quote break. - | - | > Quote - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - BlockQuote(listOf( - P(listOf(Text("text 1 text 2"))), - BlockQuote(listOf( - P(listOf(Text("text 3 text 4"))) - )), - P(listOf(Text("text 5"))) - )), - P(listOf(Text("Quote break."))), - BlockQuote(listOf( - P(listOf(Text("Quote"))) - )) - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Ignore //TODO: Again ATX_1 consumes white space - @Test fun `Blockquote nested with fancy text enhancement`() { - val kdoc = """ - | > text **1** - | > text 2 - | >> # text 3 - | >> * text 4 - | >> * text 5 - | > - | > text 6 - | - | Quote break. - | - | > Quote - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - BlockQuote(listOf( - P(listOf( - Text("text "), - B(listOf(Text("1"))), - Text("\ntext 2") - )), - BlockQuote(listOf( - H1(listOf(Text("text 3"))), - Ul(listOf( - Li(listOf(P(listOf(Text("text 4"))))), - Ul(listOf( - Li(listOf(P(listOf(Text("text 5"))))) - ) - ))) - )), - P(listOf(Text("text 6"))) - )), - P(listOf(Text("Quote break."))), - BlockQuote(listOf( - P(listOf(Text("Quote"))) - )) - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Simple Code Block`() { - val kdoc = """ - | `Some code` - | Sample text - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - Code(listOf(Text("Some code"))), - Text(" Sample text") - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Multilined Code Block`() { - val kdoc = """ - | ```kotlin - | val x: Int = 0 - | val y: String = "Text" - | - | val z: Boolean = true - | for(i in 0..10) { - | println(i) - | } - | ``` - | Sample text - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - Code( - listOf( - Text("val x: Int = 0"), Br, - Text("val y: String = \"Text\""), Br, Br, - Text(" val z: Boolean = true"), Br, - Text("for(i in 0..10) {"), Br, - Text(" println(i)"), Br, - Text("}") - ), - mapOf("lang" to "kotlin") - ), - P(listOf(Text("Sample text"))) - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - - @Test fun `Inline link`() { - val kdoc = """ - | [I'm an inline-style link](https://www.google.com) - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf(A( - listOf(Text("I'm an inline-style link")), - mapOf("href" to "https://www.google.com") - ))) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Inline link with title`() { - val kdoc = """ - | [I'm an inline-style link with title](https://www.google.com "Google's Homepage") - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf(A( - listOf(Text("I'm an inline-style link with title")), - mapOf("href" to "https://www.google.com", "title" to "Google's Homepage") - ))) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Full reference link`() { - val kdoc = """ - | [I'm a reference-style link][Arbitrary case-insensitive reference text] - | - | [arbitrary case-insensitive reference text]: https://www.mozilla.org - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf(P(listOf(A( - listOf(Text("I'm a reference-style link")), - mapOf("href" to "https://www.mozilla.org") - ))))) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Full reference link with number`() { - val kdoc = """ - | [You can use numbers for reference-style link definitions][1] - | - | [1]: http://slashdot.org - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf(P(listOf(A( - listOf(Text("You can use numbers for reference-style link definitions")), - mapOf("href" to "http://slashdot.org") - ))))) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Short reference link`() { - val kdoc = """ - | Or leave it empty and use the [link text itself]. - | - | [link text itself]: http://www.reddit.com - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf(P(listOf( - Text("Or leave it empty and use the "), - A( - listOf(Text("link text itself")), - mapOf("href" to "http://www.reddit.com") - ), - Text(".") - )))) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Autolink`() { - val kdoc = """ - | URLs and URLs in angle brackets will automatically get turned into links. - | http://www.example.com or and sometimes - | example.com (but not on Github, for example). - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - Text("URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com or "), - A( - listOf(Text("http://www.example.com")), - mapOf("href" to "http://www.example.com") - ), - Text(" and sometimes example.com (but not on Github, for example).") - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Various links`() { - val kdoc = """ - | [I'm an inline-style link](https://www.google.com) - | - | [I'm an inline-style link with title](https://www.google.com "Google's Homepage") - | - | [I'm a reference-style link][Arbitrary case-insensitive reference text] - | - | [You can use numbers for reference-style link definitions][1] - | - | Or leave it empty and use the [link text itself]. - | - | URLs and URLs in angle brackets will automatically get turned into links. - | http://www.example.com or and sometimes - | example.com (but not on Github, for example). - | - | Some text to show that the reference links can follow later. - | - | [arbitrary case-insensitive reference text]: https://www.mozilla.org - | [1]: http://slashdot.org - | [link text itself]: http://www.reddit.com - """.trimMargin() - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - P(listOf(A( - listOf(Text("I'm an inline-style link")), - mapOf("href" to "https://www.google.com") - ))), - P(listOf(A( - listOf(Text("I'm an inline-style link with title")), - mapOf("href" to "https://www.google.com", "title" to "Google's Homepage") - ))), - P(listOf(A( - listOf(Text("I'm a reference-style link")), - mapOf("href" to "https://www.mozilla.org") - ))), - P(listOf(A( - listOf(Text("You can use numbers for reference-style link definitions")), - mapOf("href" to "http://slashdot.org") - ))), - P(listOf( - Text("Or leave it empty and use the "), - A( - listOf(Text("link text itself")), - mapOf("href" to "http://www.reddit.com") - ), - Text(".") - )), - P(listOf( - Text("URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com or "), - A( - listOf(Text("http://www.example.com")), - mapOf("href" to "http://www.example.com") - ), - Text(" and sometimes example.com (but not on Github, for example).") - )), - P(listOf(Text("Some text to show that the reference links can follow later."))) - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } - - @Test fun `Windows Carriage Return Line Feed`() { - val kdoc = "text\r\ntext" - val expectedDocumentationNode = DocumentationNode( - listOf( - Description( - P(listOf( - Text("text text") - )) - ) - ) - ) - executeTest(kdoc, expectedDocumentationNode) - } -} - diff --git a/core/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt b/core/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt deleted file mode 100644 index f9431bbb..00000000 --- a/core/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt +++ /dev/null @@ -1,55 +0,0 @@ -package multiplatform - -import org.junit.Assert.assertEquals -import org.junit.Test -import testApi.testRunner.AbstractCoreTest - -class BasicMultiplatformTest : AbstractCoreTest() { - - @Test - fun dataTestExample() { - val testDataDir = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath() - - val configuration = dokkaConfiguration { - passes { - pass { - sourceRoots = listOf("$testDataDir/jvmMain/") - } - } - } - - testFromData(configuration) { - pagesTransformationStage = { - assertEquals(6, it.children.firstOrNull()?.children?.count() ?: 0) - } - } - } - - @Test - fun inlineTestExample() { - val configuration = dokkaConfiguration { - passes { - pass { - sourceRoots = listOf("src/main/kotlin/multiplatform/Test.kt") - } - } - } - - testInline( - """ - |/src/main/kotlin/multiplatform/Test.kt - |package multiplatform - | - |object Test { - | fun test2(str: String): Unit {println(str)} - |} - """.trimMargin(), - configuration - ) { - pagesGenerationStage = { - println(it.dri) - assertEquals(7, it.parentMap.size) - } - } - } -} \ No newline at end of file diff --git a/core/src/test/kotlin/pageMerger/PageNodeMergerTest.kt b/core/src/test/kotlin/pageMerger/PageNodeMergerTest.kt deleted file mode 100644 index 88e57ddb..00000000 --- a/core/src/test/kotlin/pageMerger/PageNodeMergerTest.kt +++ /dev/null @@ -1,127 +0,0 @@ -package pageMerger - -import org.jetbrains.dokka.CoreExtensions -import org.jetbrains.dokka.pages.ContentPage -import org.jetbrains.dokka.pages.PageNode -import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.transformers.pages.DefaultPageMergerStrategy -import org.jetbrains.dokka.transformers.pages.SameMethodNamePageMergerStrategy -import org.jetbrains.dokka.utilities.DokkaLogger -import org.junit.Test -import testApi.testRunner.AbstractCoreTest - -class PageNodeMergerTest : AbstractCoreTest() { - - object SameNameStrategy : DokkaPlugin() { - val strategy by extending { CoreExtensions.pageMergerStrategy with SameMethodNamePageMergerStrategy } - } - - class DefaultStrategy(val strList: MutableList = mutableListOf()) : DokkaPlugin(), DokkaLogger { - val strategy by extending { CoreExtensions.pageMergerStrategy with DefaultPageMergerStrategy(this@DefaultStrategy) } - - override var warningsCount: Int = 0 - override var errorsCount: Int = 0 - - override fun debug(message: String) = TODO() - - override fun info(message: String) = TODO() - - override fun progress(message: String) = TODO() - - override fun warn(message: String) { - strList += message - } - - override fun error(message: String) = TODO() - - override fun report() = TODO() - } - - @Test - fun sameNameStrategyTest() { - - val configuration = dokkaConfiguration { - passes { - pass { - sourceRoots = listOf("src/main/kotlin/pageMerger/Test.kt") - } - } - } - - testInline( - """ - |/src/main/kotlin/pageMerger/Test.kt - |package pageMerger - | - |fun testT(): Int = 1 - |fun testT(i: Int): Int = i - | - |object Test { - | fun test(): String = "" - | fun test(str: String): String = str - |} - """.trimMargin(), - configuration, - pluginOverrides = listOf(SameNameStrategy) - ) { - pagesTransformationStage = { - val allChildren = it.childrenRec().filterIsInstance() - val testT = allChildren.filter { it.name == "testT" } - val test = allChildren.filter { it.name == "test" } - - assert(testT.size == 1) { "There can be only one testT page" } - assert(testT.first().dri.size == 2) { "testT page should have 2 DRI, but has ${testT.first().dri.size}" } - - assert(test.size == 1) { "There can be only one test page" } - assert(test.first().dri.size == 2) { "test page should have 2 DRI, but has ${test.first().dri.size}" } - } - } - } - - @Test - fun defaultStrategyTest() { - val strList: MutableList = mutableListOf() - - val configuration = dokkaConfiguration { - passes { - pass { - sourceRoots = listOf("src/main/kotlin/pageMerger/Test.kt") - } - } - } - - testInline( - """ - |/src/main/kotlin/pageMerger/Test.kt - |package pageMerger - | - |fun testT(): Int = 1 - |fun testT(i: Int): Int = i - | - |object Test { - | fun test(): String = "" - | fun test(str: String): String = str - |} - """.trimMargin(), - configuration, - pluginOverrides = listOf(DefaultStrategy(strList)) - ) { - pagesTransformationStage = { root -> - val allChildren = root.childrenRec().filterIsInstance() - val testT = allChildren.filter { it.name == "testT" } - val test = allChildren.filter { it.name == "test" } - - assert(testT.size == 1) { "There can be only one testT page" } - assert(testT.first().dri.size == 1) { "testT page should have single DRI, but has ${testT.first().dri.size}" } - - assert(test.size == 1) { "There can be only one test page" } - assert(test.first().dri.size == 1) { "test page should have single DRI, but has ${test.first().dri.size}" } - - assert(strList.count() == 2) { "Expected 2 warnings, got ${strList.count()}" } - } - } - } - - fun PageNode.childrenRec(): List = listOf(this) + children.flatMap { it.childrenRec() } - -} \ No newline at end of file diff --git a/core/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/Clock.kt b/core/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/Clock.kt deleted file mode 100644 index 4753cb32..00000000 --- a/core/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/Clock.kt +++ /dev/null @@ -1,15 +0,0 @@ -package example - -/** - * Documentation for expected class Clock - * in common module - */ -expect open class Clock() { - fun getTime(): String - /** - * Time in minis - */ - fun getTimesInMillis(): String - fun getYear(): String -} - diff --git a/core/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/House.kt b/core/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/House.kt deleted file mode 100644 index c879dee7..00000000 --- a/core/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/House.kt +++ /dev/null @@ -1,24 +0,0 @@ -package example - -class House(val street: String, val number: Int) { - - /** - * The owner of the house - */ - var owner: String = "" - - /** - * The owner of the house - */ - val differentOwner: String = "" - - fun addFloor() {} - - class Basement { - val pickles : List = mutableListOf() - } - - companion object { - val DEFAULT = House("",0) - } -} \ No newline at end of file diff --git a/core/src/test/resources/multiplatform/basicMultiplatformTest/jsMain/kotlin/Clock.kt b/core/src/test/resources/multiplatform/basicMultiplatformTest/jsMain/kotlin/Clock.kt deleted file mode 100644 index 967cffcd..00000000 --- a/core/src/test/resources/multiplatform/basicMultiplatformTest/jsMain/kotlin/Clock.kt +++ /dev/null @@ -1,21 +0,0 @@ -package example - -import greeteer.Greeter -import kotlin.js.Date - -/** - * Documentation for actual class Clock in JS - */ -actual open class Clock { - actual fun getTime() = Date.now().toString() - fun onlyJsFunction(): Int = 42 - actual fun getTimesInMillis(): String = Date.now().toString() - - actual fun getYear(): String { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } -} - -fun main() { - Greeter().greet().also { println(it) } -} \ No newline at end of file diff --git a/core/src/test/resources/multiplatform/basicMultiplatformTest/jvmAndJsSecondCommonMain/kotlin/Greeter.kt b/core/src/test/resources/multiplatform/basicMultiplatformTest/jvmAndJsSecondCommonMain/kotlin/Greeter.kt deleted file mode 100644 index 8a52e2f3..00000000 --- a/core/src/test/resources/multiplatform/basicMultiplatformTest/jvmAndJsSecondCommonMain/kotlin/Greeter.kt +++ /dev/null @@ -1,10 +0,0 @@ -package greeteer - -import example.Clock - -class Greeter { - /** - * Some docs for the [greet] function - */ - fun greet() = Clock().let{ "Hello there! THe time is ${it.getTime()}" } -} \ No newline at end of file diff --git a/core/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt b/core/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt deleted file mode 100644 index 9ec01fb6..00000000 --- a/core/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt +++ /dev/null @@ -1,34 +0,0 @@ -package example - -import greeteer.Greeter - -actual open class Clock { - actual fun getTime(): String = System.currentTimeMillis().toString() - actual fun getTimesInMillis(): String = System.currentTimeMillis().toString() - - /** - * Documentation for onlyJVMFunction on... - * wait for it... - * ...JVM! - */ - fun onlyJVMFunction(): Double = 2.5 - /** - * Custom equals function - */ - override fun equals(other: Any?): Boolean { - return super.equals(other) - } - - open fun getDayOfTheWeek(): String { - TODO("not implemented") - } - actual fun getYear(): String { - TODO("not implemented") - } -} - -fun clockList() = listOf(Clock()) - -fun main() { - Greeter().greet().also { println(it) } -} \ No newline at end of file diff --git a/core/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ClockDays.kt b/core/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ClockDays.kt deleted file mode 100644 index 136ae5c8..00000000 --- a/core/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ClockDays.kt +++ /dev/null @@ -1,15 +0,0 @@ -package example - -/** - * frgergergrthe - * */ -enum class ClockDays { - /** - * dfsdfsdfds - * */ - FIRST, - SECOND, // test2 - THIRD, // test3 - FOURTH, // test4 - FIFTH // test5 -} \ No newline at end of file diff --git a/core/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ParticularClock.kt b/core/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ParticularClock.kt deleted file mode 100644 index 40813b50..00000000 --- a/core/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ParticularClock.kt +++ /dev/null @@ -1,32 +0,0 @@ -package example - -import greeteer.Greeter - -class ParticularClock(private val clockDay: ClockDays) : Clock() { - - /** - * Rings bell [times] - */ - fun ringBell(times: Int) {} - - /** - * Uses provider [greeter] - */ - fun useGreeter(greeter: Greeter) { - - } - - /** - * Day of the week - */ - override fun getDayOfTheWeek() = clockDay.name -} - -/** - * A sample extension function - * When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$ - * @usesMathJax - */ -fun Clock.extensionFun() { - -} \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/basic/DRITest.kt b/plugins/base/src/test/kotlin/basic/DRITest.kt new file mode 100644 index 00000000..c7dc85fb --- /dev/null +++ b/plugins/base/src/test/kotlin/basic/DRITest.kt @@ -0,0 +1,168 @@ +package basic + +import org.jetbrains.dokka.links.* +import org.jetbrains.dokka.pages.ContentPage +import org.jetbrains.dokka.pages.asSequence +import org.junit.Assert.assertEquals +import org.junit.Test +import testApi.testRunner.AbstractCoreTest + +class DRITest : AbstractCoreTest() { + @Test + fun `#634`() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package toplevel + | + |inline fun > Array.mySortBy( + | crossinline selector: (T) -> R?): Array = TODO() + |} + """.trimMargin(), + configuration + ) { + documentablesMergingStage = { module -> + val expected = TypeConstructor( + "kotlin.Function1", listOf( + TypeParam(listOf(Nullable(TypeConstructor("kotlin.Any", emptyList())))), + Nullable(TypeParam(listOf(TypeConstructor("kotlin.Comparable", listOf(SelfType))))) + ) + ) + val actual = module.packages.single() + .functions.single() + .dri.callable?.params?.single() + assertEquals(expected, actual) + } + } + } + + @Test + fun `#634 with immediate nullable self`() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package toplevel + | + |fun > Array.doSomething(t: T?): Array = TODO() + |} + """.trimMargin(), + configuration + ) { + documentablesMergingStage = { module -> + val expected = Nullable(TypeParam(listOf(TypeConstructor("kotlin.Comparable", listOf(SelfType))))) + val actual = module.packages.single() + .functions.single() + .dri.callable?.params?.single() + assertEquals(expected, actual) + } + } + } + + @Test + fun `#634 with generic nullable receiver`() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package toplevel + | + |fun > T?.doSomethingWithNullable() = TODO() + |} + """.trimMargin(), + configuration + ) { + documentablesMergingStage = { module -> + val expected = Nullable(TypeParam(listOf(TypeConstructor("kotlin.Comparable", listOf(SelfType))))) + val actual = module.packages.single() + .functions.single() + .dri.callable?.receiver + assertEquals(expected, actual) + } + } + } + + @Test + fun `#642 with * and Any?`() { + val configuration = dokkaConfiguration { + passes { + pass { + analysisPlatform = "js" + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/Test.kt + | + |open class Bar + |class ReBarBar : Bar() + |class Foo, R : List>> + | + |fun > Foo.qux(): String = TODO() + |fun > Foo.qux(): String = TODO() + | + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { module -> + // DRI(//qux/Foo[TypeParam(bounds=[kotlin.Comparable[kotlin.Any?]]),kotlin.Any?]#//) + val expectedDRI = DRI( + "", + null, + Callable( + "qux", + TypeConstructor( + "Foo", + listOf( + TypeParam( + listOf( + TypeConstructor( + "kotlin.Comparable", + listOf( + Nullable(TypeConstructor("kotlin.Any", emptyList())) + ) + ) + ) + ), + Nullable(TypeConstructor("kotlin.Any", emptyList())) + ) + ), + emptyList() + ) + ) + + val driCount = module + .asSequence() + .filterIsInstance() + .sumBy { it.dri.count { dri -> dri == expectedDRI } } + + assertEquals(1, driCount) + } + } + } +} \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt b/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt new file mode 100644 index 00000000..021f110c --- /dev/null +++ b/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt @@ -0,0 +1,41 @@ +package basic + +import org.jetbrains.dokka.pages.ClasslikePageNode +import org.jetbrains.dokka.pages.ModulePageNode +import org.junit.Test +import testApi.testRunner.AbstractCoreTest + +class DokkaBasicTests : AbstractCoreTest() { + + @Test + fun basic1() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package basic + | + |class Test { + | val tI = 1 + | fun tF() = 2 + |} + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { + println(it.dri) + assert(it.getClasslikeToMemberMap().filterKeys { it.name == "Test" }.entries.firstOrNull()?.value?.size == 5) + } + } + } + + fun ModulePageNode.getClasslikeToMemberMap() = + this.parentMap.filterValues { it is ClasslikePageNode }.entries.groupBy ({it.value}){it.key} +} \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt new file mode 100644 index 00000000..efc46595 --- /dev/null +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -0,0 +1,45 @@ +package enums + +import org.jetbrains.dokka.pages.ClasslikePageNode +import org.jetbrains.dokka.pages.ModulePageNode +import org.junit.Test +import testApi.testRunner.AbstractCoreTest + +class EnumsTest : AbstractCoreTest() { + + @Test + fun basicEnums() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package enums + | + |enum class Test { + | E1, + | E2 + |} + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { + val map = it.getClasslikeToMemberMap() + val test = map.filterKeys { it.name == "Test" }.values.firstOrNull() + assert(test != null) { "Test not found" } + assert(test!!.any { it.name == "E1" } && test.any { it.name == "E2" }) { "Enum entries missing in parent" } + assert(map.keys.any { it.name == "E1" } && map.keys.any { it.name == "E2" }) { "Enum entries missing" } + } + } + } + + + fun ModulePageNode.getClasslikeToMemberMap() = + this.parentMap.filterValues { it is ClasslikePageNode }.entries.groupBy({ it.value }) { it.key } +} \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/markdown/KDocTest.kt b/plugins/base/src/test/kotlin/markdown/KDocTest.kt new file mode 100644 index 00000000..c58c4e30 --- /dev/null +++ b/plugins/base/src/test/kotlin/markdown/KDocTest.kt @@ -0,0 +1,48 @@ +package markdown + +import org.jetbrains.dokka.model.Package +import org.jetbrains.dokka.model.doc.DocumentationNode +import org.jetbrains.dokka.pages.ModulePageNode +import org.junit.Assert +import testApi.testRunner.AbstractCoreTest + +open class KDocTest : AbstractCoreTest() { + + private val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/main/kotlin/example/Test.kt") + } + } + } + + private fun interpolateKdoc(kdoc: String) = """ + |/src/main/kotlin/example/Test.kt + |package example + | /** + ${kdoc.split("\n").joinToString("") { "| *$it\n" } } + | */ + |class Test + """.trimMargin() + + private fun actualDocumentationNode(modulePageNode: ModulePageNode) = + (modulePageNode.documentable?.children?.first() as Package) + .classlikes.first() + .platformInfo.first() + .documentationNode + + + protected fun executeTest(kdoc: String, expectedDocumentationNode: DocumentationNode) { + testInline( + interpolateKdoc(kdoc), + configuration + ) { + pagesGenerationStage = { + Assert.assertEquals( + expectedDocumentationNode, + actualDocumentationNode(it) + ) + } + } + } +} \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/markdown/ParserTest.kt b/plugins/base/src/test/kotlin/markdown/ParserTest.kt new file mode 100644 index 00000000..dee8e907 --- /dev/null +++ b/plugins/base/src/test/kotlin/markdown/ParserTest.kt @@ -0,0 +1,940 @@ +package org.jetbrains.dokka.tests + +import markdown.KDocTest +import org.jetbrains.dokka.model.doc.* +import org.junit.Ignore +import org.junit.Test + + +class ParserTest : KDocTest() { + + @Test fun `Simple text`() { + val kdoc = """ + | This is simple test of string + | Next line + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf(Text("This is simple test of string Next line"))) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Simple text with new line`() { + val kdoc = """ + | This is simple test of string\ + | Next line + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + Text("This is simple test of string"), + Br, + Text("Next line") + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Text with Bold and Emphasis decorators`() { + val kdoc = """ + | This is **simple** test of _string_ + | Next **_line_** + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P( + listOf( + Text("This is "), + B(listOf(Text("simple"))), + Text(" test of "), + I(listOf(Text("string"))), + Text(" Next "), + B(listOf(I(listOf(Text("line"))))) + ) + ) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Text with Colon`() { + val kdoc = """ + | This is simple text with: colon! + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf(Text("This is simple text with: colon!"))) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Multilined text`() { + val kdoc = """ + | Text + | and + | String + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf(Text("Text and String"))) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Paragraphs`() { + val kdoc = """ + | Paragraph number + | one + | + | Paragraph\ + | number two + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P( + listOf( + P(listOf(Text("Paragraph number one"))), + P(listOf(Text("Paragraph"), Br, Text("number two"))) + ) + ) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Emphasis with star`() { + val kdoc = " *text*" + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf(I(listOf(Text("text"))))) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Underscores that are not Emphasis`() { + val kdoc = "text_with_underscores" + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf(Text("text_with_underscores"))) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Emphasis with underscores`() { + val kdoc = "_text_" + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf(I(listOf(Text("text"))))) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Embedded star`() { + val kdoc = "Embedded*Star" + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf(Text("Embedded*Star"))) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + + @Test fun `Unordered list`() { + val kdoc = """ + | * list item 1 + | * list item 2 + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + Ul( + listOf( + Li(listOf(P(listOf(Text("list item 1"))))), + Li(listOf(P(listOf(Text("list item 2"))))) + ) + ) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Unordered list with multilines`() { + val kdoc = """ + | * list item 1 + | continue 1 + | * list item 2\ + | continue 2 + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + Ul( + listOf( + Li(listOf(P(listOf(Text("list item 1 continue 1"))))), + Li(listOf(P(listOf(Text("list item 2"), Br, Text("continue 2"))))) + ) + ) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Unordered list with Bold`() { + val kdoc = """ + | * list **item** 1 + | continue 1 + | * list __item__ 2 + | continue 2 + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + Ul(listOf( + Li(listOf(P(listOf( + Text("list "), + B(listOf(Text("item"))), + Text(" 1 continue 1") + )))), + Li(listOf(P(listOf( + Text("list "), + B(listOf(Text("item"))), + Text(" 2 continue 2") + )))) + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Unordered list with nested bullets`() { + val kdoc = """ + | * Outer first + | Outer next line + | * Outer second + | - Middle first + | Middle next line + | - Middle second + | + Inner first + | Inner next line + | - Middle third + | * Outer third + | + | New paragraph""".trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + Ul(listOf( + Li(listOf(P(listOf(Text("Outer first Outer next line"))))), + Li(listOf(P(listOf(Text("Outer second"))))), + Ul(listOf( + Li(listOf(P(listOf(Text("Middle first Middle next line"))))), + Li(listOf(P(listOf(Text("Middle second"))))), + Ul(listOf( + Li(listOf(P(listOf(Text("Inner first Inner next line"))))) + )), + Li(listOf(P(listOf(Text("Middle third"))))) + )), + Li(listOf(P(listOf(Text("Outer third"))))) + )), + P(listOf(Text("New paragraph"))) + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Ordered list`() { + val kdoc = """ + | 1. list item 1 + | 2. list item 2 + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + Ol( + listOf( + Li(listOf(P(listOf(Text("list item 1"))))), + Li(listOf(P(listOf(Text("list item 2"))))) + ), + mapOf("start" to "1") + ) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + + @Test fun `Ordered list beginning from other number`() { + val kdoc = """ + | 9. list item 1 + | 12. list item 2 + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + Ol( + listOf( + Li(listOf(P(listOf(Text("list item 1"))))), + Li(listOf(P(listOf(Text("list item 2"))))) + ), + mapOf("start" to "9") + ) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Ordered list with multilines`() { + val kdoc = """ + | 2. list item 1 + | continue 1 + | 3. list item 2 + | continue 2 + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + Ol( + listOf( + Li(listOf(P(listOf(Text("list item 1 continue 1"))))), + Li(listOf(P(listOf(Text("list item 2 continue 2"))))) + ), + mapOf("start" to "2") + ) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Ordered list with Bold`() { + val kdoc = """ + | 1. list **item** 1 + | continue 1 + | 2. list __item__ 2 + | continue 2 + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + Ol(listOf( + Li(listOf(P(listOf( + Text("list "), + B(listOf(Text("item"))), + Text(" 1 continue 1") + )))), + Li(listOf(P(listOf( + Text("list "), + B(listOf(Text("item"))), + Text(" 2 continue 2") + )))) + ), + mapOf("start" to "1") + ) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Ordered list with nested bullets`() { + val kdoc = """ + | 1. Outer first + | Outer next line + | 2. Outer second + | 1. Middle first + | Middle next line + | 2. Middle second + | 1. Inner first + | Inner next line + | 5. Middle third + | 4. Outer third + | + | New paragraph""".trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + Ol(listOf( + Li(listOf(P(listOf(Text("Outer first Outer next line"))))), + Li(listOf(P(listOf(Text("Outer second"))))), + Ol(listOf( + Li(listOf(P(listOf(Text("Middle first Middle next line"))))), + Li(listOf(P(listOf(Text("Middle second"))))), + Ol(listOf( + Li(listOf(P(listOf(Text("Inner first Inner next line"))))) + ), + mapOf("start" to "1") + ), + Li(listOf(P(listOf(Text("Middle third"))))) + ), + mapOf("start" to "1") + ), + Li(listOf(P(listOf(Text("Outer third"))))) + ), + mapOf("start" to "1") + ), + P(listOf(Text("New paragraph"))) + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Ordered nested in Unordered nested in Ordered list`() { + val kdoc = """ + | 1. Outer first + | Outer next line + | 2. Outer second + | + Middle first + | Middle next line + | + Middle second + | 1. Inner first + | Inner next line + | + Middle third + | 4. Outer third + | + | New paragraph""".trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + Ol(listOf( + Li(listOf(P(listOf(Text("Outer first Outer next line"))))), + Li(listOf(P(listOf(Text("Outer second"))))), + Ul(listOf( + Li(listOf(P(listOf(Text("Middle first Middle next line"))))), + Li(listOf(P(listOf(Text("Middle second"))))), + Ol(listOf( + Li(listOf(P(listOf(Text("Inner first Inner next line"))))) + ), + mapOf("start" to "1") + ), + Li(listOf(P(listOf(Text("Middle third"))))) + )), + Li(listOf(P(listOf(Text("Outer third"))))) + ), + mapOf("start" to "1") + ), + P(listOf(Text("New paragraph"))) + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Header and two paragraphs`() { + val kdoc = """ + | # Header 1 + | Following text + | + | New paragraph + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + H1(listOf(Text("Header 1"))), + P(listOf(Text("Following text"))), + P(listOf(Text("New paragraph"))) + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Ignore //TODO: ATX_2 to ATX_6 and sometimes ATX_1 from jetbrains parser consumes white space. Need to handle it in their library + @Test fun `All headers`() { + val kdoc = """ + | # Header 1 + | Text 1 + | ## Header 2 + | Text 2 + | ### Header 3 + | Text 3 + | #### Header 4 + | Text 4 + | ##### Header 5 + | Text 5 + | ###### Header 6 + | Text 6 + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + H1(listOf(Text("Header 1"))), + P(listOf(Text("Text 1"))), + H2(listOf(Text("Header 2"))), + P(listOf(Text("Text 2"))), + H3(listOf(Text("Header 3"))), + P(listOf(Text("Text 3"))), + H4(listOf(Text("Header 4"))), + P(listOf(Text("Text 4"))), + H5(listOf(Text("Header 5"))), + P(listOf(Text("Text 5"))), + H6(listOf(Text("Header 6"))), + P(listOf(Text("Text 6"))) + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Bold New Line Bold`() { + val kdoc = """ + | **line 1**\ + | **line 2** + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + B(listOf(Text("line 1"))), + Br, + B(listOf(Text("line 2"))) + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Horizontal rule`() { + val kdoc = """ + | *** + | text 1 + | ___ + | text 2 + | *** + | text 3 + | ___ + | text 4 + | *** + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + HorizontalRule, + P(listOf(Text("text 1"))), + HorizontalRule, + P(listOf(Text("text 2"))), + HorizontalRule, + P(listOf(Text("text 3"))), + HorizontalRule, + P(listOf(Text("text 4"))), + HorizontalRule + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Blockquote`() { + val kdoc = """ + | > Blockquotes are very handy in email to emulate reply text. + | > This line is part of the same quote. + | + | Quote break. + | + | > Quote + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + BlockQuote(listOf( + P(listOf( + Text("Blockquotes are very handy in email to emulate reply text. This line is part of the same quote.") + )) + )), + P(listOf(Text("Quote break."))), + BlockQuote(listOf( + P(listOf(Text("Quote"))) + )) + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + + @Test fun `Blockquote nested`() { + val kdoc = """ + | > text 1 + | > text 2 + | >> text 3 + | >> text 4 + | > + | > text 5 + | + | Quote break. + | + | > Quote + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + BlockQuote(listOf( + P(listOf(Text("text 1 text 2"))), + BlockQuote(listOf( + P(listOf(Text("text 3 text 4"))) + )), + P(listOf(Text("text 5"))) + )), + P(listOf(Text("Quote break."))), + BlockQuote(listOf( + P(listOf(Text("Quote"))) + )) + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Ignore //TODO: Again ATX_1 consumes white space + @Test fun `Blockquote nested with fancy text enhancement`() { + val kdoc = """ + | > text **1** + | > text 2 + | >> # text 3 + | >> * text 4 + | >> * text 5 + | > + | > text 6 + | + | Quote break. + | + | > Quote + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + BlockQuote(listOf( + P(listOf( + Text("text "), + B(listOf(Text("1"))), + Text("\ntext 2") + )), + BlockQuote(listOf( + H1(listOf(Text("text 3"))), + Ul(listOf( + Li(listOf(P(listOf(Text("text 4"))))), + Ul(listOf( + Li(listOf(P(listOf(Text("text 5"))))) + ) + ))) + )), + P(listOf(Text("text 6"))) + )), + P(listOf(Text("Quote break."))), + BlockQuote(listOf( + P(listOf(Text("Quote"))) + )) + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Simple Code Block`() { + val kdoc = """ + | `Some code` + | Sample text + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + Code(listOf(Text("Some code"))), + Text(" Sample text") + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Multilined Code Block`() { + val kdoc = """ + | ```kotlin + | val x: Int = 0 + | val y: String = "Text" + | + | val z: Boolean = true + | for(i in 0..10) { + | println(i) + | } + | ``` + | Sample text + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + Code( + listOf( + Text("val x: Int = 0"), Br, + Text("val y: String = \"Text\""), Br, Br, + Text(" val z: Boolean = true"), Br, + Text("for(i in 0..10) {"), Br, + Text(" println(i)"), Br, + Text("}") + ), + mapOf("lang" to "kotlin") + ), + P(listOf(Text("Sample text"))) + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + + @Test fun `Inline link`() { + val kdoc = """ + | [I'm an inline-style link](https://www.google.com) + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf(A( + listOf(Text("I'm an inline-style link")), + mapOf("href" to "https://www.google.com") + ))) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Inline link with title`() { + val kdoc = """ + | [I'm an inline-style link with title](https://www.google.com "Google's Homepage") + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf(A( + listOf(Text("I'm an inline-style link with title")), + mapOf("href" to "https://www.google.com", "title" to "Google's Homepage") + ))) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Full reference link`() { + val kdoc = """ + | [I'm a reference-style link][Arbitrary case-insensitive reference text] + | + | [arbitrary case-insensitive reference text]: https://www.mozilla.org + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf(P(listOf(A( + listOf(Text("I'm a reference-style link")), + mapOf("href" to "https://www.mozilla.org") + ))))) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Full reference link with number`() { + val kdoc = """ + | [You can use numbers for reference-style link definitions][1] + | + | [1]: http://slashdot.org + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf(P(listOf(A( + listOf(Text("You can use numbers for reference-style link definitions")), + mapOf("href" to "http://slashdot.org") + ))))) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Short reference link`() { + val kdoc = """ + | Or leave it empty and use the [link text itself]. + | + | [link text itself]: http://www.reddit.com + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf(P(listOf( + Text("Or leave it empty and use the "), + A( + listOf(Text("link text itself")), + mapOf("href" to "http://www.reddit.com") + ), + Text(".") + )))) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Autolink`() { + val kdoc = """ + | URLs and URLs in angle brackets will automatically get turned into links. + | http://www.example.com or and sometimes + | example.com (but not on Github, for example). + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + Text("URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com or "), + A( + listOf(Text("http://www.example.com")), + mapOf("href" to "http://www.example.com") + ), + Text(" and sometimes example.com (but not on Github, for example).") + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Various links`() { + val kdoc = """ + | [I'm an inline-style link](https://www.google.com) + | + | [I'm an inline-style link with title](https://www.google.com "Google's Homepage") + | + | [I'm a reference-style link][Arbitrary case-insensitive reference text] + | + | [You can use numbers for reference-style link definitions][1] + | + | Or leave it empty and use the [link text itself]. + | + | URLs and URLs in angle brackets will automatically get turned into links. + | http://www.example.com or and sometimes + | example.com (but not on Github, for example). + | + | Some text to show that the reference links can follow later. + | + | [arbitrary case-insensitive reference text]: https://www.mozilla.org + | [1]: http://slashdot.org + | [link text itself]: http://www.reddit.com + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + P(listOf(A( + listOf(Text("I'm an inline-style link")), + mapOf("href" to "https://www.google.com") + ))), + P(listOf(A( + listOf(Text("I'm an inline-style link with title")), + mapOf("href" to "https://www.google.com", "title" to "Google's Homepage") + ))), + P(listOf(A( + listOf(Text("I'm a reference-style link")), + mapOf("href" to "https://www.mozilla.org") + ))), + P(listOf(A( + listOf(Text("You can use numbers for reference-style link definitions")), + mapOf("href" to "http://slashdot.org") + ))), + P(listOf( + Text("Or leave it empty and use the "), + A( + listOf(Text("link text itself")), + mapOf("href" to "http://www.reddit.com") + ), + Text(".") + )), + P(listOf( + Text("URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com or "), + A( + listOf(Text("http://www.example.com")), + mapOf("href" to "http://www.example.com") + ), + Text(" and sometimes example.com (but not on Github, for example).") + )), + P(listOf(Text("Some text to show that the reference links can follow later."))) + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test fun `Windows Carriage Return Line Feed`() { + val kdoc = "text\r\ntext" + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + Text("text text") + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } +} + diff --git a/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt b/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt new file mode 100644 index 00000000..f9431bbb --- /dev/null +++ b/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt @@ -0,0 +1,55 @@ +package multiplatform + +import org.junit.Assert.assertEquals +import org.junit.Test +import testApi.testRunner.AbstractCoreTest + +class BasicMultiplatformTest : AbstractCoreTest() { + + @Test + fun dataTestExample() { + val testDataDir = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath() + + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("$testDataDir/jvmMain/") + } + } + } + + testFromData(configuration) { + pagesTransformationStage = { + assertEquals(6, it.children.firstOrNull()?.children?.count() ?: 0) + } + } + } + + @Test + fun inlineTestExample() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/main/kotlin/multiplatform/Test.kt") + } + } + } + + testInline( + """ + |/src/main/kotlin/multiplatform/Test.kt + |package multiplatform + | + |object Test { + | fun test2(str: String): Unit {println(str)} + |} + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { + println(it.dri) + assertEquals(7, it.parentMap.size) + } + } + } +} \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt new file mode 100644 index 00000000..88e57ddb --- /dev/null +++ b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt @@ -0,0 +1,127 @@ +package pageMerger + +import org.jetbrains.dokka.CoreExtensions +import org.jetbrains.dokka.pages.ContentPage +import org.jetbrains.dokka.pages.PageNode +import org.jetbrains.dokka.plugability.DokkaPlugin +import org.jetbrains.dokka.transformers.pages.DefaultPageMergerStrategy +import org.jetbrains.dokka.transformers.pages.SameMethodNamePageMergerStrategy +import org.jetbrains.dokka.utilities.DokkaLogger +import org.junit.Test +import testApi.testRunner.AbstractCoreTest + +class PageNodeMergerTest : AbstractCoreTest() { + + object SameNameStrategy : DokkaPlugin() { + val strategy by extending { CoreExtensions.pageMergerStrategy with SameMethodNamePageMergerStrategy } + } + + class DefaultStrategy(val strList: MutableList = mutableListOf()) : DokkaPlugin(), DokkaLogger { + val strategy by extending { CoreExtensions.pageMergerStrategy with DefaultPageMergerStrategy(this@DefaultStrategy) } + + override var warningsCount: Int = 0 + override var errorsCount: Int = 0 + + override fun debug(message: String) = TODO() + + override fun info(message: String) = TODO() + + override fun progress(message: String) = TODO() + + override fun warn(message: String) { + strList += message + } + + override fun error(message: String) = TODO() + + override fun report() = TODO() + } + + @Test + fun sameNameStrategyTest() { + + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/main/kotlin/pageMerger/Test.kt") + } + } + } + + testInline( + """ + |/src/main/kotlin/pageMerger/Test.kt + |package pageMerger + | + |fun testT(): Int = 1 + |fun testT(i: Int): Int = i + | + |object Test { + | fun test(): String = "" + | fun test(str: String): String = str + |} + """.trimMargin(), + configuration, + pluginOverrides = listOf(SameNameStrategy) + ) { + pagesTransformationStage = { + val allChildren = it.childrenRec().filterIsInstance() + val testT = allChildren.filter { it.name == "testT" } + val test = allChildren.filter { it.name == "test" } + + assert(testT.size == 1) { "There can be only one testT page" } + assert(testT.first().dri.size == 2) { "testT page should have 2 DRI, but has ${testT.first().dri.size}" } + + assert(test.size == 1) { "There can be only one test page" } + assert(test.first().dri.size == 2) { "test page should have 2 DRI, but has ${test.first().dri.size}" } + } + } + } + + @Test + fun defaultStrategyTest() { + val strList: MutableList = mutableListOf() + + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/main/kotlin/pageMerger/Test.kt") + } + } + } + + testInline( + """ + |/src/main/kotlin/pageMerger/Test.kt + |package pageMerger + | + |fun testT(): Int = 1 + |fun testT(i: Int): Int = i + | + |object Test { + | fun test(): String = "" + | fun test(str: String): String = str + |} + """.trimMargin(), + configuration, + pluginOverrides = listOf(DefaultStrategy(strList)) + ) { + pagesTransformationStage = { root -> + val allChildren = root.childrenRec().filterIsInstance() + val testT = allChildren.filter { it.name == "testT" } + val test = allChildren.filter { it.name == "test" } + + assert(testT.size == 1) { "There can be only one testT page" } + assert(testT.first().dri.size == 1) { "testT page should have single DRI, but has ${testT.first().dri.size}" } + + assert(test.size == 1) { "There can be only one test page" } + assert(test.first().dri.size == 1) { "test page should have single DRI, but has ${test.first().dri.size}" } + + assert(strList.count() == 2) { "Expected 2 warnings, got ${strList.count()}" } + } + } + } + + fun PageNode.childrenRec(): List = listOf(this) + children.flatMap { it.childrenRec() } + +} \ No newline at end of file diff --git a/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/Clock.kt b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/Clock.kt new file mode 100644 index 00000000..4753cb32 --- /dev/null +++ b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/Clock.kt @@ -0,0 +1,15 @@ +package example + +/** + * Documentation for expected class Clock + * in common module + */ +expect open class Clock() { + fun getTime(): String + /** + * Time in minis + */ + fun getTimesInMillis(): String + fun getYear(): String +} + diff --git a/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/House.kt b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/House.kt new file mode 100644 index 00000000..c879dee7 --- /dev/null +++ b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/House.kt @@ -0,0 +1,24 @@ +package example + +class House(val street: String, val number: Int) { + + /** + * The owner of the house + */ + var owner: String = "" + + /** + * The owner of the house + */ + val differentOwner: String = "" + + fun addFloor() {} + + class Basement { + val pickles : List = mutableListOf() + } + + companion object { + val DEFAULT = House("",0) + } +} \ No newline at end of file diff --git a/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jsMain/kotlin/Clock.kt b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jsMain/kotlin/Clock.kt new file mode 100644 index 00000000..967cffcd --- /dev/null +++ b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jsMain/kotlin/Clock.kt @@ -0,0 +1,21 @@ +package example + +import greeteer.Greeter +import kotlin.js.Date + +/** + * Documentation for actual class Clock in JS + */ +actual open class Clock { + actual fun getTime() = Date.now().toString() + fun onlyJsFunction(): Int = 42 + actual fun getTimesInMillis(): String = Date.now().toString() + + actual fun getYear(): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +} + +fun main() { + Greeter().greet().also { println(it) } +} \ No newline at end of file diff --git a/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmAndJsSecondCommonMain/kotlin/Greeter.kt b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmAndJsSecondCommonMain/kotlin/Greeter.kt new file mode 100644 index 00000000..8a52e2f3 --- /dev/null +++ b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmAndJsSecondCommonMain/kotlin/Greeter.kt @@ -0,0 +1,10 @@ +package greeteer + +import example.Clock + +class Greeter { + /** + * Some docs for the [greet] function + */ + fun greet() = Clock().let{ "Hello there! THe time is ${it.getTime()}" } +} \ No newline at end of file diff --git a/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt new file mode 100644 index 00000000..9ec01fb6 --- /dev/null +++ b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt @@ -0,0 +1,34 @@ +package example + +import greeteer.Greeter + +actual open class Clock { + actual fun getTime(): String = System.currentTimeMillis().toString() + actual fun getTimesInMillis(): String = System.currentTimeMillis().toString() + + /** + * Documentation for onlyJVMFunction on... + * wait for it... + * ...JVM! + */ + fun onlyJVMFunction(): Double = 2.5 + /** + * Custom equals function + */ + override fun equals(other: Any?): Boolean { + return super.equals(other) + } + + open fun getDayOfTheWeek(): String { + TODO("not implemented") + } + actual fun getYear(): String { + TODO("not implemented") + } +} + +fun clockList() = listOf(Clock()) + +fun main() { + Greeter().greet().also { println(it) } +} \ No newline at end of file diff --git a/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ClockDays.kt b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ClockDays.kt new file mode 100644 index 00000000..136ae5c8 --- /dev/null +++ b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ClockDays.kt @@ -0,0 +1,15 @@ +package example + +/** + * frgergergrthe + * */ +enum class ClockDays { + /** + * dfsdfsdfds + * */ + FIRST, + SECOND, // test2 + THIRD, // test3 + FOURTH, // test4 + FIFTH // test5 +} \ No newline at end of file diff --git a/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ParticularClock.kt b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ParticularClock.kt new file mode 100644 index 00000000..40813b50 --- /dev/null +++ b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ParticularClock.kt @@ -0,0 +1,32 @@ +package example + +import greeteer.Greeter + +class ParticularClock(private val clockDay: ClockDays) : Clock() { + + /** + * Rings bell [times] + */ + fun ringBell(times: Int) {} + + /** + * Uses provider [greeter] + */ + fun useGreeter(greeter: Greeter) { + + } + + /** + * Day of the week + */ + override fun getDayOfTheWeek() = clockDay.name +} + +/** + * A sample extension function + * When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$ + * @usesMathJax + */ +fun Clock.extensionFun() { + +} \ No newline at end of file diff --git a/plugins/build.gradle.kts b/plugins/build.gradle.kts index e29f1355..923fb48b 100644 --- a/plugins/build.gradle.kts +++ b/plugins/build.gradle.kts @@ -5,11 +5,12 @@ subprojects { dependencies { compileOnly(project(":core")) - compileOnly(kotlin("stdlib-jdk8")) // compileOnly(project(":coreDependencies", configuration = "shadow")) // uncomment if IntelliJ does not recognize pacakges from IntelliJ + implementation(kotlin("stdlib-jdk8")) + testImplementation(project(":core")) + testImplementation(project(":coreDependencies", configuration = "shadow")) testImplementation(project(":testApi")) - testImplementation(kotlin("stdlib-jdk8")) testImplementation("junit:junit:4.13") } } \ No newline at end of file -- cgit From 6a4eda715f59106530f5f6078ff2c93e49079ac6 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Mon, 17 Feb 2020 15:05:03 +0100 Subject: Translators moved to separate packages also typo fixed and unnecessary dependencies removed --- plugins/base/src/main/kotlin/DokkaBase.kt | 8 +- .../src/main/kotlin/renderers/DefaultRenderer.kt | 2 +- .../DefaultDescriptorToDocumentationTranslator.kt | 338 --------------------- .../DefaultDocumentablesToPageTranslator.kt | 27 -- .../transformers/documentables/PageBuilder.kt | 159 ---------- .../documentables/PageContentBuilder.kt | 218 ------------- .../transformers/pages/merger/PageNodeMerger.kt | 2 +- .../DefaultDescriptorToDocumentationTranslator.kt | 335 ++++++++++++++++++++ .../DefaultDocumentablesToPageTranslator.kt | 25 ++ .../translators/documentables/PageBuilder.kt | 159 ++++++++++ .../documentables/PageContentBuilder.kt | 218 +++++++++++++ plugins/build.gradle.kts | 2 - ...linAsJavaDescriptorToDocumentationTranslator.kt | 6 +- .../src/main/kotlin/KotlinAsJavaPageBuilder.kt | 4 +- .../main/kotlin/KotlinAsJavaPageContentBuilder.kt | 6 +- 15 files changed, 751 insertions(+), 758 deletions(-) delete mode 100644 plugins/base/src/main/kotlin/transformers/descriptors/DefaultDescriptorToDocumentationTranslator.kt delete mode 100644 plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentablesToPageTranslator.kt delete mode 100644 plugins/base/src/main/kotlin/transformers/documentables/PageBuilder.kt delete mode 100644 plugins/base/src/main/kotlin/transformers/documentables/PageContentBuilder.kt create mode 100644 plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentationTranslator.kt create mode 100644 plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentablesToPageTranslator.kt create mode 100644 plugins/base/src/main/kotlin/translators/documentables/PageBuilder.kt create mode 100644 plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt (limited to 'plugins/build.gradle.kts') diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt index fd842dc0..e7cd61a8 100644 --- a/plugins/base/src/main/kotlin/DokkaBase.kt +++ b/plugins/base/src/main/kotlin/DokkaBase.kt @@ -6,9 +6,8 @@ import org.jetbrains.dokka.base.renderers.OutputWriter import org.jetbrains.dokka.base.renderers.html.HtmlRenderer import org.jetbrains.dokka.base.resolvers.DefaultLocationProviderFactory import org.jetbrains.dokka.base.resolvers.LocationProviderFactory -import org.jetbrains.dokka.base.transformers.descriptors.DefaultDescriptorToDocumentationTranslator import org.jetbrains.dokka.base.transformers.documentables.DefaultDocumentableMerger -import org.jetbrains.dokka.base.transformers.documentables.DefaultDocumentablesToPageTranslator +import org.jetbrains.dokka.base.translators.documentables.DefaultDocumentablesToPageTranslator import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.base.transformers.pages.comments.DocTagToContentConverter import org.jetbrains.dokka.base.transformers.pages.merger.FallbackPageMergerStrategy @@ -16,12 +15,13 @@ import org.jetbrains.dokka.base.transformers.pages.merger.PageMergerStrategy import org.jetbrains.dokka.base.transformers.pages.merger.PageNodeMerger import org.jetbrains.dokka.base.transformers.pages.merger.SameMethodNamePageMergerStrategy import org.jetbrains.dokka.base.transformers.psi.DefaultPsiToDocumentationTranslator +import org.jetbrains.dokka.base.translators.descriptors.DefaultDescriptorToDocumentationTranslator import org.jetbrains.dokka.plugability.DokkaPlugin class DokkaBase : DokkaPlugin() { val pageMergerStrategy by extensionPoint() val commentsToContentConverter by extensionPoint() - val locationproviderFactory by extensionPoint() + val locationProviderFactory by extensionPoint() val outputWriter by extensionPoint() val descriptorToDocumentationTranslator by extending(isFallback = true) { @@ -65,7 +65,7 @@ class DokkaBase : DokkaPlugin() { } val locationProvider by extending(isFallback = true) { - locationproviderFactory providing ::DefaultLocationProviderFactory + locationProviderFactory providing ::DefaultLocationProviderFactory } val fileWriter by extending(isFallback = true) { diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt index 951545d2..75034bda 100644 --- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt @@ -117,7 +117,7 @@ abstract class DefaultRenderer( val newRoot = preprocessors.fold(root) { acc, t -> t(acc) } locationProvider = - context.plugin().querySingle { locationproviderFactory }.getLocationProvider(newRoot) + context.plugin().querySingle { locationProviderFactory }.getLocationProvider(newRoot) root.children().forEach { renderPackageList(it) } diff --git a/plugins/base/src/main/kotlin/transformers/descriptors/DefaultDescriptorToDocumentationTranslator.kt b/plugins/base/src/main/kotlin/transformers/descriptors/DefaultDescriptorToDocumentationTranslator.kt deleted file mode 100644 index 1358cef1..00000000 --- a/plugins/base/src/main/kotlin/transformers/descriptors/DefaultDescriptorToDocumentationTranslator.kt +++ /dev/null @@ -1,338 +0,0 @@ -package org.jetbrains.dokka.base.transformers.descriptors - -import org.jetbrains.dokka.analysis.DokkaResolutionFacade -import org.jetbrains.dokka.links.Callable -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.links.withClass -import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.ClassKind -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function -import org.jetbrains.dokka.model.Property -import org.jetbrains.dokka.model.doc.* -import org.jetbrains.dokka.pages.PlatformData -import org.jetbrains.dokka.parsers.MarkdownParser -import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentationTranslator -import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies -import org.jetbrains.kotlin.idea.kdoc.findKDoc -import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe -import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperclassesWithoutAny -import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces -import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter -import org.jetbrains.kotlin.resolve.scopes.MemberScope -import org.jetbrains.kotlin.types.KotlinType -import kotlin.reflect.KClass - -class DefaultDescriptorToDocumentationTranslator( - private val context: DokkaContext -) : DescriptorToDocumentationTranslator { - override fun invoke( - moduleName: String, - packageFragments: Iterable, - platformData: PlatformData - ) = DokkaDescriptorVisitor(platformData, context.platforms[platformData]?.facade!!).run { - packageFragments.map { - visitPackageFragmentDescriptor( - it, - DRIWithPlatformInfo(DRI.topLevel, null, emptyList()) - ) - } - }.let { Module(moduleName, it) } - -} - - -data class DRIWithPlatformInfo( - val dri: DRI, - val expected: PlatformInfo?, - val actual: List -) - -fun DRI.withEmptyInfo() = DRIWithPlatformInfo(this, null, emptyList()) - -open class DokkaDescriptorVisitor( // TODO: close this class and make it private together with DRIWithPlatformInfo - private val platformData: PlatformData, - private val resolutionFacade: DokkaResolutionFacade -) : DeclarationDescriptorVisitorEmptyBodies() { - override fun visitDeclarationDescriptor(descriptor: DeclarationDescriptor, parent: DRIWithPlatformInfo): Nothing { - throw IllegalStateException("${javaClass.simpleName} should never enter ${descriptor.javaClass.simpleName}") - } - - override fun visitPackageFragmentDescriptor( - descriptor: PackageFragmentDescriptor, - parent: DRIWithPlatformInfo - ): Package { - val driWithPlatform = DRI(packageName = descriptor.fqName.asString()).withEmptyInfo() - val scope = descriptor.getMemberScope() - - return Package( - dri = driWithPlatform.dri, - functions = scope.functions(driWithPlatform), - properties = scope.properties(driWithPlatform), - classlikes = scope.classlikes(driWithPlatform) - ) - } - - override fun visitClassDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Classlike = - when (descriptor.kind) { - org.jetbrains.kotlin.descriptors.ClassKind.ENUM_CLASS -> enumDescriptor(descriptor, parent) - else -> classDescriptor(descriptor, parent) - } - - fun enumDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Enum { - val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() - val scope = descriptor.unsubstitutedMemberScope - val descriptorData = descriptor.takeUnless { it.isExpect }?.resolveClassDescriptionData() - - return Enum( - dri = driWithPlatform.dri, - name = descriptor.name.asString(), - entries = scope.classlikes(driWithPlatform).filter { it.kind == KotlinClassKindTypes.ENUM_ENTRY }.map { - EnumEntry( - it - ) - }, - constructors = descriptor.constructors.map { visitConstructorDescriptor(it, driWithPlatform) }, - functions = scope.functions(driWithPlatform), - properties = scope.properties(driWithPlatform), - classlikes = scope.classlikes(driWithPlatform), - expected = descriptor.takeIf { it.isExpect }?.resolveClassDescriptionData(), - actual = listOfNotNull(descriptorData), - extra = mutableSetOf(), // TODO Implement following method to return proper results getXMLDRIs(descriptor, descriptorData).toMutableSet() - visibility = mapOf(platformData to descriptor.visibility) - ) - } - - fun classDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Class { - val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() - val scope = descriptor.unsubstitutedMemberScope - val descriptorData = descriptor.takeUnless { it.isExpect }?.resolveClassDescriptionData() - val expected = descriptor.takeIf { it.isExpect }?.resolveClassDescriptionData() - val actual = listOfNotNull(descriptorData) - return Class( - dri = driWithPlatform.dri, - name = descriptor.name.asString(), - kind = KotlinClassKindTypes.valueOf(descriptor.kind.toString()), - constructors = descriptor.constructors.map { - visitConstructorDescriptor( - it, - if (it.isPrimary) - DRIWithPlatformInfo( - driWithPlatform.dri, - expected?.info.filterTagWrappers(listOf(Constructor::class)), - actual.filterTagWrappers(listOf(Constructor::class)) - ) - else - DRIWithPlatformInfo(driWithPlatform.dri, null, emptyList()) - ) - }, - functions = scope.functions(driWithPlatform), - properties = scope.properties(driWithPlatform), - classlikes = scope.classlikes(driWithPlatform), - expected = expected, - actual = actual, - extra = mutableSetOf(), // TODO Implement following method to return proper results getXMLDRIs(descriptor, descriptorData).toMutableSet() - visibility = mapOf(platformData to descriptor.visibility) - ) - } - - override fun visitPropertyDescriptor(descriptor: PropertyDescriptor, parent: DRIWithPlatformInfo): Property { - val expected = descriptor.takeIf { it.isExpect }?.resolveDescriptorData() - val actual = listOfNotNull(descriptor.takeUnless { it.isExpect }?.resolveDescriptorData()) - val dri = parent.dri.copy(callable = Callable.from(descriptor)) - - return Property( - dri = dri, - name = descriptor.name.asString(), - receiver = descriptor.extensionReceiverParameter?.let { - visitReceiverParameterDescriptor( - it, - DRIWithPlatformInfo( - dri, - expected?.filterTagWrappers(listOf(Receiver::class)), - actual.filterTagWrappers(listOf(Receiver::class)) - ) - ) - }, - expected = expected, - actual = actual, - accessors = descriptor.accessors.map { visitPropertyAccessorDescriptor(it, descriptor, dri) }, - visibility = mapOf(platformData to descriptor.visibility) - ) - } - - override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, parent: DRIWithPlatformInfo): Function { - val expected = descriptor.takeIf { it.isExpect }?.resolveDescriptorData() - val actual = listOfNotNull(descriptor.takeUnless { it.isExpect }?.resolveDescriptorData()) - val dri = parent.dri.copy(callable = Callable.from(descriptor)) - - return Function( - dri = dri, - name = descriptor.name.asString(), - returnType = descriptor.returnType?.let { KotlinTypeWrapper(it) }, - isConstructor = false, - receiver = descriptor.extensionReceiverParameter?.let { - visitReceiverParameterDescriptor( - it, - DRIWithPlatformInfo( - dri, - expected?.filterTagWrappers(listOf(Receiver::class)), - actual.filterTagWrappers(listOf(Receiver::class)) - ) - ) - }, - parameters = descriptor.valueParameters.mapIndexed { index, desc -> - parameter( - index, desc, - DRIWithPlatformInfo( - dri, - expected.filterTagWrappers(listOf(Param::class), desc.name.asString()), - actual.filterTagWrappers(listOf(Param::class), desc.name.asString()) - ) - ) - }, - expected = expected, - actual = actual, - visibility = mapOf(platformData to descriptor.visibility) - ) - } - - override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor, parent: DRIWithPlatformInfo): Function { - val dri = parent.dri.copy(callable = Callable.from(descriptor)) - return Function( - dri = dri, - name = "", - returnType = KotlinTypeWrapper(descriptor.returnType), - isConstructor = true, - receiver = null, - parameters = descriptor.valueParameters.mapIndexed { index, desc -> - parameter( - index, desc, - DRIWithPlatformInfo( - dri, - parent.expected.filterTagWrappers(listOf(Param::class)), - parent.actual.filterTagWrappers(listOf(Param::class)) - ) - ) - }, - expected = parent.expected ?: descriptor.takeIf { it.isExpect }?.resolveDescriptorData(), - actual = parent.actual, - visibility = mapOf(platformData to descriptor.visibility) - ) - } - - override fun visitReceiverParameterDescriptor( - descriptor: ReceiverParameterDescriptor, - parent: DRIWithPlatformInfo - ) = Parameter( - dri = parent.dri.copy(target = 0), - name = null, - type = KotlinTypeWrapper(descriptor.type), - expected = parent.expected, - actual = parent.actual - ) - - open fun visitPropertyAccessorDescriptor( - descriptor: PropertyAccessorDescriptor, - propertyDescriptor: PropertyDescriptor, - parent: DRI - ): Function { - val dri = parent.copy(callable = Callable.from(descriptor)) - val isGetter = descriptor is PropertyGetterDescriptor - - fun PropertyDescriptor.asParameter(parent: DRI) = - Parameter( - parent.copy(target = 1), - this.name.asString(), - KotlinTypeWrapper(this.type), - descriptor.takeIf { it.isExpect }?.resolveDescriptorData(), - listOfNotNull(descriptor.takeUnless { it.isExpect }?.resolveDescriptorData()) - ) - - val name = run { - val modifier = if (isGetter) "get" else "set" - val rawName = propertyDescriptor.name.asString() - "$modifier${rawName[0].toUpperCase()}${rawName.drop(1)}" - } - - descriptor.visibility - val parameters = - if (isGetter) { - emptyList() - } else { - listOf(propertyDescriptor.asParameter(dri)) - } - - return Function( - dri, - name, - descriptor.returnType?.let { KotlinTypeWrapper(it) }, - false, - null, - parameters, - descriptor.takeIf { it.isExpect }?.resolveDescriptorData(), - listOfNotNull(descriptor.takeUnless { it.isExpect }?.resolveDescriptorData()), - visibility = mapOf(platformData to descriptor.visibility) - ) - } - - private fun parameter(index: Int, descriptor: ValueParameterDescriptor, parent: DRIWithPlatformInfo) = - Parameter( - dri = parent.dri.copy(target = index + 1), - name = descriptor.name.asString(), - type = KotlinTypeWrapper(descriptor.type), - expected = parent.expected, - actual = parent.actual - ) - - private fun MemberScope.functions(parent: DRIWithPlatformInfo): List = - getContributedDescriptors(DescriptorKindFilter.FUNCTIONS) { true } - .filterIsInstance() - .map { visitFunctionDescriptor(it, parent) } - - private fun MemberScope.properties(parent: DRIWithPlatformInfo): List = - getContributedDescriptors(DescriptorKindFilter.VALUES) { true } - .filterIsInstance() - .map { visitPropertyDescriptor(it, parent) } - - private fun MemberScope.classlikes(parent: DRIWithPlatformInfo): List = - getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS) { true } - .filterIsInstance() - .map { visitClassDescriptor(it, parent) } - - private fun DeclarationDescriptor.resolveDescriptorData(): PlatformInfo { - val doc = findKDoc() - val parser = MarkdownParser(resolutionFacade, this) - val docHeader = parser.parseFromKDocTag(doc) - - return BasePlatformInfo(docHeader, listOf(platformData)) - } - - private fun ClassDescriptor.resolveClassDescriptionData(): ClassPlatformInfo { - return ClassPlatformInfo(resolveDescriptorData(), - (getSuperInterfaces() + getAllSuperclassesWithoutAny()).map { DRI.from(it) }) - } - - private fun PlatformInfo?.filterTagWrappers( - types: List>, - name: String? = null - ): PlatformInfo? { - if (this == null) - return null - return BasePlatformInfo( - DocumentationNode( - this.documentationNode.children.filter { it::class in types && (it as? NamedTagWrapper)?.name == name } - ), - this.platformData - ) - } - - private fun List.filterTagWrappers( - types: List>, - name: String? = null - ): List = - this.map { it.filterTagWrappers(types, name)!! } -} - diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentablesToPageTranslator.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentablesToPageTranslator.kt deleted file mode 100644 index d28791ab..00000000 --- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentablesToPageTranslator.kt +++ /dev/null @@ -1,27 +0,0 @@ -package org.jetbrains.dokka.base.transformers.documentables - -import org.jetbrains.dokka.CoreExtensions -import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter -import org.jetbrains.dokka.model.Module -import org.jetbrains.dokka.pages.ModulePageNode -import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.transformers.documentation.DocumentablesToPageTranslator -import org.jetbrains.dokka.utilities.DokkaLogger - - -class DefaultDocumentablesToPageTranslator( - private val commentsToContentConverter: CommentsToContentConverter, - private val logger: DokkaLogger -) : DocumentablesToPageTranslator { - override fun invoke(module: Module): ModulePageNode = - DefaultPageBuilder { node, kind, operation -> - DefaultPageContentBuilder.group( - setOf(node.dri), - node.platformData, - kind, - commentsToContentConverter, - logger, - operation - ) - }.pageForModule(module) -} \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/transformers/documentables/PageBuilder.kt b/plugins/base/src/main/kotlin/transformers/documentables/PageBuilder.kt deleted file mode 100644 index 29f39c73..00000000 --- a/plugins/base/src/main/kotlin/transformers/documentables/PageBuilder.kt +++ /dev/null @@ -1,159 +0,0 @@ -package org.jetbrains.dokka.base.transformers.documentables - -import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function -import org.jetbrains.dokka.model.doc.TagWrapper -import org.jetbrains.dokka.pages.* - -open class DefaultPageBuilder( - override val rootContentGroup: RootContentBuilder -) : PageBuilder { - - override fun pageForModule(m: Module): ModulePageNode = - ModulePageNode(m.name.ifEmpty { "root" }, contentForModule(m), m, m.packages.map { pageForPackage(it) }) - - override fun pageForPackage(p: Package) = - PackagePageNode(p.name, contentForPackage(p), setOf(p.dri), p, - p.classlikes.map { pageForClasslike(it) } + - p.functions.map { pageForMember(it) }) - - override fun pageForClasslike(c: Classlike): ClasslikePageNode { - val constructors = when (c) { - is Class -> c.constructors - is Enum -> c.constructors - else -> emptyList() - } - - return ClasslikePageNode(c.name, contentForClasslike(c), setOf(c.dri), c, - constructors.map { pageForMember(it) } + - c.classlikes.map { pageForClasslike(it) } + - c.functions.map { pageForMember(it) }) - } - - override fun pageForMember(m: CallableNode): MemberPageNode = - when (m) { - is Function -> - MemberPageNode(m.name, contentForFunction(m), setOf(m.dri), m) - else -> throw IllegalStateException("$m should not be present here") - } - - protected open fun group(node: Documentable, content: PageContentBuilderFunction) = - rootContentGroup(node, ContentKind.Main, content) - - protected open fun contentForModule(m: Module) = group(m) { - header(1) { text("root") } - block("Packages", 2, ContentKind.Packages, m.packages, m.platformData) { - link(it.name, it.dri) - } - text("Index\n") - text("Link to allpage here") - } - - protected open fun contentForPackage(p: Package) = group(p) { - header(1) { text("Package ${p.name}") } - block("Types", 2, ContentKind.Properties, p.classlikes, p.platformData) { - link(it.name, it.dri) - text(it.briefDocTagString) - } - block("Functions", 2, ContentKind.Functions, p.functions, p.platformData) { - link(it.name, it.dri) - signature(it) - text(it.briefDocTagString) - } - } - - open fun contentForClasslike(c: Classlike): ContentGroup = when (c) { - is Class -> contentForClass(c) - is Enum -> contentForEnum(c) - else -> throw IllegalStateException("$c should not be present here") - } - - protected fun contentForClass(c: Class) = group(c) { - header(1) { text(c.name) } - - c.inherited.takeIf { it.isNotEmpty() }?.let { - header(2) { text("SuperInterfaces") } - linkTable(it) - } - contentForComments(c) - block("Constructors", 2, ContentKind.Functions, c.constructors, c.platformData) { - link(it.name, it.dri) - signature(it) - text(it.briefDocTagString) - } - block("Functions", 2, ContentKind.Functions, c.functions, c.platformData) { - link(it.name, it.dri) - signature(it) - text(it.briefDocTagString) - } - block("Properties", 2, ContentKind.Properties, c.properties, c.platformData) { - link(it.name, it.dri) - text(it.briefDocTagString) - - } - } - - fun contentForEnum(c: Enum): ContentGroup = group(c) { - header(1) { text("enum ${c.name}") } - - block("Entries", 2, ContentKind.Properties, c.entries, c.platformData) { entry -> - link(entry.name, entry.dri) - contentForComments(entry) - } - - c.inherited.takeIf { it.isNotEmpty() }?.let { - header(2) { text("SuperInterfaces") } - linkTable(it) - } - contentForComments(c) - block("Constructors", 2, ContentKind.Functions, c.constructors, c.platformData) { - link(it.name, it.dri) - signature(it) - text(it.briefDocTagString) - } - block("Functions", 2, ContentKind.Functions, c.functions, c.platformData) { - link(it.name, it.dri) - signature(it) - text(it.briefDocTagString) - } - block("Properties", 2, ContentKind.Properties, c.properties, c.platformData) { - link(it.name, it.dri) - text(it.briefDocTagString) - } - } - - private fun PageContentBuilder.contentForComments(d: Documentable) = - d.platformInfo.forEach { platformInfo -> - platformInfo.documentationNode.children.forEach { - header(3) { - text(it.toHeaderString()) - text(" [${platformInfo.platformData.joinToString(", ") { it.platformType.name }}]") - } - comment(it.root) - text("\n") - } - } - - private fun contentForFunction(f: Function) = group(f) { - header(1) { text(f.name) } - signature(f) - contentForComments(f) - block("Parameters", 2, ContentKind.Parameters, f.children, f.platformData) { - text(it.name ?: "") - it.platformInfo.forEach { it.documentationNode.children.forEach { comment(it.root) } } - } - } - - private fun TagWrapper.toHeaderString() = this.javaClass.toGenericString().split('.').last() -} - -typealias RootContentBuilder = (Documentable, Kind, PageContentBuilderFunction) -> ContentGroup - -interface PageBuilder { - val rootContentGroup: RootContentBuilder - fun pageForModule(m: Module): ModulePageNode - fun pageForPackage(p: Package): PackagePageNode - fun pageForMember(m: CallableNode): MemberPageNode - fun pageForClasslike(c: Classlike): ClasslikePageNode -} \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/transformers/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/transformers/documentables/PageContentBuilder.kt deleted file mode 100644 index 6ce883b1..00000000 --- a/plugins/base/src/main/kotlin/transformers/documentables/PageContentBuilder.kt +++ /dev/null @@ -1,218 +0,0 @@ -package org.jetbrains.dokka.base.transformers.documentables - -import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.Documentable -import org.jetbrains.dokka.model.Function -import org.jetbrains.dokka.model.TypeWrapper -import org.jetbrains.dokka.model.doc.DocTag -import org.jetbrains.dokka.pages.* -import org.jetbrains.dokka.utilities.DokkaLogger - -open class DefaultPageContentBuilder( - protected val dri: Set, - protected val platformData: Set, - protected val kind: Kind, - protected val commentsConverter: CommentsToContentConverter, - val logger: DokkaLogger, - protected val styles: Set