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 --- .../test/kotlin/pageMerger/PageNodeMergerTest.kt | 127 +++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt (limited to 'plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt') 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 -- cgit From 2bfb7733dfef8da0271a01a7275ea42ecb69d93a Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Mon, 17 Feb 2020 10:55:44 +0100 Subject: Cleans up page mergers and moves them to base plugin --- core/src/main/kotlin/CoreExtensions.kt | 2 -- .../main/kotlin/plugability/DefaultExtensions.kt | 4 --- core/src/main/kotlin/plugability/DokkaContext.kt | 3 ++ core/src/main/kotlin/plugability/DokkaPlugin.kt | 6 +++- .../pages/DefaultPageMergerStrategy.kt | 11 ------- .../transformers/pages/DefaultPageNodeMerger.kt | 23 -------------- .../transformers/pages/PageMergerStrategy.kt | 9 ------ .../pages/SameMethodNamePageMergerStrategy.kt | 33 -------------------- plugins/base/src/main/kotlin/DokkaBase.kt | 22 +++++++++++++- .../pages/merger/FallbackPageMergerStrategy.kt | 12 ++++++++ .../pages/merger/PageMergerStrategy.kt | 9 ++++++ .../transformers/pages/merger/PageNodeMerger.kt | 29 ++++++++++++++++++ .../merger/SameMethodNamePageMergerStrategy.kt | 35 ++++++++++++++++++++++ .../test/kotlin/pageMerger/PageNodeMergerTest.kt | 16 +++++----- 14 files changed, 123 insertions(+), 91 deletions(-) delete mode 100644 core/src/main/kotlin/transformers/pages/DefaultPageMergerStrategy.kt delete mode 100644 core/src/main/kotlin/transformers/pages/DefaultPageNodeMerger.kt delete mode 100644 core/src/main/kotlin/transformers/pages/PageMergerStrategy.kt delete mode 100644 core/src/main/kotlin/transformers/pages/SameMethodNamePageMergerStrategy.kt create mode 100644 plugins/base/src/main/kotlin/transformers/pages/merger/FallbackPageMergerStrategy.kt create mode 100644 plugins/base/src/main/kotlin/transformers/pages/merger/PageMergerStrategy.kt create mode 100644 plugins/base/src/main/kotlin/transformers/pages/merger/PageNodeMerger.kt create mode 100644 plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt (limited to 'plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt') diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt index 2d705c1b..0f88b492 100644 --- a/core/src/main/kotlin/CoreExtensions.kt +++ b/core/src/main/kotlin/CoreExtensions.kt @@ -9,7 +9,6 @@ import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentationTra import org.jetbrains.dokka.transformers.documentation.DocumentableMerger import org.jetbrains.dokka.transformers.documentation.DocumentationNodeTransformer import org.jetbrains.dokka.transformers.documentation.DocumentablesToPageTranslator -import org.jetbrains.dokka.transformers.pages.PageMergerStrategy import org.jetbrains.dokka.transformers.pages.PageNodeTransformer import org.jetbrains.dokka.transformers.psi.PsiToDocumentationTranslator import kotlin.reflect.KProperty @@ -31,7 +30,6 @@ object CoreExtensions { val commentsToContentConverter by coreExtension() val locationProviderFactory by coreExtension() val outputWriter by coreExtension() - val pageMergerStrategy by coreExtension() private fun coreExtension() = object { operator fun provideDelegate(thisRef: CoreExtensions, property: KProperty<*>): Lazy> = diff --git a/core/src/main/kotlin/plugability/DefaultExtensions.kt b/core/src/main/kotlin/plugability/DefaultExtensions.kt index 828d1bf1..1a367d30 100644 --- a/core/src/main/kotlin/plugability/DefaultExtensions.kt +++ b/core/src/main/kotlin/plugability/DefaultExtensions.kt @@ -5,8 +5,6 @@ import org.jetbrains.dokka.pages.DocTagToContentConverter import org.jetbrains.dokka.renderers.FileWriter import org.jetbrains.dokka.renderers.OutputWriter import org.jetbrains.dokka.resolvers.DefaultLocationProviderFactory -import org.jetbrains.dokka.transformers.pages.DefaultPageMergerStrategy -import org.jetbrains.dokka.transformers.pages.DefaultPageNodeMerger internal object DefaultExtensions { @@ -18,10 +16,8 @@ internal object DefaultExtensions { internal fun > get(point: E, fullContext: DokkaContext): List = when (point) { CoreExtensions.commentsToContentConverter -> converter.get(fullContext) - CoreExtensions.pageTransformer -> DefaultPageNodeMerger(fullContext) CoreExtensions.locationProviderFactory -> providerFactory.get(fullContext) CoreExtensions.outputWriter -> outputWriter.get(fullContext) - CoreExtensions.pageMergerStrategy -> DefaultPageMergerStrategy(fullContext.logger) else -> null }.let { listOfNotNull( it ) as List } } \ No newline at end of file diff --git a/core/src/main/kotlin/plugability/DokkaContext.kt b/core/src/main/kotlin/plugability/DokkaContext.kt index b4be5862..bcf6e1e0 100644 --- a/core/src/main/kotlin/plugability/DokkaContext.kt +++ b/core/src/main/kotlin/plugability/DokkaContext.kt @@ -43,6 +43,9 @@ interface DokkaContext { } } +inline fun DokkaContext.plugin(): T = plugin(T::class) + ?: throw java.lang.IllegalStateException("Plugin ${T::class.qualifiedName} is not present in context.") + interface DokkaContextConfiguration { fun addExtensionDependencies(extension: Extension<*>) } diff --git a/core/src/main/kotlin/plugability/DokkaPlugin.kt b/core/src/main/kotlin/plugability/DokkaPlugin.kt index cdc92ca5..c00b0af3 100644 --- a/core/src/main/kotlin/plugability/DokkaPlugin.kt +++ b/core/src/main/kotlin/plugability/DokkaPlugin.kt @@ -48,4 +48,8 @@ abstract class DokkaPlugin { .map { it.get(this) } .forEach { if (it.condition.invoke(configuration)) ctx.addExtensionDependencies(it) } } -} \ No newline at end of file +} + +inline fun P.query(extension: P.() -> ExtensionPoint): List = + context?.let { it[extension()] } + ?: throw IllegalStateException("Querying about plugins is only possible with dokka context initialised") \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/pages/DefaultPageMergerStrategy.kt b/core/src/main/kotlin/transformers/pages/DefaultPageMergerStrategy.kt deleted file mode 100644 index 66562d8b..00000000 --- a/core/src/main/kotlin/transformers/pages/DefaultPageMergerStrategy.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.jetbrains.dokka.transformers.pages - -import org.jetbrains.dokka.pages.PageNode -import org.jetbrains.dokka.utilities.DokkaLogger - -class DefaultPageMergerStrategy(val logger: DokkaLogger) : PageMergerStrategy { - override fun tryMerge(pages: List): List { - if (pages.size != 1) logger.warn("Expected 1 page, but got ${pages.size}") - return listOf(pages.first()) - } -} \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/pages/DefaultPageNodeMerger.kt b/core/src/main/kotlin/transformers/pages/DefaultPageNodeMerger.kt deleted file mode 100644 index bdfe393e..00000000 --- a/core/src/main/kotlin/transformers/pages/DefaultPageNodeMerger.kt +++ /dev/null @@ -1,23 +0,0 @@ -package org.jetbrains.dokka.transformers.pages - -import org.jetbrains.dokka.CoreExtensions -import org.jetbrains.dokka.pages.PageNode -import org.jetbrains.dokka.pages.RootPageNode -import org.jetbrains.dokka.plugability.DokkaContext - -class DefaultPageNodeMerger(val context: DokkaContext) : PageNodeTransformer { - override fun invoke(input: RootPageNode): RootPageNode = - input.modified(children = input.children.map { it.mergeChildren() }) - - fun PageNode.mergeChildren(): PageNode = children.groupBy { it.name } - .map { (_, v) -> v.mergePageNodes() } - .let { pages -> modified(children = pages.map { it.first().mergeChildren() }) } - - private fun List.mergePageNodes(): List = - context[CoreExtensions.pageMergerStrategy].fold(this) { pages, strategy -> tryMerge(strategy, pages) } - - private fun tryMerge(strategy: PageMergerStrategy, pages: List) = if (pages.size > 1) - strategy.tryMerge(pages) - else - pages -} \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/pages/PageMergerStrategy.kt b/core/src/main/kotlin/transformers/pages/PageMergerStrategy.kt deleted file mode 100644 index 8eb526b3..00000000 --- a/core/src/main/kotlin/transformers/pages/PageMergerStrategy.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.jetbrains.dokka.transformers.pages - -import org.jetbrains.dokka.pages.PageNode - -interface PageMergerStrategy { - - fun tryMerge(pages: List): List - -} \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/pages/SameMethodNamePageMergerStrategy.kt b/core/src/main/kotlin/transformers/pages/SameMethodNamePageMergerStrategy.kt deleted file mode 100644 index 3835506b..00000000 --- a/core/src/main/kotlin/transformers/pages/SameMethodNamePageMergerStrategy.kt +++ /dev/null @@ -1,33 +0,0 @@ -package org.jetbrains.dokka.transformers.pages - -import org.jetbrains.dokka.pages.* - -object SameMethodNamePageMergerStrategy : PageMergerStrategy { - override fun tryMerge(pages: List): List { - val name = pages.first().name - val members = pages.filterIsInstance() - val others = pages.filterNot { it is MemberPageNode } - - val resChildren = members.flatMap { it.children }.distinct() - val dri = members.flatMap { it.dri }.toSet() - val dci = DCI( - dri = dri, - kind = members.first().content.dci.kind - ) - - val merged = MemberPageNode( - dri = dri, - name = name, - children = resChildren, - content = asGroup(dci, members.map { it.content }), - documentable = null - ) - - return others + listOf(merged) - } - - fun asGroup(dci: DCI, nodes: List): ContentGroup { - val n = nodes.first() - return ContentGroup(nodes, dci, n.platforms, n.style, n.extras) - } -} \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt index bafd30ff..ed23d77e 100644 --- a/plugins/base/src/main/kotlin/DokkaBase.kt +++ b/plugins/base/src/main/kotlin/DokkaBase.kt @@ -4,11 +4,17 @@ import org.jetbrains.dokka.CoreExtensions 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.transformers.pages.merger.FallbackPageMergerStrategy +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.plugability.DokkaPlugin import org.jetbrains.dokka.renderers.html.HtmlRenderer class DokkaBase: DokkaPlugin() { + val pageMergerStrategy by extensionPoint() + val descriptorToDocumentationTranslator by extending(isFallback = true) { CoreExtensions.descriptorToDocumentationTranslator providing ::DefaultDescriptorToDocumentationTranslator } @@ -25,7 +31,21 @@ class DokkaBase: DokkaPlugin() { CoreExtensions.documentablesToPageTranslator with DefaultDocumentablesToPageTranslator } + val pageMerger by extending { + CoreExtensions.pageTransformer providing { ctx -> PageNodeMerger(ctx[pageMergerStrategy]) } + } + + val fallbackMerger by extending { + pageMergerStrategy providing { ctx -> FallbackPageMergerStrategy(ctx.logger) } + } + + val sameMethodNameMerger by extending { + pageMergerStrategy with SameMethodNamePageMergerStrategy order { + before(fallbackMerger) + } + } + val htmlRenderer by extending { - CoreExtensions.renderer providing ::HtmlRenderer + CoreExtensions.renderer providing ::HtmlRenderer applyIf { format == "html" } } } \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/FallbackPageMergerStrategy.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/FallbackPageMergerStrategy.kt new file mode 100644 index 00000000..df0c27ee --- /dev/null +++ b/plugins/base/src/main/kotlin/transformers/pages/merger/FallbackPageMergerStrategy.kt @@ -0,0 +1,12 @@ +package org.jetbrains.dokka.base.transformers.pages.merger + +import org.jetbrains.dokka.pages.PageNode +import org.jetbrains.dokka.utilities.DokkaLogger + +class FallbackPageMergerStrategy(private val logger: DokkaLogger) : PageMergerStrategy { + override fun tryMerge(pages: List, path: List): List { + val renderedPath = path.joinToString(separator = "/") + if (pages.size != 1) logger.warn("For $renderedPath: expected 1 page, but got ${pages.size}") + return listOf(pages.first()) + } +} \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/PageMergerStrategy.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMergerStrategy.kt new file mode 100644 index 00000000..b73b17e0 --- /dev/null +++ b/plugins/base/src/main/kotlin/transformers/pages/merger/PageMergerStrategy.kt @@ -0,0 +1,9 @@ +package org.jetbrains.dokka.base.transformers.pages.merger + +import org.jetbrains.dokka.pages.PageNode + +interface PageMergerStrategy { + + fun tryMerge(pages: List, path: List): List + +} \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/PageNodeMerger.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/PageNodeMerger.kt new file mode 100644 index 00000000..5ecf8d9b --- /dev/null +++ b/plugins/base/src/main/kotlin/transformers/pages/merger/PageNodeMerger.kt @@ -0,0 +1,29 @@ +package org.jetbrains.dokka.base.transformers.pages.merger + +import org.jetbrains.dokka.pages.PageNode +import org.jetbrains.dokka.pages.RootPageNode +import org.jetbrains.dokka.transformers.pages.PageNodeTransformer + +class PageNodeMerger(private val strategies: Iterable) : PageNodeTransformer { + override fun invoke(input: RootPageNode): RootPageNode = + input.modified(children = input.children.map { it.mergeChildren(emptyList()) }) + + private fun PageNode.mergeChildren(path: List): PageNode = children.groupBy { it.name } + .map { (n, v) -> mergePageNodes(v, path + n) } + .let { pages -> + modified(children = pages.map { it.assertSingle(path) }.map { it.mergeChildren(path + it.name) }) + } + + private fun mergePageNodes(pages: List, path: List): List = + strategies.fold(pages) { acc, strategy -> tryMerge(strategy, acc, path) } + + private fun tryMerge(strategy: PageMergerStrategy, pages: List, path: List) = + if (pages.size > 1) strategy.tryMerge(pages, path) else pages +} + +private fun Iterable.assertSingle(path: List): T = try { + single() + } catch (e: Exception) { + val renderedPath = path.joinToString(separator = "/") + throw IllegalStateException("Page merger is missconfigured. Error for $renderedPath: ${e.message}") + } \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt new file mode 100644 index 00000000..fef55dd2 --- /dev/null +++ b/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt @@ -0,0 +1,35 @@ +package org.jetbrains.dokka.base.transformers.pages.merger + +import org.jetbrains.dokka.pages.* + +object SameMethodNamePageMergerStrategy : PageMergerStrategy { + override fun tryMerge(pages: List, path: List): List { + val name = pages.first().name + val members = pages.filterIsInstance() + val others = pages.filterNot { it is MemberPageNode } + + val resChildren = members.flatMap { it.children }.distinct() + val dri = members.flatMap { it.dri }.toSet() + val dci = DCI( + dri = dri, + kind = members.first().content.dci.kind + ) + + val merged = MemberPageNode( + dri = dri, + name = name, + children = resChildren, + content = asGroup( + dci, + members.map { it.content }), + documentable = null + ) + + return others + listOf(merged) + } + + fun asGroup(dci: DCI, nodes: List): ContentGroup { + val n = nodes.first() + return ContentGroup(nodes, dci, n.platforms, n.style, n.extras) + } +} \ 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 index 88e57ddb..c6076d54 100644 --- a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt +++ b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt @@ -4,15 +4,15 @@ 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.base.transformers.pages.merger.SameMethodNamePageMergerStrategy import org.jetbrains.dokka.utilities.DokkaLogger +import org.junit.Ignore import org.junit.Test import testApi.testRunner.AbstractCoreTest class PageNodeMergerTest : AbstractCoreTest() { - object SameNameStrategy : DokkaPlugin() { + /* object SameNameStrategy : DokkaPlugin() { val strategy by extending { CoreExtensions.pageMergerStrategy with SameMethodNamePageMergerStrategy } } @@ -36,6 +36,7 @@ class PageNodeMergerTest : AbstractCoreTest() { override fun report() = TODO() } + */ @Test fun sameNameStrategyTest() { @@ -61,8 +62,8 @@ class PageNodeMergerTest : AbstractCoreTest() { | fun test(str: String): String = str |} """.trimMargin(), - configuration, - pluginOverrides = listOf(SameNameStrategy) + configuration/*, + pluginOverrides = listOf(SameNameStrategy)*/ ) { pagesTransformationStage = { val allChildren = it.childrenRec().filterIsInstance() @@ -78,6 +79,7 @@ class PageNodeMergerTest : AbstractCoreTest() { } } + @Ignore("TODO: reenable when we have infrastructure for turning off extensions") @Test fun defaultStrategyTest() { val strList: MutableList = mutableListOf() @@ -103,8 +105,8 @@ class PageNodeMergerTest : AbstractCoreTest() { | fun test(str: String): String = str |} """.trimMargin(), - configuration, - pluginOverrides = listOf(DefaultStrategy(strList)) + configuration/*, + pluginOverrides = listOf(DefaultStrategy(strList)) */ ) { pagesTransformationStage = { root -> val allChildren = root.childrenRec().filterIsInstance() -- cgit From ac590359174995a16a116a96dbb9df5dafa042f5 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Fri, 28 Feb 2020 16:30:17 +0100 Subject: Test api moved to sensible package --- plugins/base/src/test/kotlin/basic/DRITest.kt | 2 +- plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt | 2 +- plugins/base/src/test/kotlin/enums/EnumsTest.kt | 2 +- plugins/base/src/test/kotlin/expect/ExpectTest.kt | 2 +- plugins/base/src/test/kotlin/markdown/KDocTest.kt | 2 +- .../test/kotlin/multiplatform/BasicMultiplatformTest.kt | 2 +- .../src/test/kotlin/pageMerger/PageNodeMergerTest.kt | 2 +- plugins/base/src/test/kotlin/utils/ModelUtils.kt | 2 +- plugins/base/src/test/kotlin/utils/TestUtils.kt | 2 +- .../src/test/kotlin/KotlinAsJavaPluginTest.kt | 2 +- .../main/kotlin/testApi/testRunner/DokkaTestGenerator.kt | 2 +- testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt | 16 +++++++++++++--- 12 files changed, 24 insertions(+), 14 deletions(-) (limited to 'plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt') diff --git a/plugins/base/src/test/kotlin/basic/DRITest.kt b/plugins/base/src/test/kotlin/basic/DRITest.kt index eb65c47b..ca8e4bad 100644 --- a/plugins/base/src/test/kotlin/basic/DRITest.kt +++ b/plugins/base/src/test/kotlin/basic/DRITest.kt @@ -5,7 +5,7 @@ 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 +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest class DRITest : AbstractCoreTest() { @Test diff --git a/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt b/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt index 021f110c..0405b91c 100644 --- a/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt +++ b/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt @@ -3,7 +3,7 @@ package basic import org.jetbrains.dokka.pages.ClasslikePageNode import org.jetbrains.dokka.pages.ModulePageNode import org.junit.Test -import testApi.testRunner.AbstractCoreTest +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest class DokkaBasicTests : AbstractCoreTest() { diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt index efc46595..9ea100a3 100644 --- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -3,7 +3,7 @@ package enums import org.jetbrains.dokka.pages.ClasslikePageNode import org.jetbrains.dokka.pages.ModulePageNode import org.junit.Test -import testApi.testRunner.AbstractCoreTest +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest class EnumsTest : AbstractCoreTest() { diff --git a/plugins/base/src/test/kotlin/expect/ExpectTest.kt b/plugins/base/src/test/kotlin/expect/ExpectTest.kt index 3a85db17..c6c252ed 100644 --- a/plugins/base/src/test/kotlin/expect/ExpectTest.kt +++ b/plugins/base/src/test/kotlin/expect/ExpectTest.kt @@ -1,7 +1,7 @@ package expect import org.junit.Test -import testApi.testRunner.AbstractCoreTest +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths diff --git a/plugins/base/src/test/kotlin/markdown/KDocTest.kt b/plugins/base/src/test/kotlin/markdown/KDocTest.kt index 5099c46f..e250670a 100644 --- a/plugins/base/src/test/kotlin/markdown/KDocTest.kt +++ b/plugins/base/src/test/kotlin/markdown/KDocTest.kt @@ -4,7 +4,7 @@ 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 +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest open class KDocTest : AbstractCoreTest() { diff --git a/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt b/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt index ae5b4e06..e9605c5f 100644 --- a/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt +++ b/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt @@ -2,7 +2,7 @@ package multiplatform import org.junit.Assert.assertEquals import org.junit.Test -import testApi.testRunner.AbstractCoreTest +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest class BasicMultiplatformTest : AbstractCoreTest() { diff --git a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt index c6076d54..4b90604e 100644 --- a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt +++ b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt @@ -8,7 +8,7 @@ import org.jetbrains.dokka.base.transformers.pages.merger.SameMethodNamePageMerg import org.jetbrains.dokka.utilities.DokkaLogger import org.junit.Ignore import org.junit.Test -import testApi.testRunner.AbstractCoreTest +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest class PageNodeMergerTest : AbstractCoreTest() { diff --git a/plugins/base/src/test/kotlin/utils/ModelUtils.kt b/plugins/base/src/test/kotlin/utils/ModelUtils.kt index 6893c65f..75c8e008 100644 --- a/plugins/base/src/test/kotlin/utils/ModelUtils.kt +++ b/plugins/base/src/test/kotlin/utils/ModelUtils.kt @@ -2,7 +2,7 @@ package utils import org.jetbrains.dokka.model.Module import org.jetbrains.dokka.model.doc.DocumentationNode -import testApi.testRunner.AbstractCoreTest +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest abstract class AbstractModelTest(val path: String? = null, val pkg: String) : ModelDSL(), AssertDSL { diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index 641c68a2..6913ba5b 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -5,7 +5,7 @@ import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.Function import org.jetbrains.dokka.model.Property import org.jetbrains.dokka.model.doc.* -import testApi.testRunner.AbstractCoreTest +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import kotlin.reflect.KClass import kotlin.reflect.full.safeCast diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt index 6186283f..780f326a 100644 --- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt +++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt @@ -5,7 +5,7 @@ import org.jetbrains.dokka.pages.ContentPage import org.jetbrains.dokka.pages.ContentTable import org.jetbrains.dokka.pages.children import org.junit.Test -import testApi.testRunner.AbstractCoreTest +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest class KotlinAsJavaPluginTest : AbstractCoreTest() { diff --git a/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt b/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt index 33f0aff8..ddee7083 100644 --- a/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt +++ b/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt @@ -1,4 +1,4 @@ -package testApi.testRunner +package org.jetbrains.dokka.testApi.testRunner import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.DokkaGenerator diff --git a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt index 485567ac..4c754211 100644 --- a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt +++ b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt @@ -1,4 +1,4 @@ -package testApi.testRunner +package org.jetbrains.dokka.testApi.testRunner import org.jetbrains.dokka.* import org.jetbrains.dokka.model.Module @@ -38,7 +38,12 @@ abstract class AbstractCoreTest { configuration.copy( outputDir = tempDir.root.toPath().toAbsolutePath().toString() ) - DokkaTestGenerator(newConfiguration, logger, testMethods, pluginOverrides).generate() + DokkaTestGenerator( + newConfiguration, + logger, + testMethods, + pluginOverrides + ).generate() } protected fun testInline( @@ -61,7 +66,12 @@ abstract class AbstractCoreTest { passesConfigurations = configuration.passesConfigurations .map { it.copy(sourceRoots = it.sourceRoots.map { it.copy(path = "${testDirPath.toAbsolutePath()}/${it.path}") }) } ) - DokkaTestGenerator(newConfiguration, logger, testMethods, pluginOverrides).generate() + DokkaTestGenerator( + newConfiguration, + logger, + testMethods, + pluginOverrides + ).generate() } private fun String.toFileMap(): Map = this.trimMargin().removePrefix("|") -- cgit From 4002c4e91cb42ef77e93cac57ac49823629d33da Mon Sep 17 00:00:00 2001 From: Szymon Świstun Date: Thu, 27 Feb 2020 14:50:27 +0100 Subject: Add expect with generation --- plugins/base/src/test/kotlin/basic/DRITest.kt | 5 +- .../base/src/test/kotlin/basic/DokkaBasicTests.kt | 9 +- plugins/base/src/test/kotlin/enums/EnumsTest.kt | 20 +- .../src/test/kotlin/expect/AbstractExpectTest.kt | 104 +++ .../base/src/test/kotlin/expect/ExpectGenerator.kt | 15 + plugins/base/src/test/kotlin/expect/ExpectTest.kt | 70 +- plugins/base/src/test/kotlin/expect/ExpectUtils.kt | 28 + plugins/base/src/test/kotlin/issues/IssuesTest.kt | 2 +- plugins/base/src/test/kotlin/markdown/KDocTest.kt | 4 +- .../base/src/test/kotlin/markdown/ParserTest.kt | 761 +++++++++++++-------- plugins/base/src/test/kotlin/model/ClassesTest.kt | 6 +- plugins/base/src/test/kotlin/model/CommentTest.kt | 2 +- .../base/src/test/kotlin/model/FunctionsTest.kt | 2 +- .../base/src/test/kotlin/model/InheritorsTest.kt | 2 +- plugins/base/src/test/kotlin/model/JavaTest.kt | 6 +- plugins/base/src/test/kotlin/model/PackagesTest.kt | 2 +- plugins/base/src/test/kotlin/model/PropertyTest.kt | 2 +- .../kotlin/multiplatform/BasicMultiplatformTest.kt | 4 +- .../test/kotlin/pageMerger/PageNodeMergerTest.kt | 19 +- .../kotlin/renderers/html/GroupWrappingTest.kt | 2 +- .../renderers/html/PlatformDependentHintTest.kt | 5 +- .../expect/annotatedFunction/out/html/-search.html | 23 + .../annotatedFunction/out/html/navigation.html | 10 + .../expect/annotatedFunction/out/html/root/f.html | 20 + .../annotatedFunction/out/html/root/index.html | 31 + .../annotatedFunction/src/annotatedFunction.kt | 2 + .../out/html/-search.html | 23 + .../out/html/navigation.html | 25 + .../out/html/root/-fancy/-init-.html | 30 + .../out/html/root/-fancy/equals.html | 30 + .../out/html/root/-fancy/hash-code.html | 20 + .../out/html/root/-fancy/index.html | 61 ++ .../out/html/root/-fancy/to-string.html | 20 + .../out/html/root/f.html | 20 + .../out/html/root/index.html | 42 ++ .../annotatedFunctionWithAnnotationParameters.kt | 7 + .../expect/function/out/html/-search.html | 23 + .../expect/function/out/html/navigation.html | 10 + .../expect/function/out/html/root/fn.html | 23 + .../expect/function/out/html/root/index.html | 31 + .../test/resources/expect/function/src/function.kt | 5 + .../out/html/-search.html | 23 + .../out/html/navigation.html | 25 + .../out/html/root/-fancy/-init-.html | 20 + .../out/html/root/-fancy/equals.html | 30 + .../out/html/root/-fancy/hash-code.html | 20 + .../out/html/root/-fancy/index.html | 51 ++ .../out/html/root/-fancy/to-string.html | 20 + .../out/html/root/function.html | 30 + .../out/html/root/index.html | 42 ++ .../src/functionWithAnnotatedParam.kt | 7 + .../out/html/-search.html | 23 + .../out/html/navigation.html | 10 + .../out/html/root/f.html | 30 + .../out/html/root/index.html | 31 + .../src/functionWithDefaultParameter.kt | 1 + .../out/html/-search.html | 23 + .../out/html/navigation.html | 10 + .../out/html/root/function.html | 30 + .../out/html/root/index.html | 31 + .../src/functionWithNoinlineParam.kt | 2 + .../out/html/-search.html | 23 + .../out/html/navigation.html | 10 + .../out/html/root/f.html | 20 + .../out/html/root/index.html | 31 + .../src/functionWithNotDocumentedAnnotation.kt | 2 + .../functionWithParams/out/html/-search.html | 23 + .../functionWithParams/out/html/navigation.html | 10 + .../functionWithParams/out/html/root/function.html | 34 + .../functionWithParams/out/html/root/index.html | 31 + .../functionWithParams/src/functionWithParams.kt | 8 + .../functionWithReceiver/out/html/-search.html | 23 + .../functionWithReceiver/out/html/navigation.html | 10 + .../functionWithReceiver/out/html/root/fn.html | 38 + .../functionWithReceiver/out/html/root/index.html | 36 + .../src/functionWithReceiver.kt | 11 + .../expect/genericFunction/out/html/-search.html | 23 + .../genericFunction/out/html/navigation.html | 10 + .../genericFunction/out/html/root/generic.html | 23 + .../genericFunction/out/html/root/index.html | 31 + .../expect/genericFunction/src/genericFunction.kt | 5 + .../out/html/-search.html | 23 + .../out/html/navigation.html | 10 + .../out/html/root/generic.html | 23 + .../out/html/root/index.html | 31 + .../src/genericFunctionWithConstraints.kt | 6 + .../expect/inlineFunction/out/html/-search.html | 23 + .../expect/inlineFunction/out/html/navigation.html | 10 + .../expect/inlineFunction/out/html/root/f.html | 30 + .../expect/inlineFunction/out/html/root/index.html | 31 + .../expect/inlineFunction/src/inlineFunction.kt | 2 + .../inlineSuspendFunction/out/html/-search.html | 23 + .../inlineSuspendFunction/out/html/navigation.html | 10 + .../inlineSuspendFunction/out/html/root/f.html | 30 + .../inlineSuspendFunction/out/html/root/index.html | 31 + .../src/inlineSuspendFunction.kt | 2 + .../expect/sinceKotlin/out/html/-search.html | 23 + .../expect/sinceKotlin/out/html/navigation.html | 10 + .../out/html/root/available-since1.1.html | 23 + .../expect/sinceKotlin/out/html/root/index.html | 31 + .../expect/sinceKotlin/src/sinceKotlin.kt | 5 + .../expect/suspendFunction/out/html/-search.html | 23 + .../suspendFunction/out/html/navigation.html | 10 + .../expect/suspendFunction/out/html/root/f.html | 20 + .../suspendFunction/out/html/root/index.html | 31 + .../expect/suspendFunction/src/suspendFunction.kt | 2 + .../suspendInlineFunction/out/html/-search.html | 23 + .../suspendInlineFunction/out/html/navigation.html | 10 + .../suspendInlineFunction/out/html/root/f.html | 30 + .../suspendInlineFunction/out/html/root/index.html | 31 + .../src/suspendInlineFunction.kt | 2 + .../test/resources/expect/test/out/-search.html | 23 - .../expect/test/out/images/arrow_down.svg | 3 - .../resources/expect/test/out/images/logo-icon.svg | 3 - .../resources/expect/test/out/images/logo-text.svg | 6 - .../test/resources/expect/test/out/navigation.html | 10 - .../test/resources/expect/test/out/root/fn.html | 23 - .../test/resources/expect/test/out/root/index.html | 31 - .../expect/test/out/scripts/navigationLoader.js | 12 - .../resources/expect/test/out/scripts/pages.js | 5 - .../resources/expect/test/out/scripts/scripts.js | 11 - .../resources/expect/test/out/scripts/search.js | 5 - .../resources/expect/test/out/styles/style.css | 353 ---------- .../src/test/resources/expect/test/src/function.kt | 5 - plugins/build.gradle.kts | 10 +- .../src/test/kotlin/KotlinAsJavaPluginTest.kt | 2 +- 126 files changed, 2563 insertions(+), 885 deletions(-) create mode 100644 plugins/base/src/test/kotlin/expect/AbstractExpectTest.kt create mode 100644 plugins/base/src/test/kotlin/expect/ExpectGenerator.kt create mode 100644 plugins/base/src/test/kotlin/expect/ExpectUtils.kt create mode 100644 plugins/base/src/test/resources/expect/annotatedFunction/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/annotatedFunction/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/f.html create mode 100644 plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/annotatedFunction/src/annotatedFunction.kt create mode 100644 plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/-init-.html create mode 100644 plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/equals.html create mode 100644 plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/hash-code.html create mode 100644 plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/index.html create mode 100644 plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/to-string.html create mode 100644 plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/f.html create mode 100644 plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/src/annotatedFunctionWithAnnotationParameters.kt create mode 100644 plugins/base/src/test/resources/expect/function/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/function/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/function/out/html/root/fn.html create mode 100644 plugins/base/src/test/resources/expect/function/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/function/src/function.kt create mode 100644 plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/-init-.html create mode 100644 plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/equals.html create mode 100644 plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/hash-code.html create mode 100644 plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/index.html create mode 100644 plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/to-string.html create mode 100644 plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/function.html create mode 100644 plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/functionWithAnnotatedParam/src/functionWithAnnotatedParam.kt create mode 100644 plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/f.html create mode 100644 plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/functionWithDefaultParameter/src/functionWithDefaultParameter.kt create mode 100644 plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/function.html create mode 100644 plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/functionWithNoinlineParam/src/functionWithNoinlineParam.kt create mode 100644 plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/f.html create mode 100644 plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/src/functionWithNotDocumentedAnnotation.kt create mode 100644 plugins/base/src/test/resources/expect/functionWithParams/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/functionWithParams/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/functionWithParams/out/html/root/function.html create mode 100644 plugins/base/src/test/resources/expect/functionWithParams/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/functionWithParams/src/functionWithParams.kt create mode 100644 plugins/base/src/test/resources/expect/functionWithReceiver/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/functionWithReceiver/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/fn.html create mode 100644 plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/functionWithReceiver/src/functionWithReceiver.kt create mode 100644 plugins/base/src/test/resources/expect/genericFunction/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/genericFunction/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/genericFunction/out/html/root/generic.html create mode 100644 plugins/base/src/test/resources/expect/genericFunction/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/genericFunction/src/genericFunction.kt create mode 100644 plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/generic.html create mode 100644 plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/genericFunctionWithConstraints/src/genericFunctionWithConstraints.kt create mode 100644 plugins/base/src/test/resources/expect/inlineFunction/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/inlineFunction/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/inlineFunction/out/html/root/f.html create mode 100644 plugins/base/src/test/resources/expect/inlineFunction/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/inlineFunction/src/inlineFunction.kt create mode 100644 plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/f.html create mode 100644 plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/inlineSuspendFunction/src/inlineSuspendFunction.kt create mode 100644 plugins/base/src/test/resources/expect/sinceKotlin/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/sinceKotlin/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/available-since1.1.html create mode 100644 plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/sinceKotlin/src/sinceKotlin.kt create mode 100644 plugins/base/src/test/resources/expect/suspendFunction/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/suspendFunction/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/suspendFunction/out/html/root/f.html create mode 100644 plugins/base/src/test/resources/expect/suspendFunction/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/suspendFunction/src/suspendFunction.kt create mode 100644 plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/-search.html create mode 100644 plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/navigation.html create mode 100644 plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/f.html create mode 100644 plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/index.html create mode 100644 plugins/base/src/test/resources/expect/suspendInlineFunction/src/suspendInlineFunction.kt delete mode 100644 plugins/base/src/test/resources/expect/test/out/-search.html delete mode 100644 plugins/base/src/test/resources/expect/test/out/images/arrow_down.svg delete mode 100644 plugins/base/src/test/resources/expect/test/out/images/logo-icon.svg delete mode 100644 plugins/base/src/test/resources/expect/test/out/images/logo-text.svg delete mode 100644 plugins/base/src/test/resources/expect/test/out/navigation.html delete mode 100644 plugins/base/src/test/resources/expect/test/out/root/fn.html delete mode 100644 plugins/base/src/test/resources/expect/test/out/root/index.html delete mode 100644 plugins/base/src/test/resources/expect/test/out/scripts/navigationLoader.js delete mode 100644 plugins/base/src/test/resources/expect/test/out/scripts/pages.js delete mode 100644 plugins/base/src/test/resources/expect/test/out/scripts/scripts.js delete mode 100644 plugins/base/src/test/resources/expect/test/out/scripts/search.js delete mode 100644 plugins/base/src/test/resources/expect/test/out/styles/style.css delete mode 100644 plugins/base/src/test/resources/expect/test/src/function.kt (limited to 'plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt') diff --git a/plugins/base/src/test/kotlin/basic/DRITest.kt b/plugins/base/src/test/kotlin/basic/DRITest.kt index ca8e4bad..0e1f095e 100644 --- a/plugins/base/src/test/kotlin/basic/DRITest.kt +++ b/plugins/base/src/test/kotlin/basic/DRITest.kt @@ -3,10 +3,11 @@ 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 org.junit.jupiter.api.Assertions.assertEquals import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.junit.jupiter.api.Test + class DRITest : AbstractCoreTest() { @Test fun `#634`() { diff --git a/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt b/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt index 0405b91c..dae1b2be 100644 --- a/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt +++ b/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt @@ -2,7 +2,8 @@ package basic import org.jetbrains.dokka.pages.ClasslikePageNode import org.jetbrains.dokka.pages.ModulePageNode -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Test import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest class DokkaBasicTests : AbstractCoreTest() { @@ -31,11 +32,11 @@ class DokkaBasicTests : AbstractCoreTest() { ) { pagesGenerationStage = { println(it.dri) - assert(it.getClasslikeToMemberMap().filterKeys { it.name == "Test" }.entries.firstOrNull()?.value?.size == 5) + assertTrue(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} + private 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 index 34e92d82..55ad0fbc 100644 --- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -3,9 +3,9 @@ package enums import org.jetbrains.dokka.model.DEnum import org.jetbrains.dokka.pages.ClasslikePageNode import org.jetbrains.dokka.pages.ModulePageNode -import org.junit.Assert.* -import org.junit.Test +import org.junit.jupiter.api.Test import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.junit.jupiter.api.Assertions.* class EnumsTest : AbstractCoreTest() { @@ -65,11 +65,11 @@ class EnumsTest : AbstractCoreTest() { configuration ) { documentablesCreationStage = {m -> - assertTrue("Module list cannot be empty", m.isNotEmpty()) + assertTrue(m.isNotEmpty(), "Module list cannot be empty") m.first().packages.let { p -> - assertTrue("Package list cannot be empty", p.isNotEmpty()) + assertTrue(p.isNotEmpty(), "Package list cannot be empty") p.first().classlikes.let { c -> - assertTrue("Classlikes list cannot be empty", c.isNotEmpty()) + assertTrue(c.isNotEmpty(), "Classlikes list cannot be empty") val enum = c.first() as DEnum assertEquals(enum.name, "Test") @@ -78,12 +78,12 @@ class EnumsTest : AbstractCoreTest() { } } } - pagesGenerationStage = { - val map = it.getClasslikeToMemberMap() + pagesGenerationStage = { module -> + val map = module.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" } + assertNotNull(test, "Test not found") + assertTrue(test!!.any { it.name == "E1" } && test.any { it.name == "E2" }) { "Enum entries missing in parent" } + assertTrue(map.keys.any { it.name == "E1" } && map.keys.any { it.name == "E2" }) { "Enum entries missing" } } } } diff --git a/plugins/base/src/test/kotlin/expect/AbstractExpectTest.kt b/plugins/base/src/test/kotlin/expect/AbstractExpectTest.kt new file mode 100644 index 00000000..ef97b04c --- /dev/null +++ b/plugins/base/src/test/kotlin/expect/AbstractExpectTest.kt @@ -0,0 +1,104 @@ +package expect + +import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.junit.jupiter.api.Assertions.assertTrue +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths +import java.util.concurrent.TimeUnit + +abstract class AbstractExpectTest( + val testDir: Path? = Paths.get("src/test", "resources", "expect"), + val formats: List = listOf("html") +) : AbstractCoreTest() { + + protected fun generateOutput(path: Path, outFormat: String): Path? { + val config = dokkaConfiguration { + format = outFormat + passes { + pass { + sourceRoots = listOf(path.asString()) + } + } + } + + var result: Path? = null + testFromData(config, cleanupOutput = false) { + renderingStage = { _, context -> result = Paths.get(context.configuration.outputDir) } + } + return result + } + + protected fun compareOutput(expected: Path, obtained: Path?, gitTimeout: Long = 500) { + obtained?.let { path -> + val gitCompare = ProcessBuilder( + "git", + "--no-pager", + "diff", + expected.asString(), + path.asString() + ).also { logger.info("git diff command: ${it.command().joinToString(" ")}") } + .also { it.redirectErrorStream() }.start() + + assertTrue(gitCompare.waitFor(gitTimeout, TimeUnit.MILLISECONDS)) { "Git timed out after $gitTimeout" } + gitCompare.inputStream.bufferedReader().lines().forEach { logger.info(it) } + assertTrue(gitCompare.exitValue() == 0) { "${path.fileName}: outputs don't match" } + } ?: throw AssertionError("obtained path is null") + } + + protected fun compareOutputWithExcludes( + expected: Path, + obtained: Path?, + excludes: List, + timeout: Long = 500 + ) { + obtained?.let { path -> + val (res, out, err) = runDiff(expected, obtained, excludes, timeout) + assertTrue(res == 0, "Outputs differ:\nstdout - $out\n\nstderr - ${err ?: ""}") + } ?: throw AssertionError("obtained path is null") + } + + protected fun runDiff(exp: Path, obt: Path, excludes: List, timeout: Long): ProcessResult = + ProcessBuilder().command( + listOf("diff", "-ru") + excludes.flatMap { listOf("-x", it) } + listOf("--", exp.asString(), obt.asString()) + ).also { + it.redirectErrorStream() + }.start().also { assertTrue(it.waitFor(timeout, TimeUnit.MILLISECONDS), "diff timed out") }.let { + ProcessResult(it.exitValue(), it.inputStream.bufferResult()) + } + + + protected fun testOutput(p: Path, outFormat: String) { + val expectOut = p.resolve("out/$outFormat") + val testOut = generateOutput(p.resolve("src"), outFormat) + .also { logger.info("Test out: ${it?.asString()}") } + + compareOutput(expectOut.toAbsolutePath(), testOut?.toAbsolutePath()) + testOut?.deleteRecursively() + } + + protected fun testOutputWithExcludes( + p: Path, + outFormat: String, + ignores: List = emptyList(), + timeout: Long = 500 + ) { + val expected = p.resolve("out/$outFormat") + generateOutput(p.resolve("src"), outFormat) + ?.let { obtained -> + compareOutputWithExcludes(expected, obtained, ignores, timeout) + + obtained.deleteRecursively() + } ?: throw AssertionError("Output not generated for ${p.fileName}") + } + + protected fun generateExpect(p: Path, outFormat: String) { + val out = p.resolve("out/$outFormat/") + Files.createDirectories(out) + + val ret = generateOutput(p.resolve("src"), outFormat) + Files.list(out).forEach { it.deleteRecursively() } + ret?.let { Files.list(it).forEach { f -> f.copyRecursively(out.resolve(f.fileName)) } } + } + +} \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/expect/ExpectGenerator.kt b/plugins/base/src/test/kotlin/expect/ExpectGenerator.kt new file mode 100644 index 00000000..667fc249 --- /dev/null +++ b/plugins/base/src/test/kotlin/expect/ExpectGenerator.kt @@ -0,0 +1,15 @@ +package expect + +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import java.nio.file.Files +import java.nio.file.Path + +class ExpectGenerator : AbstractExpectTest() { + + @Disabled + @Test + fun generateAll() = testDir?.dirsWithFormats(formats).orEmpty().forEach { (p, f) -> + generateExpect(p, f) + } +} \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/expect/ExpectTest.kt b/plugins/base/src/test/kotlin/expect/ExpectTest.kt index c6c252ed..0423a5b4 100644 --- a/plugins/base/src/test/kotlin/expect/ExpectTest.kt +++ b/plugins/base/src/test/kotlin/expect/ExpectTest.kt @@ -1,62 +1,18 @@ package expect -import org.junit.Test -import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths -import java.util.concurrent.TimeUnit - -class ExpectTest : AbstractCoreTest() { - - private fun generateOutput(path: Path): Path? { - val config = dokkaConfiguration { - passes { - pass { - sourceRoots = listOf(path.asString()) - } - } - } - - var result: Path? = null - testFromData(config, cleanupOutput = false) { - renderingStage = { _, context -> result = Paths.get(context.configuration.outputDir) } - } - return result - } - - private fun compareOutput(expected: Path, obtained: Path?, gitTimeout: Long = 500) { - obtained?.let { path -> - val gitCompare = ProcessBuilder( - "git", - "--no-pager", - "diff", - expected.asString(), - path.asString() - ).also { logger.info("git diff command: ${it.command().joinToString(" ")}") } - .start() - - assert(gitCompare.waitFor(gitTimeout, TimeUnit.MILLISECONDS)) { "Git timed out after $gitTimeout" } - gitCompare.inputStream.bufferedReader().lines().forEach { logger.info(it) } - gitCompare.errorStream.bufferedReader().lines().forEach { logger.info(it) } - assert(gitCompare.exitValue() == 0) { "${path.fileName}: outputs don't match" } - } ?: throw AssertionError("obtained path is null") +import org.junit.jupiter.api.DynamicTest.dynamicTest +import org.junit.jupiter.api.TestFactory + +class ExpectTest : AbstractExpectTest() { + private val ignores: List = listOf( + "*.js", + "*.css", + "*.svg" + ) + + @TestFactory + fun expectTest() = testDir?.dirsWithFormats(formats).orEmpty().map { (p, f) -> + dynamicTest("${p.fileName}-$f") { testOutputWithExcludes(p, f, ignores) } } - @Test - fun expectTest() { - val sources = Paths.get("src/test", "resources", "expect") - - Files.list(sources).forEach { p -> - val expectOut = p.resolve("out") - val testOut = generateOutput(p.resolve("src")) - .also { logger.info("Test out: ${it?.asString()}") } - - compareOutput(expectOut, testOut) - testOut?.toFile()?.deleteRecursively() - } - } - - fun Path.asString() = toAbsolutePath().normalize().toString() - } \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/expect/ExpectUtils.kt b/plugins/base/src/test/kotlin/expect/ExpectUtils.kt new file mode 100644 index 00000000..4ea46dda --- /dev/null +++ b/plugins/base/src/test/kotlin/expect/ExpectUtils.kt @@ -0,0 +1,28 @@ +package expect + +import java.io.InputStream +import java.nio.file.Files +import java.nio.file.Path +import kotlin.streams.toList + +data class ProcessResult(val code: Int, val out: String, val err: String? = null) + +internal fun Path.dirsWithFormats(formats: List): List> = + Files.list(this).toList().flatMap { p -> formats.map { p to it } } + +internal fun Path.asString() = normalize().toString() +internal fun Path.deleteRecursively() = toFile().deleteRecursively() + +internal fun Path.copyRecursively(target: Path) = toFile().copyRecursively(target.toFile()) + +internal fun Path.listRecursively(filter: (Path) -> Boolean): List = when { + Files.isDirectory(this) -> listOfNotNull(takeIf(filter)) + Files.list(this).toList().flatMap { + it.listRecursively( + filter + ) + } + Files.isRegularFile(this) -> listOfNotNull(this.takeIf(filter)) + else -> emptyList() + } + +internal fun InputStream.bufferResult(): String = this.bufferedReader().lines().toList().joinToString("\n") \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/issues/IssuesTest.kt b/plugins/base/src/test/kotlin/issues/IssuesTest.kt index 1ad7a97b..41fc2632 100644 --- a/plugins/base/src/test/kotlin/issues/IssuesTest.kt +++ b/plugins/base/src/test/kotlin/issues/IssuesTest.kt @@ -2,7 +2,7 @@ package issues import org.jetbrains.dokka.model.DClass import org.jetbrains.dokka.model.DFunction -import org.junit.Test +import org.junit.jupiter.api.Test import utils.AbstractModelTest import utils.name diff --git a/plugins/base/src/test/kotlin/markdown/KDocTest.kt b/plugins/base/src/test/kotlin/markdown/KDocTest.kt index fa538c3e..a904f725 100644 --- a/plugins/base/src/test/kotlin/markdown/KDocTest.kt +++ b/plugins/base/src/test/kotlin/markdown/KDocTest.kt @@ -3,7 +3,7 @@ package markdown import org.jetbrains.dokka.model.DPackage import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.pages.ModulePageNode -import org.junit.Assert +import org.junit.jupiter.api.Assertions.* import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest open class KDocTest : AbstractCoreTest() { @@ -37,7 +37,7 @@ open class KDocTest : AbstractCoreTest() { configuration ) { pagesGenerationStage = { - Assert.assertEquals( + assertEquals( expectedDocumentationNode, actualDocumentationNode(it) ) diff --git a/plugins/base/src/test/kotlin/markdown/ParserTest.kt b/plugins/base/src/test/kotlin/markdown/ParserTest.kt index dee8e907..332c9766 100644 --- a/plugins/base/src/test/kotlin/markdown/ParserTest.kt +++ b/plugins/base/src/test/kotlin/markdown/ParserTest.kt @@ -2,13 +2,14 @@ package org.jetbrains.dokka.tests import markdown.KDocTest import org.jetbrains.dokka.model.doc.* -import org.junit.Ignore -import org.junit.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test class ParserTest : KDocTest() { - @Test fun `Simple text`() { + @Test + fun `Simple text`() { val kdoc = """ | This is simple test of string | Next line @@ -23,7 +24,8 @@ class ParserTest : KDocTest() { executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Simple text with new line`() { + @Test + fun `Simple text with new line`() { val kdoc = """ | This is simple test of string\ | Next line @@ -31,18 +33,21 @@ class ParserTest : KDocTest() { val expectedDocumentationNode = DocumentationNode( listOf( Description( - P(listOf( - Text("This is simple test of string"), - Br, - Text("Next line") - )) + P( + listOf( + Text("This is simple test of string"), + Br, + Text("Next line") + ) + ) ) ) ) executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Text with Bold and Emphasis decorators`() { + @Test + fun `Text with Bold and Emphasis decorators`() { val kdoc = """ | This is **simple** test of _string_ | Next **_line_** @@ -66,7 +71,8 @@ class ParserTest : KDocTest() { executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Text with Colon`() { + @Test + fun `Text with Colon`() { val kdoc = """ | This is simple text with: colon! """.trimMargin() @@ -80,7 +86,8 @@ class ParserTest : KDocTest() { executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Multilined text`() { + @Test + fun `Multilined text`() { val kdoc = """ | Text | and @@ -96,7 +103,8 @@ class ParserTest : KDocTest() { executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Paragraphs`() { + @Test + fun `Paragraphs`() { val kdoc = """ | Paragraph number | one @@ -119,7 +127,8 @@ class ParserTest : KDocTest() { executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Emphasis with star`() { + @Test + fun `Emphasis with star`() { val kdoc = " *text*" val expectedDocumentationNode = DocumentationNode( listOf( @@ -131,7 +140,8 @@ class ParserTest : KDocTest() { executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Underscores that are not Emphasis`() { + @Test + fun `Underscores that are not Emphasis`() { val kdoc = "text_with_underscores" val expectedDocumentationNode = DocumentationNode( listOf( @@ -143,7 +153,8 @@ class ParserTest : KDocTest() { executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Emphasis with underscores`() { + @Test + fun `Emphasis with underscores`() { val kdoc = "_text_" val expectedDocumentationNode = DocumentationNode( listOf( @@ -155,7 +166,8 @@ class ParserTest : KDocTest() { executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Embedded star`() { + @Test + fun `Embedded star`() { val kdoc = "Embedded*Star" val expectedDocumentationNode = DocumentationNode( listOf( @@ -168,7 +180,8 @@ class ParserTest : KDocTest() { } - @Test fun `Unordered list`() { + @Test + fun `Unordered list`() { val kdoc = """ | * list item 1 | * list item 2 @@ -188,7 +201,8 @@ class ParserTest : KDocTest() { executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Unordered list with multilines`() { + @Test + fun `Unordered list with multilines`() { val kdoc = """ | * list item 1 | continue 1 @@ -210,7 +224,8 @@ class ParserTest : KDocTest() { executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Unordered list with Bold`() { + @Test + fun `Unordered list with Bold`() { val kdoc = """ | * list **item** 1 | continue 1 @@ -220,25 +235,40 @@ class ParserTest : KDocTest() { 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") - )))) - )) + 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`() { + @Test + fun `Unordered list with nested bullets`() { val kdoc = """ | * Outer first | Outer next line @@ -255,29 +285,38 @@ class ParserTest : KDocTest() { 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"))) - )) + 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`() { + @Test + fun `Ordered list`() { val kdoc = """ | 1. list item 1 | 2. list item 2 @@ -299,7 +338,8 @@ class ParserTest : KDocTest() { } - @Test fun `Ordered list beginning from other number`() { + @Test + fun `Ordered list beginning from other number`() { val kdoc = """ | 9. list item 1 | 12. list item 2 @@ -320,7 +360,8 @@ class ParserTest : KDocTest() { executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Ordered list with multilines`() { + @Test + fun `Ordered list with multilines`() { val kdoc = """ | 2. list item 1 | continue 1 @@ -343,7 +384,8 @@ class ParserTest : KDocTest() { executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Ordered list with Bold`() { + @Test + fun `Ordered list with Bold`() { val kdoc = """ | 1. list **item** 1 | continue 1 @@ -353,17 +395,30 @@ class ParserTest : KDocTest() { 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") - )))) + 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") ) @@ -373,7 +428,8 @@ class ParserTest : KDocTest() { executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Ordered list with nested bullets`() { + @Test + fun `Ordered list with nested bullets`() { val kdoc = """ | 1. Outer first | Outer next line @@ -390,35 +446,41 @@ class ParserTest : KDocTest() { 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"))))) + 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") ), - mapOf("start" to "1") - ), - Li(listOf(P(listOf(Text("Middle third"))))) + Li(listOf(P(listOf(Text("Outer third"))))) ), mapOf("start" to "1") ), - Li(listOf(P(listOf(Text("Outer third"))))) - ), - mapOf("start" to "1") - ), - P(listOf(Text("New paragraph"))) - )) + P(listOf(Text("New paragraph"))) + ) + ) ) ) ) executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Ordered nested in Unordered nested in Ordered list`() { + @Test + fun `Ordered nested in Unordered nested in Ordered list`() { val kdoc = """ | 1. Outer first | Outer next line @@ -435,33 +497,40 @@ class ParserTest : KDocTest() { 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") + 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"))))) ), - Li(listOf(P(listOf(Text("Middle third"))))) - )), - Li(listOf(P(listOf(Text("Outer third"))))) - ), - mapOf("start" to "1") - ), - P(listOf(Text("New paragraph"))) - )) + mapOf("start" to "1") + ), + P(listOf(Text("New paragraph"))) + ) + ) ) ) ) executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Header and two paragraphs`() { + @Test + fun `Header and two paragraphs`() { val kdoc = """ | # Header 1 | Following text @@ -471,19 +540,22 @@ class ParserTest : KDocTest() { val expectedDocumentationNode = DocumentationNode( listOf( Description( - P(listOf( - H1(listOf(Text("Header 1"))), - P(listOf(Text("Following text"))), - P(listOf(Text("New paragraph"))) - )) + 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`() { + @Disabled //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 @@ -501,27 +573,30 @@ class ParserTest : KDocTest() { 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"))) - )) + 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`() { + @Test + fun `Bold New Line Bold`() { val kdoc = """ | **line 1**\ | **line 2** @@ -529,18 +604,21 @@ class ParserTest : KDocTest() { val expectedDocumentationNode = DocumentationNode( listOf( Description( - P(listOf( - B(listOf(Text("line 1"))), - Br, - B(listOf(Text("line 2"))) - )) + P( + listOf( + B(listOf(Text("line 1"))), + Br, + B(listOf(Text("line 2"))) + ) + ) ) ) ) executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Horizontal rule`() { + @Test + fun `Horizontal rule`() { val kdoc = """ | *** | text 1 @@ -555,24 +633,27 @@ class ParserTest : KDocTest() { 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 - )) + 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`() { + @Test + fun `Blockquote`() { val kdoc = """ | > Blockquotes are very handy in email to emulate reply text. | > This line is part of the same quote. @@ -584,17 +665,25 @@ class ParserTest : KDocTest() { 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"))) - )) - )) + 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"))) + ) + ) + ) + ) ) ) ) @@ -602,7 +691,8 @@ class ParserTest : KDocTest() { } - @Test fun `Blockquote nested`() { + @Test + fun `Blockquote nested`() { val kdoc = """ | > text 1 | > text 2 @@ -618,27 +708,36 @@ class ParserTest : KDocTest() { 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"))) - )) - )) + 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`() { + @Disabled //TODO: Again ATX_1 consumes white space + @Test + fun `Blockquote nested with fancy text enhancement`() { val kdoc = """ | > text **1** | > text 2 @@ -655,36 +754,51 @@ class ParserTest : KDocTest() { 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"))) - )) - )) + 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`() { + @Test + fun `Simple Code Block`() { val kdoc = """ | `Some code` | Sample text @@ -692,17 +806,20 @@ class ParserTest : KDocTest() { val expectedDocumentationNode = DocumentationNode( listOf( Description( - P(listOf( - Code(listOf(Text("Some code"))), - Text(" Sample text") - )) + P( + listOf( + Code(listOf(Text("Some code"))), + Text(" Sample text") + ) + ) ) ) ) executeTest(kdoc, expectedDocumentationNode) } - @Test fun `Multilined Code Block`() { + @Test + fun `Multilined Code Block`() { val kdoc = """ | ```kotlin | val x: Int = 0 @@ -718,20 +835,22 @@ class ParserTest : KDocTest() { 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("}") + 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") ), - mapOf("lang" to "kotlin") - ), - P(listOf(Text("Sample text"))) - )) + P(listOf(Text("Sample text"))) + ) + ) ) ) ) @@ -739,41 +858,52 @@ class ParserTest : KDocTest() { } - @Test fun `Inline link`() { + @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") - ))) + 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`() { + @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") - ))) + 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`() { + @Test + fun `Full reference link`() { val kdoc = """ | [I'm a reference-style link][Arbitrary case-insensitive reference text] | @@ -782,17 +912,26 @@ class ParserTest : KDocTest() { 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") - ))))) + 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`() { + @Test + fun `Full reference link with number`() { val kdoc = """ | [You can use numbers for reference-style link definitions][1] | @@ -801,17 +940,26 @@ class ParserTest : KDocTest() { 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") - ))))) + 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`() { + @Test + fun `Short reference link`() { val kdoc = """ | Or leave it empty and use the [link text itself]. | @@ -820,21 +968,28 @@ class ParserTest : KDocTest() { 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(".") - )))) + 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`() { + @Test + fun `Autolink`() { val kdoc = """ | URLs and URLs in angle brackets will automatically get turned into links. | http://www.example.com or and sometimes @@ -843,21 +998,24 @@ class ParserTest : KDocTest() { 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).") - )) + 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`() { + @Test + fun `Various links`() { val kdoc = """ | [I'm an inline-style link](https://www.google.com) | @@ -882,55 +1040,80 @@ class ParserTest : KDocTest() { 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") + P( + listOf( + P( + listOf( + A( + listOf(Text("I'm an inline-style link")), + mapOf("href" to "https://www.google.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") + 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") + ) + ) ), - 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."))) - )) + 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`() { + @Test + fun `Windows Carriage Return Line Feed`() { val kdoc = "text\r\ntext" val expectedDocumentationNode = DocumentationNode( listOf( Description( - P(listOf( - Text("text text") - )) + P( + listOf( + Text("text text") + ) + ) ) ) ) diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt index 4855056c..2f83d8c0 100644 --- a/plugins/base/src/test/kotlin/model/ClassesTest.kt +++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt @@ -1,9 +1,9 @@ package model import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.KotlinModifier.* import org.jetbrains.dokka.model.DFunction -import org.junit.Test +import org.jetbrains.dokka.model.KotlinModifier.* +import org.junit.jupiter.api.Test import utils.AbstractModelTest import utils.assertNotNull import utils.name @@ -151,7 +151,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class name equals "Klass" visibility.values allEquals KotlinVisibility.Public with(extra[AdditionalModifiers.AdditionalKey].assertNotNull("Extras")) { - content.find{it == ExtraModifiers.DATA}.assertNotNull("data modifier") + content.find { it == ExtraModifiers.DATA }.assertNotNull("data modifier") } } } diff --git a/plugins/base/src/test/kotlin/model/CommentTest.kt b/plugins/base/src/test/kotlin/model/CommentTest.kt index 055892af..b1faa07f 100644 --- a/plugins/base/src/test/kotlin/model/CommentTest.kt +++ b/plugins/base/src/test/kotlin/model/CommentTest.kt @@ -3,7 +3,7 @@ package model import org.jetbrains.dokka.model.DProperty import org.jetbrains.dokka.model.doc.CustomWrapperTag import org.jetbrains.dokka.model.doc.Text -import org.junit.Test +import org.junit.jupiter.api.Test import utils.* class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comment") { diff --git a/plugins/base/src/test/kotlin/model/FunctionsTest.kt b/plugins/base/src/test/kotlin/model/FunctionsTest.kt index 97d6b237..c8b8f2ba 100644 --- a/plugins/base/src/test/kotlin/model/FunctionsTest.kt +++ b/plugins/base/src/test/kotlin/model/FunctionsTest.kt @@ -2,7 +2,7 @@ package model import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.model.DPackage -import org.junit.Test +import org.junit.jupiter.api.Test import utils.* class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "function") { diff --git a/plugins/base/src/test/kotlin/model/InheritorsTest.kt b/plugins/base/src/test/kotlin/model/InheritorsTest.kt index b3d7bf92..da128803 100644 --- a/plugins/base/src/test/kotlin/model/InheritorsTest.kt +++ b/plugins/base/src/test/kotlin/model/InheritorsTest.kt @@ -7,7 +7,7 @@ import org.jetbrains.dokka.base.transformers.documentables.InheritorsInfo import org.jetbrains.dokka.model.DInterface import org.jetbrains.dokka.model.DPackage import org.jetbrains.dokka.plugability.DokkaPlugin -import org.junit.Test +import org.junit.jupiter.api.Test import utils.AbstractModelTest import utils.assertNotNull diff --git a/plugins/base/src/test/kotlin/model/JavaTest.kt b/plugins/base/src/test/kotlin/model/JavaTest.kt index 1e33d6fd..c6d111a4 100644 --- a/plugins/base/src/test/kotlin/model/JavaTest.kt +++ b/plugins/base/src/test/kotlin/model/JavaTest.kt @@ -3,8 +3,8 @@ package model import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.DEnum import org.jetbrains.dokka.model.DFunction -import org.junit.Assert.assertTrue -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Test import utils.AbstractModelTest import utils.assertNotNull import utils.name @@ -112,8 +112,8 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { with((this / "java" / "Foo").cast()) { val sups = listOf("Exception", "Cloneable") assertTrue( - "Foo must extend ${sups.joinToString(", ")}", sups.all { s -> supertypes.map.values.flatten().any { it.classNames == s } }) + "Foo must extend ${sups.joinToString(", ")}" } } } diff --git a/plugins/base/src/test/kotlin/model/PackagesTest.kt b/plugins/base/src/test/kotlin/model/PackagesTest.kt index 008ae14d..8885dae0 100644 --- a/plugins/base/src/test/kotlin/model/PackagesTest.kt +++ b/plugins/base/src/test/kotlin/model/PackagesTest.kt @@ -1,7 +1,7 @@ package model import org.jetbrains.dokka.model.DPackage -import org.junit.Test +import org.junit.jupiter.api.Test import utils.AbstractModelTest class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "packages") { diff --git a/plugins/base/src/test/kotlin/model/PropertyTest.kt b/plugins/base/src/test/kotlin/model/PropertyTest.kt index 4af4ee5a..f391df4e 100644 --- a/plugins/base/src/test/kotlin/model/PropertyTest.kt +++ b/plugins/base/src/test/kotlin/model/PropertyTest.kt @@ -3,7 +3,7 @@ package model import org.jetbrains.dokka.model.KotlinVisibility import org.jetbrains.dokka.model.DPackage import org.jetbrains.dokka.model.DProperty -import org.junit.Test +import org.junit.jupiter.api.Test import utils.AbstractModelTest import utils.assertNotNull import utils.name diff --git a/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt b/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt index e9605c5f..0111e8fb 100644 --- a/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt +++ b/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt @@ -1,7 +1,7 @@ package multiplatform -import org.junit.Assert.assertEquals -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest class BasicMultiplatformTest : AbstractCoreTest() { diff --git a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt index 4b90604e..15dc5581 100644 --- a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt +++ b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt @@ -1,13 +1,10 @@ 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.base.transformers.pages.merger.SameMethodNamePageMergerStrategy -import org.jetbrains.dokka.utilities.DokkaLogger -import org.junit.Ignore -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest class PageNodeMergerTest : AbstractCoreTest() { @@ -70,16 +67,16 @@ class PageNodeMergerTest : AbstractCoreTest() { 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}" } + assertTrue(testT.size == 1) { "There can be only one testT page" } + assertTrue(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}" } + assertTrue(test.size == 1) { "There can be only one test page" } + assertTrue(test.first().dri.size == 2) { "test page should have 2 DRI, but has ${test.first().dri.size}" } } } } - @Ignore("TODO: reenable when we have infrastructure for turning off extensions") + @Disabled("TODO: reenable when we have infrastructure for turning off extensions") @Test fun defaultStrategyTest() { val strList: MutableList = mutableListOf() diff --git a/plugins/base/src/test/kotlin/renderers/html/GroupWrappingTest.kt b/plugins/base/src/test/kotlin/renderers/html/GroupWrappingTest.kt index e98b97c0..f39d845a 100644 --- a/plugins/base/src/test/kotlin/renderers/html/GroupWrappingTest.kt +++ b/plugins/base/src/test/kotlin/renderers/html/GroupWrappingTest.kt @@ -2,7 +2,7 @@ package renderers.html import org.jetbrains.dokka.base.renderers.html.HtmlRenderer import org.jetbrains.dokka.pages.TextStyle -import org.junit.Test +import org.junit.jupiter.api.Test import renderers.RenderingOnlyTestBase import renderers.TestPage diff --git a/plugins/base/src/test/kotlin/renderers/html/PlatformDependentHintTest.kt b/plugins/base/src/test/kotlin/renderers/html/PlatformDependentHintTest.kt index 2fda1ee1..f1d50007 100644 --- a/plugins/base/src/test/kotlin/renderers/html/PlatformDependentHintTest.kt +++ b/plugins/base/src/test/kotlin/renderers/html/PlatformDependentHintTest.kt @@ -3,13 +3,12 @@ package renderers.html import org.jetbrains.dokka.Platform import org.jetbrains.dokka.base.renderers.html.HtmlRenderer import org.jetbrains.dokka.pages.PlatformData -import org.jetbrains.dokka.pages.Style import org.jetbrains.dokka.pages.TextStyle -import org.junit.Test +import org.junit.jupiter.api.Test import renderers.RenderingOnlyTestBase import renderers.TestPage -class PlatformDependentHintTest: RenderingOnlyTestBase() { +class PlatformDependentHintTest : RenderingOnlyTestBase() { private val pl1 = PlatformData("pl1", Platform.js, listOf("pl1")) private val pl2 = PlatformData("pl2", Platform.jvm, listOf("pl2")) private val pl3 = PlatformData("pl3", Platform.native, listOf("pl3")) diff --git a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/-search.html b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/navigation.html b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/navigation.html new file mode 100644 index 00000000..ad2005c3 --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/navigation.html @@ -0,0 +1,10 @@ + + diff --git a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/f.html b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/f.html new file mode 100644 index 00000000..7900fb98 --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/f.html @@ -0,0 +1,20 @@ + + + f + + + + + + +
//root//f +

f

+final fun f()
+ + + diff --git a/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/index.html b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/index.html new file mode 100644 index 00000000..867d7faa --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunction/out/html/root/index.html @@ -0,0 +1,31 @@ + + + + + + + + + +
//root/ +

Package

+

Functions

+ + + + + + + + + +
ffinal fun f()
+
+ + + diff --git a/plugins/base/src/test/resources/expect/annotatedFunction/src/annotatedFunction.kt b/plugins/base/src/test/resources/expect/annotatedFunction/src/annotatedFunction.kt new file mode 100644 index 00000000..f7abbf6c --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunction/src/annotatedFunction.kt @@ -0,0 +1,2 @@ +@Strictfp fun f() { +} diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/-search.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/navigation.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/navigation.html new file mode 100644 index 00000000..fe9e499e --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/navigation.html @@ -0,0 +1,25 @@ + + diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/-init-.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/-init-.html new file mode 100644 index 00000000..5ae21e5b --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/-init-.html @@ -0,0 +1,30 @@ + + + <init> + + + + + + +
//root//Fancy/<init> +

<init>

+final fun <init>(size: Int) +

Parameters

+ + + + + + + +
size
+
+ + + diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/equals.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/equals.html new file mode 100644 index 00000000..004f5344 --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/equals.html @@ -0,0 +1,30 @@ + + + equals + + + + + + +
//root//Fancy/equals +

equals

+open fun equals(other: Any): Boolean +

Parameters

+ + + + + + + +
other
+
+ + + diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/hash-code.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/hash-code.html new file mode 100644 index 00000000..b395dcda --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/hash-code.html @@ -0,0 +1,20 @@ + + + hashCode + + + + + + +
//root//Fancy/hashCode +

hashCode

+open fun hashCode(): Int
+ + + diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/index.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/index.html new file mode 100644 index 00000000..3da5f79b --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/index.html @@ -0,0 +1,61 @@ + + + Fancy + + + + + + +
//root//FancyFinal class Fancy : Annotation +

Constructors

+ + + + + + + + + +
<init>final fun <init>(size: Int)
+

Functions

+ + + + + + + + + + + + + + + + + + + +
equalsopen fun equals(other: Any): Boolean
hashCodeopen fun hashCode(): Int
toStringopen fun toString(): String
+

Properties

+ + + + + + + + +
size
+
+ + + diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/to-string.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/to-string.html new file mode 100644 index 00000000..84da7873 --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/-fancy/to-string.html @@ -0,0 +1,20 @@ + + + toString + + + + + + +
//root//Fancy/toString +

toString

+open fun toString(): String
+ + + diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/f.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/f.html new file mode 100644 index 00000000..7900fb98 --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/f.html @@ -0,0 +1,20 @@ + + + f + + + + + + +
//root//f +

f

+final fun f()
+ + + diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/index.html b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/index.html new file mode 100644 index 00000000..bba04c93 --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/out/html/root/index.html @@ -0,0 +1,42 @@ + + + + + + + + + +
//root/ +

Package

+

Types

+ + + + + + + + + +
FancyFinal class Fancy : Annotation
+

Functions

+ + + + + + + + + +
ffinal fun f()
+
+ + + diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/src/annotatedFunctionWithAnnotationParameters.kt b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/src/annotatedFunctionWithAnnotationParameters.kt new file mode 100644 index 00000000..e559713a --- /dev/null +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/src/annotatedFunctionWithAnnotationParameters.kt @@ -0,0 +1,7 @@ +@Target(AnnotationTarget.VALUE_PARAMETER) +@Retention(AnnotationRetention.SOURCE) +@MustBeDocumented +public annotation class Fancy(val size: Int) + + +@Fancy(1) fun f() {} diff --git a/plugins/base/src/test/resources/expect/function/out/html/-search.html b/plugins/base/src/test/resources/expect/function/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/function/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/function/out/html/navigation.html b/plugins/base/src/test/resources/expect/function/out/html/navigation.html new file mode 100644 index 00000000..ebff817d --- /dev/null +++ b/plugins/base/src/test/resources/expect/function/out/html/navigation.html @@ -0,0 +1,10 @@ + + diff --git a/plugins/base/src/test/resources/expect/function/out/html/root/fn.html b/plugins/base/src/test/resources/expect/function/out/html/root/fn.html new file mode 100644 index 00000000..e87d7bc4 --- /dev/null +++ b/plugins/base/src/test/resources/expect/function/out/html/root/fn.html @@ -0,0 +1,23 @@ + + + fn + + + + + + +
//root//fn +

fn

+final fun fn() +

Description

+Function fn +
+ + + diff --git a/plugins/base/src/test/resources/expect/function/out/html/root/index.html b/plugins/base/src/test/resources/expect/function/out/html/root/index.html new file mode 100644 index 00000000..25c65b11 --- /dev/null +++ b/plugins/base/src/test/resources/expect/function/out/html/root/index.html @@ -0,0 +1,31 @@ + + + + + + + + + +
//root/ +

Package

+

Functions

+ + + + + + + + + +
fnfinal fun fn()Function fn
+
+ + + diff --git a/plugins/base/src/test/resources/expect/function/src/function.kt b/plugins/base/src/test/resources/expect/function/src/function.kt new file mode 100644 index 00000000..3ed81dfa --- /dev/null +++ b/plugins/base/src/test/resources/expect/function/src/function.kt @@ -0,0 +1,5 @@ +/** + * Function fn + */ +fun fn() { +} \ No newline at end of file diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/-search.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/navigation.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/navigation.html new file mode 100644 index 00000000..53fb1ca2 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/navigation.html @@ -0,0 +1,25 @@ + + diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/-init-.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/-init-.html new file mode 100644 index 00000000..acfc127a --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/-init-.html @@ -0,0 +1,20 @@ + + + <init> + + + + + + +
//root//Fancy/<init> +

<init>

+final fun <init>()
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/equals.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/equals.html new file mode 100644 index 00000000..004f5344 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/equals.html @@ -0,0 +1,30 @@ + + + equals + + + + + + +
//root//Fancy/equals +

equals

+open fun equals(other: Any): Boolean +

Parameters

+ + + + + + + +
other
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/hash-code.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/hash-code.html new file mode 100644 index 00000000..b395dcda --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/hash-code.html @@ -0,0 +1,20 @@ + + + hashCode + + + + + + +
//root//Fancy/hashCode +

hashCode

+open fun hashCode(): Int
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/index.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/index.html new file mode 100644 index 00000000..6a1d3c92 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/index.html @@ -0,0 +1,51 @@ + + + Fancy + + + + + + +
//root//FancyFinal class Fancy : Annotation +

Constructors

+ + + + + + + + + +
<init>final fun <init>()
+

Functions

+ + + + + + + + + + + + + + + + + + + +
equalsopen fun equals(other: Any): Boolean
hashCodeopen fun hashCode(): Int
toStringopen fun toString(): String
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/to-string.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/to-string.html new file mode 100644 index 00000000..84da7873 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/-fancy/to-string.html @@ -0,0 +1,20 @@ + + + toString + + + + + + +
//root//Fancy/toString +

toString

+open fun toString(): String
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/function.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/function.html new file mode 100644 index 00000000..2c0eb890 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/function.html @@ -0,0 +1,30 @@ + + + function + + + + + + +
//root//function +

function

+final fun function(notInlined: Function0<Unit>) +

Parameters

+ + + + + + + +
notInlined
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/index.html b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/index.html new file mode 100644 index 00000000..1797f269 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/out/html/root/index.html @@ -0,0 +1,42 @@ + + + + + + + + + +
//root/ +

Package

+

Types

+ + + + + + + + + +
FancyFinal class Fancy : Annotation
+

Functions

+ + + + + + + + + +
functionfinal fun function(notInlined: Function0<Unit>)
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/src/functionWithAnnotatedParam.kt b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/src/functionWithAnnotatedParam.kt new file mode 100644 index 00000000..f858e671 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/src/functionWithAnnotatedParam.kt @@ -0,0 +1,7 @@ +@Target(AnnotationTarget.VALUE_PARAMETER) +@Retention(AnnotationRetention.SOURCE) +@MustBeDocumented +public annotation class Fancy + +fun function(@Fancy notInlined: () -> Unit) { +} diff --git a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/-search.html b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/navigation.html b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/navigation.html new file mode 100644 index 00000000..ad2005c3 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/navigation.html @@ -0,0 +1,10 @@ + + diff --git a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/f.html b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/f.html new file mode 100644 index 00000000..448fdf25 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/f.html @@ -0,0 +1,30 @@ + + + f + + + + + + +
//root//f +

f

+final fun f(x: String) +

Parameters

+ + + + + + + +
x
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/index.html b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/index.html new file mode 100644 index 00000000..d23b9737 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/out/html/root/index.html @@ -0,0 +1,31 @@ + + + + + + + + + +
//root/ +

Package

+

Functions

+ + + + + + + + + +
ffinal fun f(x: String)
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithDefaultParameter/src/functionWithDefaultParameter.kt b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/src/functionWithDefaultParameter.kt new file mode 100644 index 00000000..3a3a102f --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithDefaultParameter/src/functionWithDefaultParameter.kt @@ -0,0 +1 @@ +fun f(x: String = "") {} diff --git a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/-search.html b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/navigation.html b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/navigation.html new file mode 100644 index 00000000..659c441f --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/navigation.html @@ -0,0 +1,10 @@ + + diff --git a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/function.html b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/function.html new file mode 100644 index 00000000..2c0eb890 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/function.html @@ -0,0 +1,30 @@ + + + function + + + + + + +
//root//function +

function

+final fun function(notInlined: Function0<Unit>) +

Parameters

+ + + + + + + +
notInlined
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/index.html b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/index.html new file mode 100644 index 00000000..2c53c3e2 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/out/html/root/index.html @@ -0,0 +1,31 @@ + + + + + + + + + +
//root/ +

Package

+

Functions

+ + + + + + + + + +
functionfinal fun function(notInlined: Function0<Unit>)
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithNoinlineParam/src/functionWithNoinlineParam.kt b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/src/functionWithNoinlineParam.kt new file mode 100644 index 00000000..640bec83 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithNoinlineParam/src/functionWithNoinlineParam.kt @@ -0,0 +1,2 @@ +fun function(noinline notInlined: () -> Unit) { +} diff --git a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/-search.html b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/navigation.html b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/navigation.html new file mode 100644 index 00000000..ad2005c3 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/navigation.html @@ -0,0 +1,10 @@ + + diff --git a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/f.html b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/f.html new file mode 100644 index 00000000..7900fb98 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/f.html @@ -0,0 +1,20 @@ + + + f + + + + + + +
//root//f +

f

+final fun f()
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/index.html b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/index.html new file mode 100644 index 00000000..867d7faa --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/out/html/root/index.html @@ -0,0 +1,31 @@ + + + + + + + + + +
//root/ +

Package

+

Functions

+ + + + + + + + + +
ffinal fun f()
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/src/functionWithNotDocumentedAnnotation.kt b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/src/functionWithNotDocumentedAnnotation.kt new file mode 100644 index 00000000..3c7e2ff9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithNotDocumentedAnnotation/src/functionWithNotDocumentedAnnotation.kt @@ -0,0 +1,2 @@ +@Suppress("FOO") fun f() { +} diff --git a/plugins/base/src/test/resources/expect/functionWithParams/out/html/-search.html b/plugins/base/src/test/resources/expect/functionWithParams/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithParams/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithParams/out/html/navigation.html b/plugins/base/src/test/resources/expect/functionWithParams/out/html/navigation.html new file mode 100644 index 00000000..659c441f --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithParams/out/html/navigation.html @@ -0,0 +1,10 @@ + + diff --git a/plugins/base/src/test/resources/expect/functionWithParams/out/html/root/function.html b/plugins/base/src/test/resources/expect/functionWithParams/out/html/root/function.html new file mode 100644 index 00000000..0c62a13d --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithParams/out/html/root/function.html @@ -0,0 +1,34 @@ + + + function + + + + + + +
//root//function +

function

+final fun function(x: Int) +

Description

+MultilineFunction Documentation + +

Parameters

+ + + + + + + + +
xparameter
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithParams/out/html/root/index.html b/plugins/base/src/test/resources/expect/functionWithParams/out/html/root/index.html new file mode 100644 index 00000000..a5fdacb0 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithParams/out/html/root/index.html @@ -0,0 +1,31 @@ + + + + + + + + + +
//root/ +

Package

+

Functions

+ + + + + + + + + +
functionfinal fun function(x: Int)Multiline Function Documentation
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithParams/src/functionWithParams.kt b/plugins/base/src/test/resources/expect/functionWithParams/src/functionWithParams.kt new file mode 100644 index 00000000..85c49368 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithParams/src/functionWithParams.kt @@ -0,0 +1,8 @@ +/** + * Multiline + * + * Function + * Documentation + */ +fun function(/** parameter */ x: Int) { +} \ No newline at end of file diff --git a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/-search.html b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/navigation.html b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/navigation.html new file mode 100644 index 00000000..ebff817d --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/navigation.html @@ -0,0 +1,10 @@ + + diff --git a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/fn.html b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/fn.html new file mode 100644 index 00000000..fc3630fc --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/fn.html @@ -0,0 +1,38 @@ + + + fn + + + + + + +
//root//fn +

fn

+final fun String.fn() +

Description

+Function with receiver + +

fn

+final fun String.fn(x: Int) +

Description

+Function with receiver + +

Parameters

+ + + + + + + +
x
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/index.html b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/index.html new file mode 100644 index 00000000..cd92f78d --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithReceiver/out/html/root/index.html @@ -0,0 +1,36 @@ + + + + + + + + + +
//root/ +

Package

+

Functions

+ + + + + + + + + + + + + + +
fnfinal fun String.fn()Function with receiver
fnfinal fun String.fn(x: Int)Function with receiver
+
+ + + diff --git a/plugins/base/src/test/resources/expect/functionWithReceiver/src/functionWithReceiver.kt b/plugins/base/src/test/resources/expect/functionWithReceiver/src/functionWithReceiver.kt new file mode 100644 index 00000000..c8473251 --- /dev/null +++ b/plugins/base/src/test/resources/expect/functionWithReceiver/src/functionWithReceiver.kt @@ -0,0 +1,11 @@ +/** + * Function with receiver + */ +fun String.fn() { +} + +/** + * Function with receiver + */ +fun String.fn(x: Int) { +} diff --git a/plugins/base/src/test/resources/expect/genericFunction/out/html/-search.html b/plugins/base/src/test/resources/expect/genericFunction/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/genericFunction/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/genericFunction/out/html/navigation.html b/plugins/base/src/test/resources/expect/genericFunction/out/html/navigation.html new file mode 100644 index 00000000..dc7dcf2d --- /dev/null +++ b/plugins/base/src/test/resources/expect/genericFunction/out/html/navigation.html @@ -0,0 +1,10 @@ + + diff --git a/plugins/base/src/test/resources/expect/genericFunction/out/html/root/generic.html b/plugins/base/src/test/resources/expect/genericFunction/out/html/root/generic.html new file mode 100644 index 00000000..a8f1dbd1 --- /dev/null +++ b/plugins/base/src/test/resources/expect/genericFunction/out/html/root/generic.html @@ -0,0 +1,23 @@ + + + generic + + + + + + +
//root//generic +

generic

+private final fun generic<generic.T : Any>() +

Description

+generic function +
+ + + diff --git a/plugins/base/src/test/resources/expect/genericFunction/out/html/root/index.html b/plugins/base/src/test/resources/expect/genericFunction/out/html/root/index.html new file mode 100644 index 00000000..e89383c9 --- /dev/null +++ b/plugins/base/src/test/resources/expect/genericFunction/out/html/root/index.html @@ -0,0 +1,31 @@ + + + + + + + + + +
//root/ +

Package

+

Functions

+ + + + + + + + + +
genericprivate final fun generic<generic.T : Any>()generic function
+
+ + + diff --git a/plugins/base/src/test/resources/expect/genericFunction/src/genericFunction.kt b/plugins/base/src/test/resources/expect/genericFunction/src/genericFunction.kt new file mode 100644 index 00000000..05a65070 --- /dev/null +++ b/plugins/base/src/test/resources/expect/genericFunction/src/genericFunction.kt @@ -0,0 +1,5 @@ + +/** + * generic function + */ +private fun generic() {} \ No newline at end of file diff --git a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/-search.html b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/navigation.html b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/navigation.html new file mode 100644 index 00000000..dc7dcf2d --- /dev/null +++ b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/navigation.html @@ -0,0 +1,10 @@ + + diff --git a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/generic.html b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/generic.html new file mode 100644 index 00000000..cd1945f8 --- /dev/null +++ b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/generic.html @@ -0,0 +1,23 @@ + + + generic + + + + + + +
//root//generic +

generic

+final fun generic<generic.T : org.jetbrains.kotlin.protobuf.GeneratedMessageLite$GeneratedExtension@5a8ec9b6, generic.R : Any>() +

Description

+generic function +
+ + + diff --git a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/index.html b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/index.html new file mode 100644 index 00000000..016b01e7 --- /dev/null +++ b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/out/html/root/index.html @@ -0,0 +1,31 @@ + + + + + + + + + +
//root/ +

Package

+

Functions

+ + + + + + + + + +
genericfinal fun generic()generic function
+
+ + + diff --git a/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/src/genericFunctionWithConstraints.kt b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/src/genericFunctionWithConstraints.kt new file mode 100644 index 00000000..5f22f8c5 --- /dev/null +++ b/plugins/base/src/test/resources/expect/genericFunctionWithConstraints/src/genericFunctionWithConstraints.kt @@ -0,0 +1,6 @@ + +/** + * generic function + */ +public fun generic() { +} \ No newline at end of file diff --git a/plugins/base/src/test/resources/expect/inlineFunction/out/html/-search.html b/plugins/base/src/test/resources/expect/inlineFunction/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/inlineFunction/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/inlineFunction/out/html/navigation.html b/plugins/base/src/test/resources/expect/inlineFunction/out/html/navigation.html new file mode 100644 index 00000000..ad2005c3 --- /dev/null +++ b/plugins/base/src/test/resources/expect/inlineFunction/out/html/navigation.html @@ -0,0 +1,10 @@ + + diff --git a/plugins/base/src/test/resources/expect/inlineFunction/out/html/root/f.html b/plugins/base/src/test/resources/expect/inlineFunction/out/html/root/f.html new file mode 100644 index 00000000..0661e211 --- /dev/null +++ b/plugins/base/src/test/resources/expect/inlineFunction/out/html/root/f.html @@ -0,0 +1,30 @@ + + + f + + + + + + +
//root//f +

f

+final fun f(a: Function0<String>) +

Parameters

+ + + + + + + +
a
+
+ + + diff --git a/plugins/base/src/test/resources/expect/inlineFunction/out/html/root/index.html b/plugins/base/src/test/resources/expect/inlineFunction/out/html/root/index.html new file mode 100644 index 00000000..a5dd2a5d --- /dev/null +++ b/plugins/base/src/test/resources/expect/inlineFunction/out/html/root/index.html @@ -0,0 +1,31 @@ + + + + + + + + + +
//root/ +

Package

+

Functions

+ + + + + + + + + +
ffinal fun f(a: Function0<String>)
+
+ + + diff --git a/plugins/base/src/test/resources/expect/inlineFunction/src/inlineFunction.kt b/plugins/base/src/test/resources/expect/inlineFunction/src/inlineFunction.kt new file mode 100644 index 00000000..64a617a4 --- /dev/null +++ b/plugins/base/src/test/resources/expect/inlineFunction/src/inlineFunction.kt @@ -0,0 +1,2 @@ +inline fun f(a: () -> String) { +} diff --git a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/-search.html b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/navigation.html b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/navigation.html new file mode 100644 index 00000000..ad2005c3 --- /dev/null +++ b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/navigation.html @@ -0,0 +1,10 @@ + + diff --git a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/f.html b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/f.html new file mode 100644 index 00000000..0661e211 --- /dev/null +++ b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/f.html @@ -0,0 +1,30 @@ + + + f + + + + + + +
//root//f +

f

+final fun f(a: Function0<String>) +

Parameters

+ + + + + + + +
a
+
+ + + diff --git a/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/index.html b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/index.html new file mode 100644 index 00000000..a5dd2a5d --- /dev/null +++ b/plugins/base/src/test/resources/expect/inlineSuspendFunction/out/html/root/index.html @@ -0,0 +1,31 @@ + + + + + + + + + +
//root/ +

Package

+

Functions

+ + + + + + + + + +
ffinal fun f(a: Function0<String>)
+
+ + + diff --git a/plugins/base/src/test/resources/expect/inlineSuspendFunction/src/inlineSuspendFunction.kt b/plugins/base/src/test/resources/expect/inlineSuspendFunction/src/inlineSuspendFunction.kt new file mode 100644 index 00000000..5f376267 --- /dev/null +++ b/plugins/base/src/test/resources/expect/inlineSuspendFunction/src/inlineSuspendFunction.kt @@ -0,0 +1,2 @@ +inline suspend fun f(a: () -> String) { +} diff --git a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/-search.html b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/navigation.html b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/navigation.html new file mode 100644 index 00000000..5f182c80 --- /dev/null +++ b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/navigation.html @@ -0,0 +1,10 @@ + + diff --git a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/available-since1.1.html b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/available-since1.1.html new file mode 100644 index 00000000..42aa89c4 --- /dev/null +++ b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/available-since1.1.html @@ -0,0 +1,23 @@ + + + availableSince1.1 + + + + + + +
//root//availableSince1.1 +

availableSince1.1

+final fun availableSince1.1(): String +

Description

+Quite useful String +
+ + + diff --git a/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/index.html b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/index.html new file mode 100644 index 00000000..65836c49 --- /dev/null +++ b/plugins/base/src/test/resources/expect/sinceKotlin/out/html/root/index.html @@ -0,0 +1,31 @@ + + + + + + + + + +
//root/ +

Package

+

Functions

+ + + + + + + + + +
availableSince1.1final fun availableSince1.1(): StringQuite useful String
+
+ + + diff --git a/plugins/base/src/test/resources/expect/sinceKotlin/src/sinceKotlin.kt b/plugins/base/src/test/resources/expect/sinceKotlin/src/sinceKotlin.kt new file mode 100644 index 00000000..cdcd3357 --- /dev/null +++ b/plugins/base/src/test/resources/expect/sinceKotlin/src/sinceKotlin.kt @@ -0,0 +1,5 @@ +/** + * Quite useful [String] + */ +@SinceKotlin("1.1") +fun `availableSince1.1`(): String = "1.1 rulezz" \ No newline at end of file diff --git a/plugins/base/src/test/resources/expect/suspendFunction/out/html/-search.html b/plugins/base/src/test/resources/expect/suspendFunction/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/suspendFunction/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/suspendFunction/out/html/navigation.html b/plugins/base/src/test/resources/expect/suspendFunction/out/html/navigation.html new file mode 100644 index 00000000..ad2005c3 --- /dev/null +++ b/plugins/base/src/test/resources/expect/suspendFunction/out/html/navigation.html @@ -0,0 +1,10 @@ + + diff --git a/plugins/base/src/test/resources/expect/suspendFunction/out/html/root/f.html b/plugins/base/src/test/resources/expect/suspendFunction/out/html/root/f.html new file mode 100644 index 00000000..7900fb98 --- /dev/null +++ b/plugins/base/src/test/resources/expect/suspendFunction/out/html/root/f.html @@ -0,0 +1,20 @@ + + + f + + + + + + +
//root//f +

f

+final fun f()
+ + + diff --git a/plugins/base/src/test/resources/expect/suspendFunction/out/html/root/index.html b/plugins/base/src/test/resources/expect/suspendFunction/out/html/root/index.html new file mode 100644 index 00000000..867d7faa --- /dev/null +++ b/plugins/base/src/test/resources/expect/suspendFunction/out/html/root/index.html @@ -0,0 +1,31 @@ + + + + + + + + + +
//root/ +

Package

+

Functions

+ + + + + + + + + +
ffinal fun f()
+
+ + + diff --git a/plugins/base/src/test/resources/expect/suspendFunction/src/suspendFunction.kt b/plugins/base/src/test/resources/expect/suspendFunction/src/suspendFunction.kt new file mode 100644 index 00000000..49ecca2a --- /dev/null +++ b/plugins/base/src/test/resources/expect/suspendFunction/src/suspendFunction.kt @@ -0,0 +1,2 @@ +suspend fun f() { +} diff --git a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/-search.html b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/-search.html new file mode 100644 index 00000000..1ee812bb --- /dev/null +++ b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/-search.html @@ -0,0 +1,23 @@ + + + Search + + + + + + +
+

Search results for

+ + +
+
+ + + diff --git a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/navigation.html b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/navigation.html new file mode 100644 index 00000000..ad2005c3 --- /dev/null +++ b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/navigation.html @@ -0,0 +1,10 @@ + + diff --git a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/f.html b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/f.html new file mode 100644 index 00000000..0661e211 --- /dev/null +++ b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/f.html @@ -0,0 +1,30 @@ + + + f + + + + + + +
//root//f +

f

+final fun f(a: Function0<String>) +

Parameters

+ + + + + + + +
a
+
+ + + diff --git a/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/index.html b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/index.html new file mode 100644 index 00000000..a5dd2a5d --- /dev/null +++ b/plugins/base/src/test/resources/expect/suspendInlineFunction/out/html/root/index.html @@ -0,0 +1,31 @@ + + + + + + + + + +
//root/ +

Package

+

Functions

+ + + + + + + + + +
ffinal fun f(a: Function0<String>)
+
+ + + diff --git a/plugins/base/src/test/resources/expect/suspendInlineFunction/src/suspendInlineFunction.kt b/plugins/base/src/test/resources/expect/suspendInlineFunction/src/suspendInlineFunction.kt new file mode 100644 index 00000000..54f65658 --- /dev/null +++ b/plugins/base/src/test/resources/expect/suspendInlineFunction/src/suspendInlineFunction.kt @@ -0,0 +1,2 @@ +suspend inline fun f(a: () -> String) { +} diff --git a/plugins/base/src/test/resources/expect/test/out/-search.html b/plugins/base/src/test/resources/expect/test/out/-search.html deleted file mode 100644 index 1ee812bb..00000000 --- a/plugins/base/src/test/resources/expect/test/out/-search.html +++ /dev/null @@ -1,23 +0,0 @@ - - - Search - - - - - - -
-

Search results for

- - -
-
- - - diff --git a/plugins/base/src/test/resources/expect/test/out/images/arrow_down.svg b/plugins/base/src/test/resources/expect/test/out/images/arrow_down.svg deleted file mode 100644 index 89e7df47..00000000 --- a/plugins/base/src/test/resources/expect/test/out/images/arrow_down.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/plugins/base/src/test/resources/expect/test/out/images/logo-icon.svg b/plugins/base/src/test/resources/expect/test/out/images/logo-icon.svg deleted file mode 100644 index 1b3b3670..00000000 --- a/plugins/base/src/test/resources/expect/test/out/images/logo-icon.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/plugins/base/src/test/resources/expect/test/out/images/logo-text.svg b/plugins/base/src/test/resources/expect/test/out/images/logo-text.svg deleted file mode 100644 index 7bf3e6c5..00000000 --- a/plugins/base/src/test/resources/expect/test/out/images/logo-text.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/plugins/base/src/test/resources/expect/test/out/navigation.html b/plugins/base/src/test/resources/expect/test/out/navigation.html deleted file mode 100644 index ebff817d..00000000 --- a/plugins/base/src/test/resources/expect/test/out/navigation.html +++ /dev/null @@ -1,10 +0,0 @@ - - diff --git a/plugins/base/src/test/resources/expect/test/out/root/fn.html b/plugins/base/src/test/resources/expect/test/out/root/fn.html deleted file mode 100644 index e87d7bc4..00000000 --- a/plugins/base/src/test/resources/expect/test/out/root/fn.html +++ /dev/null @@ -1,23 +0,0 @@ - - - fn - - - - - - -
//root//fn -

fn

-final fun fn() -

Description

-Function fn -
- - - diff --git a/plugins/base/src/test/resources/expect/test/out/root/index.html b/plugins/base/src/test/resources/expect/test/out/root/index.html deleted file mode 100644 index 25c65b11..00000000 --- a/plugins/base/src/test/resources/expect/test/out/root/index.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - -
//root/ -

Package

-

Functions

- - - - - - - - - -
fnfinal fun fn()Function fn
-
- - - diff --git a/plugins/base/src/test/resources/expect/test/out/scripts/navigationLoader.js b/plugins/base/src/test/resources/expect/test/out/scripts/navigationLoader.js deleted file mode 100644 index 99a885a9..00000000 --- a/plugins/base/src/test/resources/expect/test/out/scripts/navigationLoader.js +++ /dev/null @@ -1,12 +0,0 @@ -onload = () => { - fetch(pathToRoot + "navigation.html") - .then(response => response.text()) - .then(data => { - document.getElementById("sideMenu").innerHTML = data; - }).then(() => { - document.querySelectorAll(".overview > a").forEach(link => { - link.setAttribute("href", pathToRoot + link.getAttribute("href")) - console.log(link.attributes["href"]) - }) - }) -} \ No newline at end of file diff --git a/plugins/base/src/test/resources/expect/test/out/scripts/pages.js b/plugins/base/src/test/resources/expect/test/out/scripts/pages.js deleted file mode 100644 index c0bd7a2f..00000000 --- a/plugins/base/src/test/resources/expect/test/out/scripts/pages.js +++ /dev/null @@ -1,5 +0,0 @@ -var pages = [ -{ "name": "root", "location": "root/index.html" }, -{ "name": "", "location": "root//index.html" }, -{ "name": "fn", "location": "root//fn.html" } -] diff --git a/plugins/base/src/test/resources/expect/test/out/scripts/scripts.js b/plugins/base/src/test/resources/expect/test/out/scripts/scripts.js deleted file mode 100644 index c2e29b9f..00000000 --- a/plugins/base/src/test/resources/expect/test/out/scripts/scripts.js +++ /dev/null @@ -1,11 +0,0 @@ -document.getElementById("navigationFilter").oninput = function (e) { - var input = e.target.value; - var menuParts = document.getElementsByClassName("sideMenuPart") - for (let part of menuParts) { - if(part.querySelector("a").textContent.startsWith(input)) { - part.classList.remove("filtered"); - } else { - part.classList.add("filtered"); - } - } -} \ No newline at end of file diff --git a/plugins/base/src/test/resources/expect/test/out/scripts/search.js b/plugins/base/src/test/resources/expect/test/out/scripts/search.js deleted file mode 100644 index 63112ac5..00000000 --- a/plugins/base/src/test/resources/expect/test/out/scripts/search.js +++ /dev/null @@ -1,5 +0,0 @@ -var query = new URLSearchParams(window.location.search).get("query"); - document.getElementById("searchTitle").innerHTML += '"' + query + '":'; - document.getElementById("searchTable").innerHTML = pages.filter(el => el.name.startsWith(query)).reduce((acc, element) => { return acc + - '' + element.name + '' - }, ""); \ No newline at end of file diff --git a/plugins/base/src/test/resources/expect/test/out/styles/style.css b/plugins/base/src/test/resources/expect/test/out/styles/style.css deleted file mode 100644 index 4a76dd96..00000000 --- a/plugins/base/src/test/resources/expect/test/out/styles/style.css +++ /dev/null @@ -1,353 +0,0 @@ -@import url(https://fonts.googleapis.com/css?family=Open+Sans:300i,400,700); - - -#content { - margin-top: 3em; - margin-left: 15em; -} - -#navigation { - position: relative -} - -#sideMenu, #searchBar { - position: absolute; -} - -#sideMenu { - width: 14em; - padding-left: 0.5em; -} - -#sideMenu .sideMenuPart { - margin-left: 1em; -} - -#sideMenu img { - margin: 1em 0.25em; -} - -#sideMenu hr { - background: #DADFE6; -} - -#searchBar { - width: 100%; - pointer-events: none; -} - -#searchForm { - float: right; - pointer-events: all; -} - -.sideMenuPart > .navButton { - margin-left:0.25em -} - -.sideMenuPart > .overview .navButtonContent::after { - float: right; - content: url("../images/arrow_down.svg"); -} - -.sideMenuPart.hidden > .navButton .navButtonContent::after { - content: '\02192'; -} - -.sideMenuPart.hidden > .sideMenuPart { - display: none; -} - -.filtered > a, .filtered > .navButton { - display: none; -} - -body, table{ - font:14px/1.5 'Open Sans', "Helvetica Neue", Helvetica, Arial, sans-serif; - background: #F4F4F4; - font-weight:300; - margin-left: auto; - margin-right: auto; - max-width: 1440px; -} - -table { - display: flex; - padding:5px; -} - -td:first-child { - width: 20vw; -} - -.keyword { - color:black; - font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; - font-size:12px; -} - -.symbol { - font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; - font-size:12px; -} - -.identifier { - color: darkblue; - font-size:12px; - font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; -} - -h1, h2, h3, h4, h5, h6 { - color:#222; - margin:0 0 20px; -} - -p, ul, ol, table, pre, dl { - margin:0 0 20px; -} - -h1, h2, h3 { - line-height:1.1; -} - -h1 { - font-size:28px; -} - -h2 { - color:#393939; -} - -h3, h4, h5, h6 { - color:#494949; -} - -a { - color:#258aaf; - font-weight:400; - text-decoration:none; -} - -a:hover { - color: inherit; - text-decoration:underline; -} - -a small { - font-size:11px; - color:#555; - margin-top:-0.6em; - display:block; -} - -.wrapper { - width:860px; - margin:0 auto; -} - -blockquote { - border-left:1px solid #e5e5e5; - margin:0; - padding:0 0 0 20px; - font-style:italic; -} - -code, pre { - font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; - color:#333; - font-size:12px; -} - -pre { - display: block; -/* - padding:8px 8px; - background: #f8f8f8; - border-radius:5px; - border:1px solid #e5e5e5; -*/ - overflow-x: auto; -} - -table { - width:100%; - border-collapse:collapse; -} - -th, td { - text-align:left; - vertical-align: top; - padding:5px 10px; -} - -dt { - color:#444; - font-weight:700; -} - -th { - color:#444; -} - -img { - max-width:100%; -} - -header { - width:270px; - float:left; - position:fixed; -} - -header ul { - list-style:none; - height:40px; - - padding:0; - - background: #eee; - background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd)); - background: -webkit-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); - background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); - background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); - background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%); - - border-radius:5px; - border:1px solid #d2d2d2; - box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0; - width:270px; -} - -header li { - width:89px; - float:left; - border-right:1px solid #d2d2d2; - height:40px; -} - -header ul a { - line-height:1; - font-size:11px; - color:#999; - display:block; - text-align:center; - padding-top:6px; - height:40px; -} - -strong { - color:#222; - font-weight:700; -} - -header ul li + li { - width:88px; - border-left:1px solid #fff; -} - -header ul li + li + li { - border-right:none; - width:89px; -} - -header ul a strong { - font-size:14px; - display:block; - color:#222; -} - -section { - width:500px; - float:right; - padding-bottom:50px; -} - -small { - font-size:11px; -} - -hr { - border:0; - background:#e5e5e5; - height:1px; - margin:0 0 20px; -} - -footer { - width:270px; - float:left; - position:fixed; - bottom:50px; -} - -@media print, screen and (max-width: 960px) { - - div.wrapper { - width:auto; - margin:0; - } - - header, section, footer { - float:none; - position:static; - width:auto; - } - - header { - padding-right:320px; - } - - section { - border:1px solid #e5e5e5; - border-width:1px 0; - padding:20px 0; - margin:0 0 20px; - } - - header a small { - display:inline; - } - - header ul { - position:absolute; - right:50px; - top:52px; - } -} - -@media print, screen and (max-width: 720px) { - body { - word-wrap:break-word; - } - - header { - padding:0; - } - - header ul, header p.view { - position:static; - } - - pre, code { - word-wrap:normal; - } -} - -@media print, screen and (max-width: 480px) { - body { - padding:15px; - } - - header ul { - display:none; - } -} - -@media print { - body { - padding:0.4in; - font-size:12pt; - color:#444; - } -} diff --git a/plugins/base/src/test/resources/expect/test/src/function.kt b/plugins/base/src/test/resources/expect/test/src/function.kt deleted file mode 100644 index 3ed81dfa..00000000 --- a/plugins/base/src/test/resources/expect/test/src/function.kt +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Function fn - */ -fun fn() { -} \ No newline at end of file diff --git a/plugins/build.gradle.kts b/plugins/build.gradle.kts index a95b612e..c7c29140 100644 --- a/plugins/build.gradle.kts +++ b/plugins/build.gradle.kts @@ -9,6 +9,14 @@ subprojects { implementation(kotlin("stdlib-jdk8")) testImplementation(project(":testApi")) - testImplementation("junit:junit:4.13") + testImplementation("org.junit.jupiter:junit-jupiter:5.6.0") + } + + tasks.test { + useJUnitPlatform() + ignoreFailures = true + testLogging { + events("passed", "skipped", "failed") + } } } \ No newline at end of file diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt index 780f326a..2a9ddf0e 100644 --- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt +++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt @@ -4,8 +4,8 @@ import org.jetbrains.dokka.pages.ContentGroup import org.jetbrains.dokka.pages.ContentPage import org.jetbrains.dokka.pages.ContentTable import org.jetbrains.dokka.pages.children -import org.junit.Test import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.junit.jupiter.api.Test class KotlinAsJavaPluginTest : AbstractCoreTest() { -- cgit From 03329b0eb98b309d208839344052633028e00984 Mon Sep 17 00:00:00 2001 From: Szymon Świstun Date: Wed, 18 Mar 2020 14:19:54 +0100 Subject: Fix minor bugs and add core tests --- core/src/main/kotlin/model/aditionalExtras.kt | 22 +- .../DefaultDescriptorToDocumentableTranslator.kt | 2 +- plugins/base/src/test/kotlin/enums/EnumsTest.kt | 6 +- plugins/base/src/test/kotlin/model/ClassesTest.kt | 173 +++++------ .../base/src/test/kotlin/model/FunctionsTest.kt | 321 ++++++++++++--------- .../base/src/test/kotlin/model/InheritorsTest.kt | 4 +- plugins/base/src/test/kotlin/model/JavaTest.kt | 109 +++++-- plugins/base/src/test/kotlin/model/PropertyTest.kt | 59 +++- .../test/kotlin/pageMerger/PageNodeMergerTest.kt | 10 +- plugins/base/src/test/kotlin/utils/TestUtils.kt | 5 + .../kotlin/converters/KotlinToJavaConverter.kt | 2 +- 11 files changed, 431 insertions(+), 282 deletions(-) (limited to 'plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt') diff --git a/core/src/main/kotlin/model/aditionalExtras.kt b/core/src/main/kotlin/model/aditionalExtras.kt index b0755759..f7d37111 100644 --- a/core/src/main/kotlin/model/aditionalExtras.kt +++ b/core/src/main/kotlin/model/aditionalExtras.kt @@ -5,22 +5,34 @@ import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy class AdditionalModifiers(val content: Set) : ExtraProperty { - object AdditionalKey : ExtraProperty.Key { + companion object : ExtraProperty.Key { override fun mergeStrategyFor( left: AdditionalModifiers, right: AdditionalModifiers ): MergeStrategy = MergeStrategy.Replace(AdditionalModifiers(left.content + right.content)) } - override fun equals(other: Any?): Boolean = if (other is AdditionalModifiers) other.content == content else false + override fun equals(other: Any?): Boolean = + if (other is AdditionalModifiers) other.content == content else false + override fun hashCode() = content.hashCode() - override val key: ExtraProperty.Key = AdditionalKey + override val key: ExtraProperty.Key = AdditionalModifiers } class Annotations(val content: List) : ExtraProperty { - companion object : ExtraProperty.Key + companion object : ExtraProperty.Key { + override fun mergeStrategyFor(left: Annotations, right: Annotations): MergeStrategy = + MergeStrategy.Replace(Annotations((left.content + right.content).distinct())) + } override val key: ExtraProperty.Key = Annotations - data class Annotation(val dri: DRI, val params: Map) + data class Annotation(val dri: DRI, val params: Map) { + override fun equals(other: Any?): Boolean = when(other) { + is Annotation -> dri.equals(other.dri) + else -> false + } + + override fun hashCode(): Int = dri.hashCode() + } } \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 8e0f1231..44679d8d 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -367,7 +367,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv type = descriptor.type.toBound(), documentation = descriptor.resolveDescriptorData(platformData), platformData = listOf(platformData), - extra = PropertyContainer.withAll(descriptor.additionalExtras()) + extra = PropertyContainer.withAll(descriptor.additionalExtras(), descriptor.getAnnotations()) ) private fun MemberScope.functions(parent: DRIWithPlatformInfo): List = diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt index 55ad0fbc..c9024a72 100644 --- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -34,9 +34,9 @@ class EnumsTest : AbstractCoreTest() { 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" } + assertTrue(test != null) { "Test not found" } + assertTrue(test!!.any { it.name == "E1" } && test.any { it.name == "E2" }) { "Enum entries missing in parent" } + assertTrue(map.keys.any { it.name == "E1" } && map.keys.any { it.name == "E2" }) { "Enum entries missing" } } } } diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt index bd35afc5..336023da 100644 --- a/plugins/base/src/test/kotlin/model/ClassesTest.kt +++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt @@ -1,7 +1,6 @@ package model import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.model.KotlinModifier.* import org.junit.jupiter.api.Test import utils.AbstractModelTest @@ -150,20 +149,14 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class with((this / "classes" / "Klass").cast()) { name equals "Klass" visibility.values allEquals KotlinVisibility.Public - with(extra[AdditionalModifiers.AdditionalKey].assertNotNull("Extras")) { - content.find { it == ExtraModifiers.DATA }.assertNotNull("data modifier") + with(extra[AdditionalModifiers].assertNotNull("Extras")) { + content counts 1 + content.first() equals ExtraModifiers.DATA } } } } -// @Test fun dataClass() { -// verifyPackageMember("testdata/classes/dataClass.kt", defaultModelConfig) { cls -> -// val modifiers = cls.details(NodeKind.Modifier).map { it.name } -// assertTrue("data" in modifiers) -// } -// } - @Test fun sealedClass() { inlineModelTest( @@ -178,30 +171,25 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class } } -// // TODO modifiers -// @Test fun annotatedClassWithAnnotationParameters() { -// checkSourceExistsAndVerifyModel( -// "testdata/classes/annotatedClassWithAnnotationParameters.kt", -// defaultModelConfig -// ) { model -> -// with(model.members.single().members.single()) { -// with(deprecation!!) { -// assertEquals("Deprecated", name) -// assertEquals(Content.Empty, content) -// assertEquals(NodeKind.Annotation, kind) -// assertEquals(1, details.count()) -// with(details[0]) { -// assertEquals(NodeKind.Parameter, kind) -// assertEquals(1, details.count()) -// with(details[0]) { -// assertEquals(NodeKind.Value, kind) -// assertEquals("\"should no longer be used\"", name) -// } -// } -// } -// } -// } -// } + @Test + fun annotatedClassWithAnnotationParameters() { + inlineModelTest( + """ + |@Deprecated("should no longer be used") class Foo() {} + """ + ) { + with((this / "classes" / "Foo").cast()) { + with(extra[Annotations].assertNotNull("Annotations")) { + this.content counts 1 + with(content.first()) { + dri.classNames equals "Deprecated" + params.entries counts 1 + params["message"].assertNotNull("message") equals "should no longer be used" + } + } + } + } + } @Test fun notOpenClass() { @@ -272,7 +260,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class } } - @Test // todo inner class + @Test fun innerClass() { inlineModelTest( """ @@ -284,21 +272,15 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class with((this / "classes" / "C").cast()) { with((this / "D").cast()) { + with(extra[AdditionalModifiers].assertNotNull("AdditionalModifiers")) { + content counts 1 + content.first() equals ExtraModifiers.INNER + } } } } } -// // TODO modifiers -// @Test fun innerClass() { -// verifyPackageMember("testdata/classes/innerClass.kt", defaultModelConfig) { cls -> -// val innerClass = cls.members.single { it.name == "D" } -// val modifiers = innerClass.details(NodeKind.Modifier) -// assertEquals(3, modifiers.size) -// assertEquals("inner", modifiers[2].name) -// } -// } - @Test fun companionObjectExtension() { inlineModelTest( @@ -364,14 +346,29 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class } } - // TODO modifiers -// @Test fun sinceKotlin() { -// checkSourceExistsAndVerifyModel("testdata/classes/sinceKotlin.kt", defaultModelConfig) { model -> -// with(model.members.single().members.single()) { -// assertEquals("1.1", sinceKotlin) -// } -// } -// } + @Test + fun sinceKotlin() { + inlineModelTest( + """ + |/** + | * Useful + | */ + |@SinceKotlin("1.1") + |class C + """ + ) { + with((this / "classes" / "C").cast()) { + with(extra[Annotations].assertNotNull("Annotations")) { + this.content counts 1 + with(content.first()) { + dri.classNames equals "SinceKotlin" + params.entries counts 1 + params["version"].assertNotNull("version") equals "1.1" + } + } + } + } + } @Test fun privateCompanionObject() { @@ -402,7 +399,8 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class } } - @Test fun annotatedClass() { + @Test + fun annotatedClass() { inlineModelTest( """@Suppress("abc") class Foo() {}""" ) { @@ -417,47 +415,30 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class } } - // TODO annotations -// @Test fun annotatedClass() { -// verifyPackageMember("testdata/classes/annotatedClass.kt", ModelConfig( -// analysisPlatform = analysisPlatform, -// withKotlinRuntime = true -// ) -// ) { cls -> -// Assert.assertEquals(1, cls.annotations.count()) -// with(cls.annotations[0]) { -// Assert.assertEquals("Strictfp", name) -// Assert.assertEquals(Content.Empty, content) -// Assert.assertEquals(NodeKind.Annotation, kind) -// } -// } -// } - - -// TODO annotations - -// @Test fun javaAnnotationClass() { -// checkSourceExistsAndVerifyModel( -// "testdata/classes/javaAnnotationClass.kt", -// modelConfig = ModelConfig(analysisPlatform = analysisPlatform, withJdk = true) -// ) { model -> -// with(model.members.single().members.single()) { -// Assert.assertEquals(1, annotations.count()) -// with(annotations[0]) { -// Assert.assertEquals("Retention", name) -// Assert.assertEquals(Content.Empty, content) -// Assert.assertEquals(NodeKind.Annotation, kind) -// with(details[0]) { -// Assert.assertEquals(NodeKind.Parameter, kind) -// Assert.assertEquals(1, details.count()) -// with(details[0]) { -// Assert.assertEquals(NodeKind.Value, kind) -// Assert.assertEquals("RetentionPolicy.SOURCE", name) -// } -// } -// } -// } -// } -// } + @Test fun javaAnnotationClass() { + inlineModelTest( + """ + |import java.lang.annotation.Retention + |import java.lang.annotation.RetentionPolicy + | + |@Retention(RetentionPolicy.SOURCE) + |public annotation class throws() + """ + ) { + with((this / "classes" / "throws").cast()) { + with(extra[AdditionalModifiers].assertNotNull("AdditionalModifiers")) { + content counts 1 + content.first() equals ExtraModifiers.OVERRIDE // ?? + } + with(extra[Annotations].assertNotNull("Annotations")) { + content counts 1 + with(content.first()) { + dri.classNames equals "Retention" + params["value"].assertNotNull("value") equals "(java/lang/annotation/RetentionPolicy, SOURCE)" + } + } + } + } + } } \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/model/FunctionsTest.kt b/plugins/base/src/test/kotlin/model/FunctionsTest.kt index c8b8f2ba..068c2895 100644 --- a/plugins/base/src/test/kotlin/model/FunctionsTest.kt +++ b/plugins/base/src/test/kotlin/model/FunctionsTest.kt @@ -1,9 +1,11 @@ package model -import org.jetbrains.dokka.model.DFunction -import org.jetbrains.dokka.model.DPackage +import org.jetbrains.dokka.model.* import org.junit.jupiter.api.Test -import utils.* +import utils.AbstractModelTest +import utils.assertNotNull +import utils.comments +import utils.name class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "function") { @@ -130,8 +132,6 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun } } -// TODO add modifiers - start - @Test fun functionWithNotDocumentedAnnotation() { inlineModelTest( @@ -139,20 +139,19 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun |@Suppress("FOO") fun f() {} """ ) { - // TODO add annotations - with((this / "function" / "f").cast()) { - assert(false) { "No annotation data" } + with(extra[Annotations].assertNotNull("Annotations")) { + content counts 1 + with(content.first()) { + dri.classNames equals "Suppress" + params.entries counts 1 + params["names"].assertNotNull("names") equals "[\"FOO\"]" + } + } } } } -// @Test fun functionWithNotDocumentedAnnotation() { -// verifyPackageMember("testdata/functions/functionWithNotDocumentedAnnotation.kt", defaultModelConfig) { func -> -// assertEquals(0, func.annotations.count()) -// } -// } - @Test fun inlineFunction() { inlineModelTest( @@ -160,21 +159,13 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun |inline fun f(a: () -> String) {} """ ) { - // TODO add data about inline - with((this / "function" / "f").cast()) { - assert(false) { "No inline data" } + extra[AdditionalModifiers]?.content counts 1 + extra[AdditionalModifiers]?.content exists ExtraModifiers.INLINE } } } -// @Test fun inlineFunction() { -// verifyPackageMember("testdata/functions/inlineFunction.kt", defaultModelConfig) { func -> -// val modifiers = func.details(NodeKind.Modifier).map { it.name } -// assertTrue("inline" in modifiers) -// } -// } - @Test fun suspendFunction() { inlineModelTest( @@ -182,112 +173,167 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun |suspend fun f() {} """ ) { - // TODO add data about suspend + with((this / "function" / "f").cast()) { + extra[AdditionalModifiers]?.content counts 1 + extra[AdditionalModifiers]?.content exists ExtraModifiers.SUSPEND + } + } + } + @Test + fun suspendInlineFunctionOrder() { + inlineModelTest( + """ + |suspend inline fun f(a: () -> String) {} + """ + ) { with((this / "function" / "f").cast()) { - assert(false) { "No suspend data" } + extra[AdditionalModifiers]?.content counts 2 + extra[AdditionalModifiers]?.content exists ExtraModifiers.SUSPEND + extra[AdditionalModifiers]?.content exists ExtraModifiers.INLINE } } } -// @Test fun suspendFunction() { -// verifyPackageMember("testdata/functions/suspendFunction.kt") { func -> -// val modifiers = func.details(NodeKind.Modifier).map { it.name } -// assertTrue("suspend" in modifiers) -// } -// } + @Test + fun inlineSuspendFunctionOrderChanged() { + inlineModelTest( + """ + |inline suspend fun f(a: () -> String) {} + """ + ) { + with((this / "function" / "f").cast()) { + with(extra[AdditionalModifiers].assertNotNull("AdditionalModifiers")) { + content counts 2 + content exists ExtraModifiers.SUSPEND + content exists ExtraModifiers.INLINE + } + } + } + } -// @Test fun suspendInlineFunctionOrder() { -// verifyPackageMember("testdata/functions/suspendInlineFunction.kt") { func -> -// val modifiers = func.details(NodeKind.Modifier).map { it.name }.filter { -// it == "suspend" || it == "inline" -// } -// -// assertEquals(listOf("suspend", "inline"), modifiers) -// } -// } -// -// @Test fun inlineSuspendFunctionOrderChanged() { -// verifyPackageMember("testdata/functions/inlineSuspendFunction.kt") { func -> -// val modifiers = func.details(NodeKind.Modifier).map { it.name }.filter { -// it == "suspend" || it == "inline" -// } -// -// assertEquals(listOf("suspend", "inline"), modifiers) -// } -// } -// -// @Test fun functionWithAnnotatedParam() { -// checkSourceExistsAndVerifyModel("testdata/functions/functionWithAnnotatedParam.kt", defaultModelConfig) { model -> -// with(model.members.single().members.single { it.name == "function" }) { -// with(details(NodeKind.Parameter).first()) { -// assertEquals(1, annotations.count()) -// with(annotations[0]) { -// assertEquals("Fancy", name) -// assertEquals(Content.Empty, content) -// assertEquals(NodeKind.Annotation, kind) -// } -// } -// } -// } -// } -// -// @Test fun functionWithNoinlineParam() { -// verifyPackageMember("testdata/functions/functionWithNoinlineParam.kt", defaultModelConfig) { func -> -// with(func.details(NodeKind.Parameter).first()) { -// val modifiers = details(NodeKind.Modifier).map { it.name } -// assertTrue("noinline" in modifiers) -// } -// } -// } -// -// @Test fun annotatedFunctionWithAnnotationParameters() { -// checkSourceExistsAndVerifyModel( -// "testdata/functions/annotatedFunctionWithAnnotationParameters.kt", -// defaultModelConfig -// ) { model -> -// with(model.members.single().members.single { it.name == "f" }) { -// assertEquals(1, annotations.count()) -// with(annotations[0]) { -// assertEquals("Fancy", name) -// assertEquals(Content.Empty, content) -// assertEquals(NodeKind.Annotation, kind) -// assertEquals(1, details.count()) -// with(details[0]) { -// assertEquals(NodeKind.Parameter, kind) -// assertEquals(1, details.count()) -// with(details[0]) { -// assertEquals(NodeKind.Value, kind) -// assertEquals("1", name) -// } -// } -// } -// } -// } -// } + @Test + fun functionWithAnnotatedParam() { + inlineModelTest( + """ + |@Target(AnnotationTarget.VALUE_PARAMETER) + |@Retention(AnnotationRetention.SOURCE) + |@MustBeDocumented + |public annotation class Fancy + | + |fun function(@Fancy notInlined: () -> Unit) {} + """ + ) { + with((this / "function" / "Fancy").cast()) { + with(extra[Annotations].assertNotNull("Annotations")) { + content counts 3 + with(content.map { it.dri.classNames to it }.toMap()) { + with(this["Target"].assertNotNull("Target")) { + params["allowedTargets"].assertNotNull("allowedTargets") equals "[AnnotationTarget.VALUE_PARAMETER]" + } + with(this["Retention"].assertNotNull("Retention")) { + params["value"].assertNotNull("value") equals "(kotlin/annotation/AnnotationRetention, SOURCE)" + } + this["MustBeDocumented"].assertNotNull("MustBeDocumented").params.entries counts 0 + } + } + + } + with((this / "function" / "function" / "notInlined").cast()) { + with(this.extra[Annotations].assertNotNull("Annotations")) { + content counts 1 + with(content.first()) { + dri.classNames equals "Fancy" + params.entries counts 0 + } + } + } + } + } -// TODO add modifiers - end + @Test + fun functionWithNoinlineParam() { + inlineModelTest( + """ + |fun f(noinline notInlined: () -> Unit) {} + """ + ) { + with((this / "function" / "f" / "notInlined").cast()) { + extra[AdditionalModifiers]?.content counts 1 + extra[AdditionalModifiers]?.content exists ExtraModifiers.NOINLINE + } + } + } -// @Test -// fun functionWithDefaultParameter() { -// inlineModelTest( -// """ -// |/src/main/kotlin/function/Test.kt -// |package function -// |fun f(x: String = "") {} -// """ -// ) { -// // TODO add default value data -// -// with(this / "function" / "f" cast Function::class) { -// parameters.forEach { p -> -// p.name equals "x" -// p.type.constructorFqName.assertNotNull("Parameter type: ") equals "kotlin.String" -// assert(false) { "Add default value data" } -// } -// } -// } -// } + @Test + fun annotatedFunctionWithAnnotationParameters() { + inlineModelTest( + """ + |@Target(AnnotationTarget.VALUE_PARAMETER) + |@Retention(AnnotationRetention.SOURCE) + |@MustBeDocumented + |public annotation class Fancy(val size: Int) + | + |@Fancy(1) fun f() {} + """ + ) { + with((this / "function" / "Fancy").cast()) { + constructors counts 1 + with(constructors.first()) { + parameters counts 1 + with(parameters.first()) { + type.name equals "Int" + name equals "size" + } + } + + with(extra[Annotations].assertNotNull("Annotations")) { + content counts 3 + with(content.map { it.dri.classNames to it }.toMap()) { + with(this["Target"].assertNotNull("Target")) { + params["allowedTargets"].assertNotNull("allowedTargets") equals "[AnnotationTarget.VALUE_PARAMETER]" + } + with(this["Retention"].assertNotNull("Retention")) { + params["value"].assertNotNull("value") equals "(kotlin/annotation/AnnotationRetention, SOURCE)" + } + this["MustBeDocumented"].assertNotNull("MustBeDocumented").params.entries counts 0 + } + } + + } + with((this / "function" / "f").cast()) { + with(this.extra[Annotations].assertNotNull("Annotations")) { + content counts 1 + with(content.first()) { + dri.classNames equals "Fancy" + params.entries counts 1 + params["size"] equals "1" + } + } + } + } + } + + @Test + fun functionWithDefaultParameter() { + inlineModelTest( + """ + |/src/main/kotlin/function/Test.kt + |package function + |fun f(x: String = "") {} + """ + ) { + // TODO add default value data + + with((this / "function" / "f").cast()) { + parameters.forEach { p -> + p.name equals "x" + p.type.name.assertNotNull("Parameter type: ") equals "String" + assert(false) { "No default value data" } + } + } + } + } // @Test fun functionWithDefaultParameter() { // checkSourceExistsAndVerifyModel("testdata/functions/functionWithDefaultParameter.kt", defaultModelConfig) { model -> @@ -302,14 +348,29 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun // } // } // } -// -// @Test fun sinceKotlin() { -// checkSourceExistsAndVerifyModel("testdata/functions/sinceKotlin.kt", defaultModelConfig) { model -> -// with(model.members.single().members.single()) { -// assertEquals("1.1", sinceKotlin) -// } -// } -// } -//} + + @Test + fun sinceKotlin() { + inlineModelTest( + """ + |/** + | * Quite useful [String] + | */ + |@SinceKotlin("1.1") + |fun f(): String = "1.1 rulezz" + """ + ) { + with((this / "function" / "f").cast()) { + with(extra[Annotations].assertNotNull("Annotations")) { + this.content counts 1 + with(content.first()) { + dri.classNames equals "SinceKotlin" + params.entries counts 1 + params["version"].assertNotNull("version") equals "1.1" + } + } + } + } + } } \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/model/InheritorsTest.kt b/plugins/base/src/test/kotlin/model/InheritorsTest.kt index da128803..e1717fe4 100644 --- a/plugins/base/src/test/kotlin/model/InheritorsTest.kt +++ b/plugins/base/src/test/kotlin/model/InheritorsTest.kt @@ -5,8 +5,8 @@ import org.jetbrains.dokka.Platform import org.jetbrains.dokka.base.transformers.documentables.InheritorsExtractorTransformer import org.jetbrains.dokka.base.transformers.documentables.InheritorsInfo import org.jetbrains.dokka.model.DInterface -import org.jetbrains.dokka.model.DPackage import org.jetbrains.dokka.plugability.DokkaPlugin +import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import utils.AbstractModelTest import utils.assertNotNull @@ -83,7 +83,7 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", with(find { it.platformType == Platform.js }.assertNotNull("js key").let { map[it]!! }) { this counts 2 val classes = listOf("B", "C") - assert(all{ classes.contains(it.classNames) }){"One of subclasses missing in js"} + assertTrue(all { classes.contains(it.classNames) }, "One of subclasses missing in js" ) } } diff --git a/plugins/base/src/test/kotlin/model/JavaTest.kt b/plugins/base/src/test/kotlin/model/JavaTest.kt index c6d111a4..a3fcce42 100644 --- a/plugins/base/src/test/kotlin/model/JavaTest.kt +++ b/plugins/base/src/test/kotlin/model/JavaTest.kt @@ -1,8 +1,7 @@ package model +import org.jetbrains.dokka.base.transformers.documentables.InheritorsInfo import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.DEnum -import org.jetbrains.dokka.model.DFunction import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import utils.AbstractModelTest @@ -113,7 +112,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { val sups = listOf("Exception", "Cloneable") assertTrue( sups.all { s -> supertypes.map.values.flatten().any { it.classNames == s } }) - "Foo must extend ${sups.joinToString(", ")}" + "Foo must extend ${sups.joinToString(", ")}" } } } @@ -155,7 +154,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { """ ) { with((this / "java" / "Foo").cast()) { - this + throw AssertionError("No type parameters data for class") } } } @@ -286,6 +285,24 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { // } // } + @Test + fun staticMethod() { + inlineModelTest( + """ + |class C { + | public static void foo() {} + |} + """ + ) { + with((this / "java" / "C" / "foo").cast()) { + with(extra[AdditionalModifiers].assertNotNull("AdditionalModifiers")) { + content counts 1 + content.first() equals ExtraModifiers.STATIC + } + } + } + } + // @Test fun staticMethod() { todo // verifyJavaPackageMember("testdata/java/staticMethod.java", defaultModelConfig) { cls -> // val m = cls.members(NodeKind.Function).single { it.name == "foo" } @@ -304,31 +321,53 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { // assertEquals(1, cls.members(NodeKind.Function).size) // } // } - // - // @Test fun annotatedAnnotation() { - // verifyJavaPackageMember("testdata/java/annotatedAnnotation.java", defaultModelConfig) { cls -> - // assertEquals(1, cls.annotations.size) - // with(cls.annotations[0]) { - // assertEquals(1, details.count()) - // with(details[0]) { - // assertEquals(NodeKind.Parameter, kind) - // assertEquals(1, details.count()) - // with(details[0]) { - // assertEquals(NodeKind.Value, kind) - // assertEquals("[AnnotationTarget.FIELD, AnnotationTarget.CLASS, AnnotationTarget.FILE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]", name) - // } - // } - // } - // } - // } - // + + @Test + fun annotatedAnnotation() { + inlineModelTest( + """ + |import java.lang.annotation.*; + | + |@Target({ElementType.FIELD, ElementType.TYPE, ElementType.METHOD}) + |public @interface Attribute { + | String value() default ""; + |} + """ + ) { + with((this / "java" / "Attribute").cast()) { + with(extra[Annotations].assertNotNull("Annotations")) { + content counts 1 + with(content.first()) { + dri.classNames equals "Target" + params["value"].assertNotNull("value") equals "PsiArrayInitializerMemberValue:{ElementType.FIELD, ElementType.TYPE, ElementType.METHOD}" + } + } + } + } + } + // @Test fun deprecation() { // verifyJavaPackageMember("testdata/java/deprecation.java", defaultModelConfig) { cls -> // val fn = cls.members(NodeKind.Function).single() // assertEquals("This should no longer be used", fn.deprecation!!.content.toTestString()) // } // } - // + + @Test + fun javaLangObject() { + inlineModelTest( + """ + |class Test { + | public Object fn() { return null; } + |} + """ + ) { + with((this / "java" / "Test" / "fn").cast()) { + type.name equals "Any" + } + } + } + // @Test fun javaLangObject() { // verifyJavaPackageMember("testdata/java/javaLangObject.java", defaultModelConfig) { cls -> // val fn = cls.members(NodeKind.Function).single() @@ -356,6 +395,30 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { } } + @Test + fun inheritorLinks() { + inlineModelTest( + """ + |public class InheritorLinks { + | public static class Foo {} + | + | public static class Bar extends Foo {} + |} + """ + ) { + with((this / "java" / "InheritorLinks").cast()) { + val dri = (this / "Foo").assertNotNull("Foo dri").dri + with((this / "Bar").cast()) { + with(extra[InheritorsInfo].assertNotNull("InheritorsInfo")) { + with(value.map.values.flatten().distinct()) { + this counts 1 + first() equals dri + } + } + } + } + } + } // todo // @Test fun inheritorLinks() { diff --git a/plugins/base/src/test/kotlin/model/PropertyTest.kt b/plugins/base/src/test/kotlin/model/PropertyTest.kt index f391df4e..f6f7f3c0 100644 --- a/plugins/base/src/test/kotlin/model/PropertyTest.kt +++ b/plugins/base/src/test/kotlin/model/PropertyTest.kt @@ -1,8 +1,6 @@ package model -import org.jetbrains.dokka.model.KotlinVisibility -import org.jetbrains.dokka.model.DPackage -import org.jetbrains.dokka.model.DProperty +import org.jetbrains.dokka.model.* import org.junit.jupiter.api.Test import utils.AbstractModelTest import utils.assertNotNull @@ -140,19 +138,48 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro } } - // todo -// @Test fun sinceKotlin() { -// checkSourceExistsAndVerifyModel("testdata/properties/sinceKotlin.kt", defaultModelConfig) { model -> -// with(model.members.single().members.single()) { -// assertEquals("1.1", sinceKotlin) -// } -// } -// } -//} -// -//class JSPropertyTest: BasePropertyTest(Platform.js) {} -// -//class JVMPropertyTest : BasePropertyTest(Platform.jvm) { + @Test + fun sinceKotlin() { + inlineModelTest( + """ + |/** + | * Quite useful [String] + | */ + |@SinceKotlin("1.1") + |val prop: String = "1.1 rulezz" + """ + ) { + with((this / "property" / "prop").cast()) { + with(extra[Annotations].assertNotNull("Annotations")) { + this.content counts 1 + with(content.first()) { + dri.classNames equals "SinceKotlin" + params.entries counts 1 + params["version"].assertNotNull("version") equals "1.1" + } + } + } + } + } + + @Test + fun annotatedProperty() { + inlineModelTest( + """ + |@Strictfp var property = "test" + """ + ) { + with((this / "property" / "property").cast()) { + with(extra[Annotations].assertNotNull("Annotations")) { + this.content counts 1 + with(content.first()) { + dri.classNames equals "Strictfp" + params.entries counts 0 + } + } + } + } + } // @Test // fun annotatedProperty() { // checkSourceExistsAndVerifyModel( diff --git a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt index 15dc5581..6ef38aa9 100644 --- a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt +++ b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt @@ -110,13 +110,13 @@ class PageNodeMergerTest : AbstractCoreTest() { 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}" } + assertTrue(testT.size == 1) { "There can be only one testT page" } + assertTrue(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}" } + assertTrue(test.size == 1) { "There can be only one test page" } + assertTrue(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()}" } + assertTrue(strList.count() == 2) { "Expected 2 warnings, got ${strList.count()}" } } } } diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index 68ab7120..8a3053b3 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -3,6 +3,7 @@ package utils import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.doc.* import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.junit.jupiter.api.Assertions.assertTrue import kotlin.collections.orEmpty @DslMarker @@ -22,6 +23,10 @@ interface AssertDSL { infix fun Any?.equals(other: Any?) = this.assertEqual(other) infix fun Collection?.allEquals(other: Any?) = this?.also { c -> c.forEach { it equals other } } ?: run { assert(false) { "Collection is empty" } } + infix fun Collection?.exists(e: T) { + assertTrue(this.orEmpty().isNotEmpty(), "Collection cannot be null or empty") + assertTrue(this!!.any{it == e}, "Collection doesn't contain $e") + } infix fun Collection?.counts(n: Int) = this.orEmpty().assertCount(n) diff --git a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt index 991ee07d..ce41562b 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt @@ -259,7 +259,7 @@ internal fun ClassId.toDRI(dri: DRI?): DRI = DRI( ) private fun PropertyContainer.mergeAdditionalModifiers(second: Set) = - this[AdditionalModifiers.AdditionalKey]?.squash(AdditionalModifiers(second)) ?: AdditionalModifiers(second) + this[AdditionalModifiers]?.squash(AdditionalModifiers(second)) ?: AdditionalModifiers(second) private fun AdditionalModifiers.squash(second: AdditionalModifiers) = AdditionalModifiers(content + second.content) -- cgit From b0e8622f374f6499058b0f083367b4a54512b702 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Tue, 30 Jun 2020 23:06:03 +0200 Subject: Enforce workspace unique SourceSetID --- build.gradle.kts | 4 +- core/src/main/kotlin/DokkaBootstrapImpl.kt | 5 +- core/src/main/kotlin/DokkaGenerator.kt | 2 +- .../main/kotlin/DokkaMultimoduleBootstrapImpl.kt | 5 +- core/src/main/kotlin/configuration.kt | 27 ++- core/src/main/kotlin/defaultConfiguration.kt | 22 ++- core/src/main/kotlin/plugability/DokkaPlugin.kt | 2 +- .../org/jetbrains/dokka/analysis/KotlinAnalysis.kt | 5 +- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 22 +-- .../main/kotlin/signatures/JvmSignatureUtils.kt | 3 +- .../DocumentableVisibilityFilterTransformer.kt | 12 +- .../EmptyPackagesFilterTransformer.kt | 6 +- .../ModuleAndPackageDocumentationTransformer.kt | 4 +- .../pages/samples/SamplesTransformer.kt | 4 +- .../DefaultDescriptorToDocumentableTranslator.kt | 4 +- .../psi/DefaultPsiToDocumentableTranslator.kt | 2 +- plugins/base/src/test/kotlin/basic/DRITest.kt | 40 ++-- .../base/src/test/kotlin/basic/DokkaBasicTests.kt | 6 +- .../src/test/kotlin/basic/FailOnWarningTest.kt | 18 +- .../annotations/ContentForAnnotationsTest.kt | 6 +- .../annotations/DepredatedAndSinceKotlinTest.kt | 8 +- .../kotlin/content/params/ContentForParamsTest.kt | 4 +- .../content/seealso/ContentForSeeAlsoTest.kt | 6 +- .../content/signatures/ContentForSignaturesTest.kt | 4 +- .../SkippingParenthesisForConstructorsTest.kt | 6 +- plugins/base/src/test/kotlin/enums/EnumsTest.kt | 20 +- .../src/test/kotlin/expect/AbstractExpectTest.kt | 6 +- .../test/kotlin/filter/DeprecationFilterTest.kt | 22 +-- .../test/kotlin/filter/EmptyPackagesFilterTest.kt | 11 +- .../src/test/kotlin/filter/VisibilityFilterTest.kt | 22 +-- plugins/base/src/test/kotlin/issues/IssuesTest.kt | 6 +- .../kotlin/linkableContent/LinkableContentTest.kt | 38 ++-- .../DefaultLocationProviderTest.kt | 6 +- plugins/base/src/test/kotlin/markdown/KDocTest.kt | 6 +- plugins/base/src/test/kotlin/markdown/LinkTest.kt | 10 +- .../base/src/test/kotlin/model/InheritorsTest.kt | 8 +- plugins/base/src/test/kotlin/model/PropertyTest.kt | 6 +- .../kotlin/multiplatform/BasicMultiplatformTest.kt | 10 +- .../test/kotlin/pageMerger/PageNodeMergerTest.kt | 10 +- .../test/kotlin/renderers/html/DivergentTest.kt | 8 +- .../renderers/html/SourceSetDependentHintTest.kt | 8 +- .../test/kotlin/renderers/html/defaultSourceSet.kt | 9 +- .../test/kotlin/resourceLinks/ResourceLinksTest.kt | 6 +- .../PageTransformerBuilderTest.kt | 12 +- .../ReportUndocumentedTransformerTest.kt | 136 ++++++------- .../DefaultPsiToDocumentableTranslatorTest.kt | 14 +- plugins/base/src/test/kotlin/utils/ModelUtils.kt | 4 +- plugins/gfm/src/main/kotlin/GfmPlugin.kt | 6 +- .../javadoc/AbstractJavadocTemplateMapTest.kt | 5 +- .../javadoc/src/test/kotlin/javadoc/JavadocTest.kt | 4 +- .../kotlin/javadoc/location/JavadocLocationTest.kt | 6 +- .../src/test/kotlin/KotlinAsJavaPluginTest.kt | 13 +- runners/ant/build.gradle | 18 -- runners/ant/src/main/kotlin/ant/dokka.kt | 210 --------------------- runners/ant/src/main/resources/dokka-antlib.xml | 3 - runners/cli/build.gradle.kts | 3 +- runners/cli/src/main/kotlin/cli/main.kt | 57 +++--- runners/gradle-plugin/build.gradle.kts | 2 + .../dokka/gradle/ConfigurationExtractor.kt | 2 +- .../jetbrains/dokka/gradle/DokkaCollectorTask.kt | 8 +- .../dokka/gradle/DokkaSourceSetIDFactory.kt | 10 + .../kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt | 36 ++-- .../dokka/gradle/configurationImplementations.kt | 93 +++++++-- .../main/kotlin/org/jetbrains/dokka/gradle/main.kt | 4 +- .../gradle/KotlinDslDokkaTaskConfigurationTest.kt | 77 ++++++++ runners/maven-plugin/src/main/kotlin/DokkaMojo.kt | 14 +- .../src/main/kotlin/testApi/context/MockContext.kt | 3 +- .../testApi/testRunner/DokkaTestGenerator.kt | 3 +- .../main/kotlin/testApi/testRunner/TestRunner.kt | 19 +- 69 files changed, 567 insertions(+), 634 deletions(-) delete mode 100644 runners/ant/build.gradle delete mode 100644 runners/ant/src/main/kotlin/ant/dokka.kt delete mode 100644 runners/ant/src/main/resources/dokka-antlib.xml create mode 100644 runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetIDFactory.kt (limited to 'plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt') diff --git a/build.gradle.kts b/build.gradle.kts index c94faa77..04f4afd4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,7 +19,7 @@ allprojects { val language_version: String by project tasks.withType(KotlinCompile::class).all { kotlinOptions { - freeCompilerArgs += "-Xjsr305=strict -Xskip-metadata-version-check" + freeCompilerArgs += "-Xjsr305=strict -Xskip-metadata-version-check -Xopt-in=kotlin.RequiresOptIn." languageVersion = language_version apiVersion = language_version jvmTarget = "1.8" @@ -49,4 +49,4 @@ subprojects { } } -println("Publication version: $dokka_version") \ No newline at end of file +println("Publication version: $dokka_version") diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index bd632546..be3d6c9b 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -1,8 +1,6 @@ package org.jetbrains.dokka -import com.google.gson.Gson import org.jetbrains.dokka.DokkaConfiguration.PackageOptions -import org.jetbrains.dokka.utilities.DokkaConsoleLogger import org.jetbrains.dokka.utilities.DokkaLogger import java.util.function.BiConsumer @@ -80,7 +78,6 @@ class DokkaBootstrapImpl : DokkaBootstrap { } private lateinit var generator: DokkaGenerator - val gson = Gson() fun configure(logger: DokkaLogger, configuration: DokkaConfigurationImpl) = with(configuration) { @@ -113,7 +110,7 @@ class DokkaBootstrapImpl : DokkaBootstrap { override fun configure(logger: BiConsumer, serializedConfigurationJSON: String) = configure( DokkaProxyLogger(logger), - gson.fromJson(serializedConfigurationJSON, DokkaConfigurationImpl::class.java) + DokkaConfigurationImpl(serializedConfigurationJSON) ) override fun generate() = generator.generate() diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index ce8d229a..ee1adf0b 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -68,7 +68,7 @@ class DokkaGenerator( fun createDocumentationModels( context: DokkaContext ) = context.configuration.sourceSets - .flatMap { passConfiguration -> translateSources(passConfiguration, context) } + .flatMap { sourceSet -> translateSources(sourceSet, context) } fun transformDocumentationModelBeforeMerge( modulesFromPlatforms: List, diff --git a/core/src/main/kotlin/DokkaMultimoduleBootstrapImpl.kt b/core/src/main/kotlin/DokkaMultimoduleBootstrapImpl.kt index 6825ce64..70b99f8d 100644 --- a/core/src/main/kotlin/DokkaMultimoduleBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaMultimoduleBootstrapImpl.kt @@ -1,6 +1,5 @@ package org.jetbrains.dokka -import com.google.gson.Gson import org.jetbrains.dokka.DokkaBootstrapImpl.DokkaProxyLogger import org.jetbrains.dokka.utilities.DokkaLogger import java.util.function.BiConsumer @@ -15,11 +14,11 @@ class DokkaMultimoduleBootstrapImpl : DokkaBootstrap { override fun configure(logger: BiConsumer, serializedConfigurationJSON: String) = configure( DokkaProxyLogger(logger), - Gson().fromJson(serializedConfigurationJSON, DokkaConfigurationImpl::class.java) + DokkaConfigurationImpl(serializedConfigurationJSON) ) override fun generate() { generator.generateAllModulesPage() } -} \ No newline at end of file +} diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt index 463d2342..c531ab9a 100644 --- a/core/src/main/kotlin/configuration.kt +++ b/core/src/main/kotlin/configuration.kt @@ -1,6 +1,10 @@ +@file:Suppress("FunctionName") + package org.jetbrains.dokka +import com.google.gson.Gson import java.io.File +import java.io.Serializable import java.net.URL object DokkaDefaults { @@ -43,6 +47,23 @@ enum class Platform(val key: String) { } } +data class DokkaSourceSetID( + val moduleName: String, + val sourceSetName: String +) : Serializable { + override fun toString(): String { + return "$moduleName/$sourceSetName" + } +} + +fun DokkaConfigurationImpl(json: String): DokkaConfigurationImpl { + return Gson().fromJson(json, DokkaConfigurationImpl::class.java) +} + +fun DokkaConfiguration.toJson(): String { + return Gson().toJson(this) +} + interface DokkaConfiguration { val outputDir: String val format: String @@ -55,12 +76,12 @@ interface DokkaConfiguration { val pluginsConfiguration: Map interface DokkaSourceSet { - val moduleName: String + val sourceSetID: DokkaSourceSetID val displayName: String - val sourceSetID: String + val moduleDisplayName: String val classpath: List val sourceRoots: List - val dependentSourceSets: List + val dependentSourceSets: Set val samples: List val includes: List val includeNonPublic: Boolean diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt index d3ac9df2..47bd7fe2 100644 --- a/core/src/main/kotlin/defaultConfiguration.kt +++ b/core/src/main/kotlin/defaultConfiguration.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import java.io.File import java.net.URL @@ -16,12 +17,12 @@ data class DokkaConfigurationImpl( ) : DokkaConfiguration data class DokkaSourceSetImpl( - override val moduleName: String, + override val moduleDisplayName: String, override val displayName: String, - override val sourceSetID: String, + override val sourceSetID: DokkaSourceSetID, override val classpath: List, override val sourceRoots: List, - override val dependentSourceSets: List, + override val dependentSourceSets: Set, override val samples: List, override val includes: List, override val includeNonPublic: Boolean, @@ -39,23 +40,23 @@ data class DokkaSourceSetImpl( override val noJdkLink: Boolean, override val suppressedFiles: List, override val analysisPlatform: Platform -) : DokkaConfiguration.DokkaSourceSet +) : DokkaSourceSet data class DokkaModuleDescriptionImpl( override val name: String, override val path: String, override val docFile: String -): DokkaConfiguration.DokkaModuleDescription +) : DokkaConfiguration.DokkaModuleDescription data class SourceRootImpl( override val path: String -): DokkaConfiguration.SourceRoot +) : DokkaConfiguration.SourceRoot data class SourceLinkDefinitionImpl( override val path: String, override val url: String, override val lineSuffix: String? -): DokkaConfiguration.SourceLinkDefinition { +) : DokkaConfiguration.SourceLinkDefinition { companion object { fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinitionImpl { val (path, urlAndLine) = srcLink.split('=') @@ -73,9 +74,10 @@ data class PackageOptionsImpl( override val reportUndocumented: Boolean?, override val skipDeprecated: Boolean, override val suppress: Boolean -): DokkaConfiguration.PackageOptions +) : DokkaConfiguration.PackageOptions -data class ExternalDocumentationLinkImpl(override val url: URL, - override val packageListUrl: URL +data class ExternalDocumentationLinkImpl( + override val url: URL, + override val packageListUrl: URL ) : DokkaConfiguration.ExternalDocumentationLink diff --git a/core/src/main/kotlin/plugability/DokkaPlugin.kt b/core/src/main/kotlin/plugability/DokkaPlugin.kt index fe472b12..7ead43b8 100644 --- a/core/src/main/kotlin/plugability/DokkaPlugin.kt +++ b/core/src/main/kotlin/plugability/DokkaPlugin.kt @@ -82,4 +82,4 @@ inline fun configuratio } } } -} \ No newline at end of file +} diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinAnalysis.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinAnalysis.kt index 426ffdde..e723768c 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinAnalysis.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinAnalysis.kt @@ -3,6 +3,7 @@ package org.jetbrains.dokka.analysis import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet +import org.jetbrains.dokka.DokkaSourceSetID import org.jetbrains.dokka.model.SourceSetDependent import org.jetbrains.dokka.plugability.DokkaContext @@ -21,7 +22,7 @@ fun KotlinAnalysis(context: DokkaContext): KotlinAnalysis { interface KotlinAnalysis : SourceSetDependent { override fun get(key: DokkaSourceSet): EnvironmentAndFacade - operator fun get(sourceSetID: String): EnvironmentAndFacade + operator fun get(sourceSetID: DokkaSourceSetID): EnvironmentAndFacade } internal class KotlinAnalysisImpl( @@ -32,7 +33,7 @@ internal class KotlinAnalysisImpl( return environments[key] ?: throw IllegalStateException("Missing EnvironmentAndFacade for sourceSet $key") } - override fun get(sourceSetID: String): EnvironmentAndFacade { + override fun get(sourceSetID: DokkaSourceSetID): EnvironmentAndFacade { return environments.entries.first { (sourceSet, _) -> sourceSet.sourceSetID == sourceSetID }.value } } diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index de892bb1..f8fa3b2e 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -94,7 +94,7 @@ open class HtmlRenderer( group.sourceSets.forEach { button(classes = "platform-tag platform-selector") { attributes["data-active"] = "" - attributes["data-filter"] = it.sourceSetID + attributes["data-filter"] = it.sourceSetID.toString() when (it.analysisPlatform.key) { "common" -> classes = classes + "common-like" "native" -> classes = classes + "native-like" @@ -168,10 +168,10 @@ open class HtmlRenderer( attributes["data-toggle-list"] = "data-toggle-list" contents.forEachIndexed { index, pair -> button(classes = "platform-bookmark") { - attributes["data-filterable-current"] = pair.first.sourceSetID - attributes["data-filterable-set"] = pair.first.sourceSetID + attributes["data-filterable-current"] = pair.first.sourceSetID.toString() + attributes["data-filterable-set"] = pair.first.sourceSetID.toString() if (index == 0) attributes["data-active"] = "" - attributes["data-toggle"] = pair.first.sourceSetID + attributes["data-toggle"] = pair.first.sourceSetID.toString() when ( pair.first.analysisPlatform.key ) { @@ -180,7 +180,7 @@ open class HtmlRenderer( "jvm" -> classes = classes + "jvm-like" "js" -> classes = classes + "js-like" } - attributes["data-toggle"] = pair.first.sourceSetID + attributes["data-toggle"] = pair.first.sourceSetID.toString() text(pair.first.displayName) } } @@ -212,7 +212,7 @@ open class HtmlRenderer( }.map { it to createHTML(prettyPrint = false).div(classes = "content sourceset-depenent-content") { if (counter++ == 0) attributes["data-active"] = "" - attributes["data-togglable"] = it.sourceSetID + attributes["data-togglable"] = it.sourceSetID.toString() unsafe { +html } @@ -249,10 +249,10 @@ open class HtmlRenderer( consumer.onTagContentUnsafe { +createHTML().div("divergent-group") { attributes["data-filterable-current"] = groupedDivergent.keys.joinToString(" ") { - it.sourceSetID + it.sourceSetID.toString() } attributes["data-filterable-set"] = groupedDivergent.keys.joinToString(" ") { - it.sourceSetID + it.sourceSetID.toString() } val divergentForPlatformDependent = groupedDivergent.map { (sourceSet, elements) -> @@ -353,10 +353,10 @@ open class HtmlRenderer( div(classes = "table-row") { if (!style.contains(MultimoduleTable)) { attributes["data-filterable-current"] = node.sourceSets.joinToString(" ") { - it.sourceSetID + it.sourceSetID.toString() } attributes["data-filterable-set"] = node.sourceSets.joinToString(" ") { - it.sourceSetID + it.sourceSetID.toString() } } @@ -728,4 +728,4 @@ private fun String.stripDiv() = drop(5).dropLast(6) // TODO: Find a way to do it private val PageNode.isNavigable: Boolean get() = this !is RendererSpecificPage || strategy != RenderingStrategy.DoNothing -fun PropertyContainer.extraHtmlAttributes() = allOfType() \ No newline at end of file +fun PropertyContainer.extraHtmlAttributes() = allOfType() diff --git a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt index f042eae3..2a242948 100644 --- a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt +++ b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt @@ -1,6 +1,5 @@ package org.jetbrains.dokka.base.signatures -import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.* @@ -142,4 +141,4 @@ interface JvmSignatureUtils { sealed class AtStrategy object All : AtStrategy() object OnlyOnce : AtStrategy() -object Never : AtStrategy() \ No newline at end of file +object Never : AtStrategy() diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt index c3cc4d38..ff05beed 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilterTransformer.kt @@ -9,11 +9,9 @@ import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMergeDocumentableTransformer { override fun invoke(modules: List) = modules.map { original -> - val passOptions = original.sourceSets.single() - val packageOptions = passOptions.perPackageOptions - original.let { - DocumentableVisibilityFilter(packageOptions, passOptions).processModule(it) - } + val sourceSet = original.sourceSets.single() + val packageOptions = sourceSet.perPackageOptions + DocumentableVisibilityFilter(packageOptions, sourceSet).processModule(original) } private class DocumentableVisibilityFilter( @@ -45,7 +43,7 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe private fun filterPackages(packages: List): Pair> { var packagesListChanged = false - val filteredPackages = packages.mapNotNull { + val filteredPackages = packages.map { var modified = false val functions = filterFunctions(it.functions).let { (listModified, list) -> modified = modified || listModified @@ -326,4 +324,4 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe return Pair(classlikesListChanged, filteredClasslikes) } } -} \ No newline at end of file +} diff --git a/plugins/base/src/main/kotlin/transformers/documentables/EmptyPackagesFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/EmptyPackagesFilterTransformer.kt index 3fd0081a..61abfbd7 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/EmptyPackagesFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/EmptyPackagesFilterTransformer.kt @@ -14,9 +14,9 @@ class EmptyPackagesFilterTransformer(val context: DokkaContext) : PreMergeDocume } private class EmptyPackagesFilter( - val passOptions: DokkaConfiguration.DokkaSourceSet + val sourceSet: DokkaConfiguration.DokkaSourceSet ) { - fun DPackage.shouldBeSkipped() = passOptions.skipEmptyPackages && + fun DPackage.shouldBeSkipped() = sourceSet.skipEmptyPackages && functions.isEmpty() && properties.isEmpty() && classlikes.isEmpty() @@ -25,4 +25,4 @@ class EmptyPackagesFilterTransformer(val context: DokkaContext) : PreMergeDocume packages = module.packages.filter { !it.shouldBeSkipped() } ) } -} \ No newline at end of file +} diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt index 1f718a7c..a0800da8 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt @@ -1,12 +1,10 @@ package org.jetbrains.dokka.base.transformers.documentables -import org.jetbrains.dokka.analysis.EnvironmentAndFacade import org.jetbrains.dokka.analysis.KotlinAnalysis import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.base.parsers.MarkdownParser -import org.jetbrains.dokka.model.SourceSetDependent import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer import org.jetbrains.kotlin.name.FqName @@ -24,7 +22,7 @@ internal class ModuleAndPackageDocumentationTransformer( val modulesAndPackagesDocumentation = context.configuration.sourceSets .map { - Pair(it.moduleName, it) to + Pair(it.moduleDisplayName, it) to it.includes.map { Paths.get(it) } .also { it.forEach { diff --git a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt index b39715a7..41dea1a2 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt @@ -67,7 +67,7 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer { analysis: Map ): ContentNode { val facade = analysis[platform]?.facade - ?: return this.also { context.logger.warn("Cannot resolve facade for platform ${platform.moduleName}") } + ?: return this.also { context.logger.warn("Cannot resolve facade for platform ${platform.moduleDisplayName}") } val psiElement = fqNameToPsiElement(facade, fqName) ?: return this.also { context.logger.warn("Cannot find PsiElement corresponding to $fqName") } val imports = @@ -147,4 +147,4 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer { style = styles + ContentStyle.RunnableSample + TextStyle.Monospace, extra = extra ) -} \ No newline at end of file +} diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 9cdd251c..b0374014 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotated import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies import org.jetbrains.kotlin.idea.kdoc.findKDoc -import org.jetbrains.kotlin.idea.kdoc.isBoringBuiltinClass import org.jetbrains.kotlin.load.kotlin.toSourceElement import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.* @@ -36,7 +35,6 @@ import org.jetbrains.kotlin.resolve.constants.KClassValue.Value.NormalClass import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperclassesWithoutAny import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces -import org.jetbrains.kotlin.resolve.jvm.isInlineClassThatRequiresMangling import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.resolve.source.KotlinSourceElement @@ -71,7 +69,7 @@ class DefaultDescriptorToDocumentableTranslator( DRIWithPlatformInfo(DRI.topLevel, emptyMap()) ) } - }.let { DModule(sourceSet.moduleName, it, emptyMap(), null, setOf(sourceSet)) } + }.let { DModule(sourceSet.moduleDisplayName, it, emptyMap(), null, setOf(sourceSet)) } } } diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index 76f8319d..5a55e3ec 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -68,7 +68,7 @@ class DefaultPsiToDocumentableTranslator( context.logger ) return DModule( - sourceSet.moduleName, + sourceSet.moduleDisplayName, psiFiles.mapNotNull { it.safeAs() }.groupBy { it.packageName }.map { (packageName, psiFiles) -> val dri = DRI(packageName = packageName) DPackage( diff --git a/plugins/base/src/test/kotlin/basic/DRITest.kt b/plugins/base/src/test/kotlin/basic/DRITest.kt index 1f4c7d93..559a2dbf 100644 --- a/plugins/base/src/test/kotlin/basic/DRITest.kt +++ b/plugins/base/src/test/kotlin/basic/DRITest.kt @@ -5,19 +5,19 @@ import org.jetbrains.dokka.links.Callable import org.jetbrains.dokka.links.Nullable import org.jetbrains.dokka.links.TypeConstructor import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.pages.* -import org.jetbrains.dokka.pages.dfs -import org.junit.jupiter.api.Assertions.assertEquals +import org.jetbrains.dokka.pages.ClasslikePageNode +import org.jetbrains.dokka.pages.ContentPage +import org.jetbrains.dokka.pages.MemberPageNode import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest - +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test class DRITest : AbstractCoreTest() { @Test fun issue634() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") } } @@ -52,8 +52,8 @@ class DRITest : AbstractCoreTest() { @Test fun issue634WithImmediateNullableSelf() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") } } @@ -82,8 +82,8 @@ class DRITest : AbstractCoreTest() { @Test fun issue634WithGenericNullableReceiver() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") } } @@ -112,8 +112,8 @@ class DRITest : AbstractCoreTest() { @Test fun issue642WithStarAndAny() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { analysisPlatform = "js" sourceRoots = listOf("src/") } @@ -171,8 +171,8 @@ class DRITest : AbstractCoreTest() { @Test fun driForGenericClass(){ val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") } } @@ -201,8 +201,8 @@ class DRITest : AbstractCoreTest() { @Test fun driForGenericFunction(){ val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") classpath = listOfNotNull(jvmStdlibPath) } @@ -243,8 +243,8 @@ class DRITest : AbstractCoreTest() { @Test fun driForFunctionNestedInsideInnerClass() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") classpath = listOfNotNull(jvmStdlibPath) } @@ -280,8 +280,8 @@ class DRITest : AbstractCoreTest() { @Test fun driForGenericExtensionFunction(){ val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") } } diff --git a/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt b/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt index 5cc17bf3..bceb79ae 100644 --- a/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt +++ b/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt @@ -11,8 +11,8 @@ class DokkaBasicTests : AbstractCoreTest() { @Test fun basic1() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/basic/Test.kt") } } @@ -39,4 +39,4 @@ class DokkaBasicTests : AbstractCoreTest() { private 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/basic/FailOnWarningTest.kt b/plugins/base/src/test/kotlin/basic/FailOnWarningTest.kt index d548b75b..9d2c5825 100644 --- a/plugins/base/src/test/kotlin/basic/FailOnWarningTest.kt +++ b/plugins/base/src/test/kotlin/basic/FailOnWarningTest.kt @@ -14,8 +14,8 @@ class FailOnWarningTest : AbstractCoreTest() { fun `throws exception if one or more warnings were emitted`() { val configuration = dokkaConfiguration { failOnWarning = true - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin") } } @@ -39,8 +39,8 @@ class FailOnWarningTest : AbstractCoreTest() { fun `throws exception if one or more error were emitted`() { val configuration = dokkaConfiguration { failOnWarning = true - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin") } } @@ -66,8 +66,8 @@ class FailOnWarningTest : AbstractCoreTest() { val configuration = dokkaConfiguration { failOnWarning = true - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin") } } @@ -88,8 +88,8 @@ class FailOnWarningTest : AbstractCoreTest() { fun `does not throw if disabled`() { val configuration = dokkaConfiguration { failOnWarning = false - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin") } } @@ -115,4 +115,4 @@ private class ZeroErrorOrWarningCountDokkaLogger( ) : DokkaLogger by logger { override var warningsCount: Int = 0 override var errorsCount: Int = 0 -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt index 7add4119..bf78b847 100644 --- a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt +++ b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt @@ -14,8 +14,8 @@ class ContentForAnnotationsTest : AbstractCoreTest() { private val testConfiguration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") analysisPlatform = "jvm" } @@ -218,4 +218,4 @@ class ContentForAnnotationsTest : AbstractCoreTest() { } } } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/content/annotations/DepredatedAndSinceKotlinTest.kt b/plugins/base/src/test/kotlin/content/annotations/DepredatedAndSinceKotlinTest.kt index 99ec25c5..69de1bcd 100644 --- a/plugins/base/src/test/kotlin/content/annotations/DepredatedAndSinceKotlinTest.kt +++ b/plugins/base/src/test/kotlin/content/annotations/DepredatedAndSinceKotlinTest.kt @@ -3,19 +3,17 @@ package content.annotations import matchers.content.* import org.jetbrains.dokka.pages.ContentPage -import org.jetbrains.dokka.pages.PackagePageNode import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import org.junit.jupiter.api.Test import utils.ParamAttributes import utils.bareSignature -import utils.propertySignature class DepredatedAndSinceKotlinTest : AbstractCoreTest() { private val testConfiguration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") analysisPlatform = "jvm" } @@ -102,4 +100,4 @@ class DepredatedAndSinceKotlinTest : AbstractCoreTest() { } } } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt index f6e80891..a9689bc5 100644 --- a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt +++ b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt @@ -17,8 +17,8 @@ import utils.* class ContentForParamsTest : AbstractCoreTest() { private val testConfiguration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") analysisPlatform = "jvm" } diff --git a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt index 696c3032..24970660 100644 --- a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt +++ b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt @@ -11,8 +11,8 @@ import utils.unnamedTag class ContentForSeeAlsoTest : AbstractCoreTest() { private val testConfiguration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") analysisPlatform = "jvm" } @@ -456,4 +456,4 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { } } } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt b/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt index 6cb8b0f4..cabe822d 100644 --- a/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt +++ b/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt @@ -14,8 +14,8 @@ import utils.typealiasSignature class ContentForSignaturesTest : AbstractCoreTest() { private val testConfiguration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") analysisPlatform = "jvm" includeNonPublic = true diff --git a/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt b/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt index d203025b..c2fbd26f 100644 --- a/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt +++ b/plugins/base/src/test/kotlin/content/signatures/SkippingParenthesisForConstructorsTest.kt @@ -8,8 +8,8 @@ import utils.functionSignature class ConstructorsSignaturesTest : AbstractCoreTest() { private val testConfiguration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") analysisPlatform = "jvm" } @@ -190,4 +190,4 @@ class ConstructorsSignaturesTest : AbstractCoreTest() { } } } -} \ 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 index be910b5c..6a973f8e 100644 --- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -14,8 +14,8 @@ class EnumsTest : AbstractCoreTest() { @Test fun basicEnum() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") } } @@ -45,8 +45,8 @@ class EnumsTest : AbstractCoreTest() { @Test fun enumWithCompanion() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") } } @@ -90,8 +90,8 @@ class EnumsTest : AbstractCoreTest() { @Test fun enumWithConstructor() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") } } @@ -136,8 +136,8 @@ class EnumsTest : AbstractCoreTest() { @Test fun enumWithMethods() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") } } @@ -179,8 +179,8 @@ class EnumsTest : AbstractCoreTest() { @Test fun enumWithAnnotationsOnEntries(){ val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") } } diff --git a/plugins/base/src/test/kotlin/expect/AbstractExpectTest.kt b/plugins/base/src/test/kotlin/expect/AbstractExpectTest.kt index 3b69a54e..4dfdc410 100644 --- a/plugins/base/src/test/kotlin/expect/AbstractExpectTest.kt +++ b/plugins/base/src/test/kotlin/expect/AbstractExpectTest.kt @@ -15,8 +15,8 @@ abstract class AbstractExpectTest( protected fun generateOutput(path: Path, outFormat: String): Path? { val config = dokkaConfiguration { format = outFormat - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf(path.toAbsolutePath().asString()) } } @@ -101,4 +101,4 @@ abstract class AbstractExpectTest( ret?.let { Files.list(it).forEach { f -> f.copyRecursively(out.resolve(f.fileName)) } } } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt b/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt index c15e53e8..c8b9f2d4 100644 --- a/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt +++ b/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt @@ -9,8 +9,8 @@ class DeprecationFilterTest : AbstractCoreTest() { @Test fun `function with false global skipDeprecated`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { skipDeprecated = false sourceRoots = listOf("src/main/kotlin/basic/Test.kt") } @@ -39,8 +39,8 @@ class DeprecationFilterTest : AbstractCoreTest() { @Test fun `deprecated function with false global skipDeprecated`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { skipDeprecated = false sourceRoots = listOf("src/main/kotlin/basic/Test.kt") } @@ -69,8 +69,8 @@ class DeprecationFilterTest : AbstractCoreTest() { @Test fun `deprecated function with true global skipDeprecated`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/basic/Test.kt") skipDeprecated = true } @@ -99,8 +99,8 @@ class DeprecationFilterTest : AbstractCoreTest() { @Test fun `deprecated function with false global true package skipDeprecated`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/basic/Test.kt") skipDeprecated = false perPackageOptions = mutableListOf( @@ -136,8 +136,8 @@ class DeprecationFilterTest : AbstractCoreTest() { @Test fun `deprecated function with true global false package skipDeprecated`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/basic/Test.kt") skipDeprecated = true perPackageOptions = mutableListOf( @@ -170,4 +170,4 @@ class DeprecationFilterTest : AbstractCoreTest() { } } } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/filter/EmptyPackagesFilterTest.kt b/plugins/base/src/test/kotlin/filter/EmptyPackagesFilterTest.kt index 7d96541b..e5b9e9c2 100644 --- a/plugins/base/src/test/kotlin/filter/EmptyPackagesFilterTest.kt +++ b/plugins/base/src/test/kotlin/filter/EmptyPackagesFilterTest.kt @@ -1,6 +1,5 @@ package filter -import org.jetbrains.dokka.PackageOptionsImpl import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test @@ -9,8 +8,8 @@ class EmptyPackagesFilterTest : AbstractCoreTest() { @Test fun `empty package with false skipEmptyPackages`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { skipEmptyPackages = false sourceRoots = listOf("src/main/kotlin/basic/Test.kt") } @@ -37,8 +36,8 @@ class EmptyPackagesFilterTest : AbstractCoreTest() { @Test fun `empty package with true skipEmptyPackages`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { skipEmptyPackages = true sourceRoots = listOf("src/main/kotlin/basic/Test.kt") } @@ -61,4 +60,4 @@ class EmptyPackagesFilterTest : AbstractCoreTest() { } } } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt b/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt index 5e8e33dc..192de449 100644 --- a/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt +++ b/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt @@ -9,8 +9,8 @@ class VisibilityFilterTest : AbstractCoreTest() { @Test fun `public function with false global includeNonPublic`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { includeNonPublic = false sourceRoots = listOf("src/main/kotlin/basic/Test.kt") } @@ -39,8 +39,8 @@ class VisibilityFilterTest : AbstractCoreTest() { @Test fun `private function with false global includeNonPublic`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { includeNonPublic = false sourceRoots = listOf("src/main/kotlin/basic/Test.kt") } @@ -69,8 +69,8 @@ class VisibilityFilterTest : AbstractCoreTest() { @Test fun `private function with true global includeNonPublic`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/basic/Test.kt") includeNonPublic = true } @@ -99,8 +99,8 @@ class VisibilityFilterTest : AbstractCoreTest() { @Test fun `private function with false global true package includeNonPublic`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/basic/Test.kt") includeNonPublic = false perPackageOptions = mutableListOf( @@ -136,8 +136,8 @@ class VisibilityFilterTest : AbstractCoreTest() { @Test fun `private function with true global false package includeNonPublic`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/basic/Test.kt") includeNonPublic = true perPackageOptions = mutableListOf( @@ -170,4 +170,4 @@ class VisibilityFilterTest : AbstractCoreTest() { } } } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/issues/IssuesTest.kt b/plugins/base/src/test/kotlin/issues/IssuesTest.kt index f67229b7..7b065349 100644 --- a/plugins/base/src/test/kotlin/issues/IssuesTest.kt +++ b/plugins/base/src/test/kotlin/issues/IssuesTest.kt @@ -34,8 +34,8 @@ class IssuesTest : AbstractModelTest("/src/main/kotlin/issues/Test.kt", "issues" |} """, configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") classpath = listOfNotNull(jvmStdlibPath) } @@ -70,4 +70,4 @@ class IssuesTest : AbstractModelTest("/src/main/kotlin/issues/Test.kt", "issues" // } // } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt index 191df066..2775fcf4 100644 --- a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt +++ b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt @@ -23,23 +23,23 @@ class LinkableContentTest : AbstractCoreTest() { val includesDir = getTestDataDir("linkable/includes").toAbsolutePath() val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { moduleName = "example" analysisPlatform = "js" sourceRoots = listOf("jsMain", "commonMain", "jvmAndJsSecondCommonMain").map { Paths.get("$testDataDir/$it/kotlin").toString() } - sourceSetID = "js" + name = "js" includes = listOf(Paths.get("$includesDir/include2.md").toString()) } - pass { + sourceSet { moduleName = "example" analysisPlatform = "jvm" sourceRoots = listOf("jvmMain", "commonMain", "jvmAndJsSecondCommonMain").map { Paths.get("$testDataDir/$it/kotlin").toString() } - sourceSetID = "jvm" + name = "jvm" includes = listOf(Paths.get("$includesDir/include1.md").toString()) } } @@ -62,8 +62,8 @@ class LinkableContentTest : AbstractCoreTest() { val testDataDir = getTestDataDir("linkable/sources").toAbsolutePath() val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { moduleName = "example" analysisPlatform = "js" sourceRoots = listOf("$testDataDir/jsMain/kotlin") @@ -74,9 +74,9 @@ class LinkableContentTest : AbstractCoreTest() { lineSuffix = "#L" ) ) - sourceSetID = "js" + name = "js" } - pass { + sourceSet { moduleName = "example" analysisPlatform = "jvm" sourceRoots = listOf("$testDataDir/jvmMain/kotlin") @@ -87,7 +87,7 @@ class LinkableContentTest : AbstractCoreTest() { lineSuffix = "#L" ) ) - sourceSetID = "jvm" + name = "jvm" } } } @@ -127,19 +127,19 @@ class LinkableContentTest : AbstractCoreTest() { val testDataDir = getTestDataDir("linkable/samples").toAbsolutePath() val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { moduleName = "example" analysisPlatform = "js" sourceRoots = listOf("$testDataDir/jsMain/kotlin") - sourceSetID = "js" + name = "js" samples = listOf("$testDataDir/jsMain/resources/Samples.kt") } - pass { + sourceSet { moduleName = "example" analysisPlatform = "jvm" sourceRoots = listOf("$testDataDir/jvmMain/kotlin") - sourceSetID = "jvm" + name = "jvm" samples = listOf("$testDataDir/jvmMain/resources/Samples.kt") } } @@ -196,11 +196,11 @@ class LinkableContentTest : AbstractCoreTest() { | """.trimIndent(), dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") analysisPlatform = "jvm" - sourceSetID = "js" + name = "js" } } } @@ -222,4 +222,4 @@ class LinkableContentTest : AbstractCoreTest() { } } } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/locationProvider/DefaultLocationProviderTest.kt b/plugins/base/src/test/kotlin/locationProvider/DefaultLocationProviderTest.kt index 1bc3ea29..a219fb04 100644 --- a/plugins/base/src/test/kotlin/locationProvider/DefaultLocationProviderTest.kt +++ b/plugins/base/src/test/kotlin/locationProvider/DefaultLocationProviderTest.kt @@ -10,8 +10,8 @@ class DefaultLocationProviderTest: AbstractCoreTest() { @Test fun `#644 same directory for module and package`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") } } @@ -38,4 +38,4 @@ class DefaultLocationProviderTest: AbstractCoreTest() { } } } -} \ 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 index 218f7244..f5b29322 100644 --- a/plugins/base/src/test/kotlin/markdown/KDocTest.kt +++ b/plugins/base/src/test/kotlin/markdown/KDocTest.kt @@ -9,8 +9,8 @@ import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest abstract class KDocTest : AbstractCoreTest() { private val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/example/Test.kt") } } @@ -44,4 +44,4 @@ abstract class KDocTest : AbstractCoreTest() { } } } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/markdown/LinkTest.kt b/plugins/base/src/test/kotlin/markdown/LinkTest.kt index ddcef5db..8e4e588e 100644 --- a/plugins/base/src/test/kotlin/markdown/LinkTest.kt +++ b/plugins/base/src/test/kotlin/markdown/LinkTest.kt @@ -13,8 +13,8 @@ class LinkTest : AbstractCoreTest() { @Test fun linkToClassLoader() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/parser") } } @@ -46,8 +46,8 @@ class LinkTest : AbstractCoreTest() { @Test fun returnTypeShouldHaveLinkToOuterClassFromInner() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin") } } @@ -75,4 +75,4 @@ class LinkTest : AbstractCoreTest() { } } } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/model/InheritorsTest.kt b/plugins/base/src/test/kotlin/model/InheritorsTest.kt index f5517abb..503cf50c 100644 --- a/plugins/base/src/test/kotlin/model/InheritorsTest.kt +++ b/plugins/base/src/test/kotlin/model/InheritorsTest.kt @@ -44,12 +44,12 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", @Test fun multiplatform() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("common/src/", "jvm/src/") analysisPlatform = "jvm" } - pass { + sourceSet { sourceRoots = listOf("common/src/", "js/src/") analysisPlatform = "js" } @@ -92,4 +92,4 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", } } } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/model/PropertyTest.kt b/plugins/base/src/test/kotlin/model/PropertyTest.kt index e384b920..af952b43 100644 --- a/plugins/base/src/test/kotlin/model/PropertyTest.kt +++ b/plugins/base/src/test/kotlin/model/PropertyTest.kt @@ -169,8 +169,8 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro |@Strictfp var property = "test" """, configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") classpath = listOfNotNull(jvmStdlibPath) } @@ -262,4 +262,4 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro // } // //} -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt b/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt index 5facd194..b3ac7b07 100644 --- a/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt +++ b/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt @@ -11,8 +11,8 @@ class BasicMultiplatformTest : AbstractCoreTest() { val testDataDir = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath() val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("$testDataDir/jvmMain/") } } @@ -28,8 +28,8 @@ class BasicMultiplatformTest : AbstractCoreTest() { @Test fun inlineTestExample() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/multiplatform/Test.kt") } } @@ -51,4 +51,4 @@ class BasicMultiplatformTest : AbstractCoreTest() { } } } -} \ 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 index 6ef38aa9..935b9377 100644 --- a/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt +++ b/plugins/base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt @@ -39,8 +39,8 @@ class PageNodeMergerTest : AbstractCoreTest() { fun sameNameStrategyTest() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/pageMerger/Test.kt") } } @@ -82,8 +82,8 @@ class PageNodeMergerTest : AbstractCoreTest() { val strList: MutableList = mutableListOf() val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/pageMerger/Test.kt") } } @@ -123,4 +123,4 @@ class PageNodeMergerTest : AbstractCoreTest() { fun PageNode.childrenRec(): List = listOf(this) + children.flatMap { it.childrenRec() } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt b/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt index 6ceb805b..d4778a8e 100644 --- a/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt +++ b/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt @@ -12,14 +12,14 @@ class DivergentTest : RenderingOnlyTestBase() { private val js = defaultSourceSet.copy( "root", "JS", - "js", + defaultSourceSet.sourceSetID.copy(sourceSetName = "js"), analysisPlatform = Platform.js, sourceRoots = listOf(SourceRootImpl("pl1")) ) private val jvm = defaultSourceSet.copy( "root", "JVM", - "jvm", + defaultSourceSet.sourceSetID.copy(sourceSetName = "jvm"), analysisPlatform = Platform.jvm, sourceRoots = listOf(SourceRootImpl("pl1")) @@ -27,7 +27,7 @@ class DivergentTest : RenderingOnlyTestBase() { private val native = defaultSourceSet.copy( "root", "NATIVE", - "native", + defaultSourceSet.sourceSetID.copy(sourceSetName = "native"), analysisPlatform = Platform.native, sourceRoots = listOf(SourceRootImpl("pl1")) ) @@ -344,4 +344,4 @@ class DivergentTest : RenderingOnlyTestBase() { Div(Div("b-", Span()), Div(Div(Div(("b")))), "ab+") ) } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt b/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt index c868cfd5..ea1ea9ae 100644 --- a/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt +++ b/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt @@ -15,21 +15,21 @@ class SourceSetDependentHintTest : RenderingOnlyTestBase() { private val pl1 = defaultSourceSet.copy( "root", "pl1", - "pl1", + defaultSourceSet.sourceSetID.copy(sourceSetName = "pl1"), analysisPlatform = Platform.js, sourceRoots = listOf(SourceRootImpl("pl1")) ) private val pl2 = defaultSourceSet.copy( "root", "pl2", - "pl2", + defaultSourceSet.sourceSetID.copy(sourceSetName = "pl2"), analysisPlatform = Platform.jvm, sourceRoots = listOf(SourceRootImpl("pl1")) ) private val pl3 = defaultSourceSet.copy( "root", "pl3", - "pl3", + defaultSourceSet.sourceSetID.copy(sourceSetName = "pl3"), analysisPlatform = Platform.native, sourceRoots = listOf(SourceRootImpl("pl1")) ) @@ -135,4 +135,4 @@ class SourceSetDependentHintTest : RenderingOnlyTestBase() { HtmlRenderer(context).render(page) renderedContent.match(Div(Div(Div("a")), Div(Div("b")))) } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/renderers/html/defaultSourceSet.kt b/plugins/base/src/test/kotlin/renderers/html/defaultSourceSet.kt index 771cabaa..a9be1cfd 100644 --- a/plugins/base/src/test/kotlin/renderers/html/defaultSourceSet.kt +++ b/plugins/base/src/test/kotlin/renderers/html/defaultSourceSet.kt @@ -1,15 +1,16 @@ package renderers.html +import org.jetbrains.dokka.DokkaSourceSetID import org.jetbrains.dokka.DokkaSourceSetImpl import org.jetbrains.dokka.Platform internal val defaultSourceSet = DokkaSourceSetImpl( - moduleName = "DEFAULT", + moduleDisplayName = "DEFAULT", displayName = "DEFAULT", - sourceSetID = "DEFAULT", + sourceSetID = DokkaSourceSetID("DEFAULT", "DEFAULT"), classpath = emptyList(), sourceRoots = emptyList(), - dependentSourceSets = emptyList(), + dependentSourceSets = emptySet(), samples = emptyList(), includes = emptyList(), includeNonPublic = false, @@ -27,4 +28,4 @@ internal val defaultSourceSet = DokkaSourceSetImpl( noJdkLink = false, suppressedFiles = emptyList(), analysisPlatform = Platform.DEFAULT -) \ No newline at end of file +) diff --git a/plugins/base/src/test/kotlin/resourceLinks/ResourceLinksTest.kt b/plugins/base/src/test/kotlin/resourceLinks/ResourceLinksTest.kt index be87813b..4f8a834b 100644 --- a/plugins/base/src/test/kotlin/resourceLinks/ResourceLinksTest.kt +++ b/plugins/base/src/test/kotlin/resourceLinks/ResourceLinksTest.kt @@ -26,8 +26,8 @@ class ResourceLinksTest : AbstractCoreTest() { @Test fun resourceLinksTest() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/test/Test.kt") } } @@ -68,4 +68,4 @@ class ResourceLinksTest : AbstractCoreTest() { } } } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt index e66490c1..d8e057da 100644 --- a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt +++ b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt @@ -21,8 +21,8 @@ class PageTransformerBuilderTest : AbstractCoreTest() { @Test fun scannerTest() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/transformerBuilder/Test.kt") } } @@ -58,8 +58,8 @@ class PageTransformerBuilderTest : AbstractCoreTest() { @Test fun mapperTest() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/transformerBuilder/Test.kt") } } @@ -98,8 +98,8 @@ class PageTransformerBuilderTest : AbstractCoreTest() { @Test fun structureTransformerTest() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/kotlin/transformerBuilder/Test.kt") } } diff --git a/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt b/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt index 523813fc..72948372 100644 --- a/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt +++ b/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt @@ -12,8 +12,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `undocumented class gets reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/kotlin/Test.kt") } @@ -39,8 +39,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `undocumented non-public class does not get reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/kotlin/Test.kt") } @@ -65,8 +65,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `undocumented function gets reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/kotlin/Test.kt") } @@ -95,8 +95,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `undocumented property gets reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/kotlin/Test.kt") } @@ -125,8 +125,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `undocumented primary constructor does not get reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/kotlin/Test.kt") } @@ -153,8 +153,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `data class component functions do not get reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/kotlin") } @@ -183,8 +183,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `undocumented secondary constructor gets reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/kotlin/Test.kt") } @@ -213,8 +213,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `undocumented inherited function does not get reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/kotlin/Test.kt") } @@ -246,8 +246,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `undocumented inherited property does not get reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/kotlin/Test.kt") } @@ -279,8 +279,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `overridden function does not get reported when super is documented`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/kotlin/Test.kt") } @@ -315,8 +315,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `overridden property does not get reported when super is documented`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/kotlin/Test.kt") } @@ -349,10 +349,10 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { } @Test - fun `report disabled by pass configuration`() { + fun `report disabled by source set`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = false sourceRoots = listOf("src/main/kotlin/Test.kt") } @@ -377,8 +377,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `report enabled by package configuration`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { perPackageOptions += packageOptions( prefix = "sample", reportUndocumented = true, @@ -407,8 +407,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `report enabled by more specific package configuration`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { perPackageOptions += packageOptions( prefix = "sample", reportUndocumented = false, @@ -445,8 +445,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `report disabled by more specific package configuration`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { perPackageOptions += packageOptions( prefix = "sample", reportUndocumented = true, @@ -483,22 +483,22 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `multiplatform undocumented class gets reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + val commonMain = sourceSet { reportUndocumented = true analysisPlatform = Platform.common.toString() - sourceSetID = "commonMain" + name = "commonMain" displayName = "commonMain" sourceRoots = listOf("src/commonMain/kotlin") } - pass { + sourceSet { reportUndocumented = true analysisPlatform = Platform.jvm.toString() - sourceSetID = "jvmMain" + name = "jvmMain" displayName = "jvmMain" sourceRoots = listOf("src/jvmMain/kotlin") - dependentSourceSets = listOf("commonMain") + dependentSourceSets = setOf(commonMain.sourceSetID) } } } @@ -526,22 +526,22 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `multiplatform undocumented class does not get reported if expect is documented`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + val commonMain = sourceSet { reportUndocumented = true analysisPlatform = Platform.common.toString() - sourceSetID = "commonMain" + name = "commonMain" displayName = "commonMain" sourceRoots = listOf("src/commonMain/kotlin") } - pass { + sourceSet { reportUndocumented = true analysisPlatform = Platform.jvm.toString() - sourceSetID = "jvmMain" + name = "jvmMain" displayName = "jvmMain" sourceRoots = listOf("src/jvmMain/kotlin") - dependentSourceSets = listOf("commonMain") + dependentSourceSets = setOf(commonMain.sourceSetID) } } } @@ -568,31 +568,31 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `multiplatform undocumented function gets reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + val commonMain = sourceSet { reportUndocumented = true analysisPlatform = Platform.common.toString() - sourceSetID = "commonMain" + name = "commonMain" displayName = "commonMain" sourceRoots = listOf("src/commonMain/kotlin") } - pass { + sourceSet { reportUndocumented = true analysisPlatform = Platform.jvm.toString() - sourceSetID = "jvmMain" + name = "jvmMain" displayName = "jvmMain" sourceRoots = listOf("src/jvmMain/kotlin") - dependentSourceSets = listOf("commonMain") + dependentSourceSets = setOf(commonMain.sourceSetID) } - pass { + sourceSet { reportUndocumented = true analysisPlatform = Platform.native.toString() - sourceSetID = "macosMain" + name = "macosMain" displayName = "macosMain" sourceRoots = listOf("src/macosMain/kotlin") - dependentSourceSets = listOf("commonMain") + dependentSourceSets = setOf(commonMain.sourceSetID) } } } @@ -625,8 +625,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `java undocumented class gets reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/java") } @@ -652,8 +652,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `java undocumented non-public class does not get reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/java") } @@ -677,8 +677,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `java undocumented constructor does not get reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/java") } @@ -706,8 +706,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `java undocumented method gets reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/java") } @@ -736,8 +736,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `java undocumented property gets reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/java") } @@ -766,8 +766,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `java undocumented inherited method gets reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/java") } @@ -805,8 +805,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `java documented inherited method does not get reported`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/java") } @@ -842,8 +842,8 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() { @Test fun `java overridden function does not get reported when super is documented`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { reportUndocumented = true sourceRoots = listOf("src/main/java") } diff --git a/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt b/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt index 5f8a7864..95fbb3c6 100644 --- a/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt +++ b/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt @@ -12,8 +12,8 @@ class DefaultPsiToDocumentableTranslatorTest : AbstractCoreTest() { @Test fun `method overriding two documented classes picks closest class documentation`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/java") } } @@ -57,8 +57,8 @@ class DefaultPsiToDocumentableTranslatorTest : AbstractCoreTest() { @Test fun `method overriding class and interface picks class documentation`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/java") } } @@ -102,8 +102,8 @@ class DefaultPsiToDocumentableTranslatorTest : AbstractCoreTest() { @Test fun `method overriding two classes picks closest documented class documentation`() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/main/java") } } @@ -153,4 +153,4 @@ class DefaultPsiToDocumentableTranslatorTest : AbstractCoreTest() { ?.body.orEmpty() } -} \ No newline at end of file +} diff --git a/plugins/base/src/test/kotlin/utils/ModelUtils.kt b/plugins/base/src/test/kotlin/utils/ModelUtils.kt index 9697a843..87a9c802 100644 --- a/plugins/base/src/test/kotlin/utils/ModelUtils.kt +++ b/plugins/base/src/test/kotlin/utils/ModelUtils.kt @@ -16,8 +16,8 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo block: DModule.() -> Unit ) { val testConfiguration = configuration ?: dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") analysisPlatform = platform } diff --git a/plugins/gfm/src/main/kotlin/GfmPlugin.kt b/plugins/gfm/src/main/kotlin/GfmPlugin.kt index b955d403..287ef74f 100644 --- a/plugins/gfm/src/main/kotlin/GfmPlugin.kt +++ b/plugins/gfm/src/main/kotlin/GfmPlugin.kt @@ -140,7 +140,7 @@ open class CommonmarkRenderer( platforms.joinToString( prefix = " [", postfix = "] $text " - ) { "${it.moduleName}/${it.sourceSetID}" }) + ) { "${it.moduleDisplayName}/${it.sourceSetID}" }) buildNewLine() } } @@ -157,7 +157,7 @@ open class CommonmarkRenderer( ) { if(node.dci.kind == ContentKind.Sample || node.dci.kind == ContentKind.Parameters){ node.sourceSets.forEach {sourcesetData -> - append("${sourcesetData.moduleName}/${sourcesetData.sourceSetID}") + append("${sourcesetData.moduleDisplayName}/${sourcesetData.sourceSetID}") buildNewLine() buildTable(node.copy(children = node.children.filter { it.sourceSets.contains(sourcesetData) }, dci = node.dci.copy(kind = ContentKind.Main)), pageContext, sourceSetRestriction) buildNewLine() @@ -286,4 +286,4 @@ class MarkdownLocationProvider( dokkaContext ) { override val extension = ".md" -} \ No newline at end of file +} diff --git a/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt index 138208ae..4fa65c58 100644 --- a/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt +++ b/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt @@ -15,8 +15,8 @@ import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest internal abstract class AbstractJavadocTemplateMapTest : AbstractCoreTest() { protected var config: DokkaConfigurationImpl = dokkaConfiguration { format = "javadoc" - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src") analysisPlatform = "jvm" } @@ -62,7 +62,6 @@ internal abstract class AbstractJavadocTemplateMapTest : AbstractCoreTest() { ) { testInline(query, configuration) { renderingStage = { rootPageNode, dokkaContext -> - // TODO NOW: Clarify preprocessors! val transformedRootPageNode = preprocessors.fold(rootPageNode) { acc, pageTransformer -> pageTransformer(acc) } diff --git a/plugins/javadoc/src/test/kotlin/javadoc/JavadocTest.kt b/plugins/javadoc/src/test/kotlin/javadoc/JavadocTest.kt index 905cb61b..31a33ad5 100644 --- a/plugins/javadoc/src/test/kotlin/javadoc/JavadocTest.kt +++ b/plugins/javadoc/src/test/kotlin/javadoc/JavadocTest.kt @@ -10,8 +10,8 @@ class JavadocTest : AbstractCoreTest() { fun test() { val config = dokkaConfiguration { format = "javadoc" - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("jvmSrc/") analysisPlatform = "jvm" } diff --git a/plugins/javadoc/src/test/kotlin/javadoc/location/JavadocLocationTest.kt b/plugins/javadoc/src/test/kotlin/javadoc/location/JavadocLocationTest.kt index cbaa3dd6..a47f0142 100644 --- a/plugins/javadoc/src/test/kotlin/javadoc/location/JavadocLocationTest.kt +++ b/plugins/javadoc/src/test/kotlin/javadoc/location/JavadocLocationTest.kt @@ -23,8 +23,8 @@ class JavadocTest : AbstractCoreTest() { val config = dokkaConfiguration { format = "javadoc" - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("jvmSrc/") externalDocumentationLinks = listOf( externalLink("https://docs.oracle.com/javase/8/docs/api/"), @@ -60,4 +60,4 @@ class JavadocTest : AbstractCoreTest() { } } } -} \ No newline at end of file +} diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt index db87051b..96446201 100644 --- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt +++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt @@ -3,7 +3,6 @@ package kotlinAsJavaPlugin import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import org.jetbrains.kotlin.utils.addToStdlib.cast -import org.jetbrains.kotlin.utils.addToStdlib.safeAs import org.junit.jupiter.api.Test class KotlinAsJavaPluginTest : AbstractCoreTest() { @@ -11,8 +10,8 @@ class KotlinAsJavaPluginTest : AbstractCoreTest() { @Test fun topLevelTest() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") } } @@ -49,8 +48,8 @@ class KotlinAsJavaPluginTest : AbstractCoreTest() { @Test fun topLevelWithClassTest() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") } } @@ -90,8 +89,8 @@ class KotlinAsJavaPluginTest : AbstractCoreTest() { @Test fun kotlinAndJavaTest() { val configuration = dokkaConfiguration { - passes { - pass { + sourceSets { + sourceSet { sourceRoots = listOf("src/") } } diff --git a/runners/ant/build.gradle b/runners/ant/build.gradle deleted file mode 100644 index 216420c6..00000000 --- a/runners/ant/build.gradle +++ /dev/null @@ -1,18 +0,0 @@ -apply plugin: 'kotlin' - -sourceCompatibility = 1.8 - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions { - freeCompilerArgs += "-Xjsr305=strict" - languageVersion = language_version - apiVersion = language_version - jvmTarget = "1.8" - } -} - -dependencies { - compile project(":core") - compileOnly group: 'org.apache.ant', name: 'ant', version: ant_version -} - diff --git a/runners/ant/src/main/kotlin/ant/dokka.kt b/runners/ant/src/main/kotlin/ant/dokka.kt deleted file mode 100644 index d275ed82..00000000 --- a/runners/ant/src/main/kotlin/ant/dokka.kt +++ /dev/null @@ -1,210 +0,0 @@ -package org.jetbrains.dokka.ant - -import org.apache.tools.ant.BuildException -import org.apache.tools.ant.Project -import org.apache.tools.ant.Task -import org.apache.tools.ant.types.Path -import org.apache.tools.ant.types.Reference -import org.jetbrains.dokka.* -import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink -import org.jetbrains.dokka.utilities.DokkaConsoleLogger -import org.jetbrains.dokka.utilities.DokkaLogger -import java.io.File - -class AntLogger(val task: Task): DokkaLogger { - override var warningsCount: Int = 0 - override var errorsCount: Int = 0 - override fun debug(message: String) = task.log(message, Project.MSG_DEBUG) - override fun info(message: String) = task.log(message, Project.MSG_VERBOSE) - override fun progress(message: String) = task.log(message, Project.MSG_INFO) - override fun warn(message: String) = task.log(message, Project.MSG_WARN).also { warningsCount++ } - override fun error(message: String) = task.log(message, Project.MSG_ERR).also { errorsCount++ } - override fun report() { - if (warningsCount > 0 || errorsCount > 0) { - task.log("Generation completed with $warningsCount warning" + - (if(warningsCount == 1) "" else "s") + - " and $errorsCount error" + - if(errorsCount == 1) "" else "s" - ) - } else { - task.log("generation completed successfully") - } - } -} - -class AntSourceLinkDefinition(var path: String? = null, var url: String? = null, var lineSuffix: String? = null) - -class AntSourceRoot(var path: String? = null) { - fun toSourceRoot(): SourceRootImpl? = path?.let { path -> - SourceRootImpl(path) - } -} - -class TextProperty(var value: String = "") - -class AntPassConfig(task: Task) : DokkaConfiguration.PassConfiguration { - override var moduleName: String = "" - override val classpath: List - get() = buildClassPath.list().toList() - - override val sourceRoots: List - get() = sourcePath.list().map { SourceRootImpl(it) } + antSourceRoots.mapNotNull { it.toSourceRoot() } - - override val samples: List - get() = samplesPath.list().toList() - override val includes: List - get() = includesPath.list().toList() - override var includeNonPublic: Boolean = false - override var includeRootPackage: Boolean = true - override var reportUndocumented: Boolean = false - override var skipEmptyPackages: Boolean = true - override var skipDeprecated: Boolean = false - override var jdkVersion: Int = 8 - override val sourceLinks: List - get() = antSourceLinkDefinition.map { - val path = it.path!! - val url = it.url!! - SourceLinkDefinitionImpl(File(path).canonicalFile.absolutePath, url, it.lineSuffix) - } - override val perPackageOptions: MutableList = mutableListOf() - override val externalDocumentationLinks: List - get() = buildExternalLinksBuilders.map { it.build() } + defaultExternalDocumentationLinks - - override var languageVersion: String? = null - override var apiVersion: String? = null - override var noStdlibLink: Boolean = false - override var noJdkLink: Boolean = false - override var suppressedFiles: MutableList = mutableListOf() - override var collectInheritedExtensionsFromLibraries: Boolean = false - override var analysisPlatform: Platform = Platform.DEFAULT - override var targets: List = listOf() - get() = buildTargets.filter { it.value != "" } - .map { it.value } - - override var sinceKotlin: String? = null - - private val samplesPath: Path by lazy { Path(task.project) } - private val includesPath: Path by lazy { Path(task.project) } - private val buildClassPath: Path by lazy { Path(task.project) } - val sourcePath: Path by lazy { Path(task.project) } - val antSourceRoots: MutableList = mutableListOf() - - private val buildTargets: MutableList = mutableListOf() - private val buildExternalLinksBuilders: MutableList = mutableListOf() - val antSourceLinkDefinition: MutableList = mutableListOf() - - private val defaultExternalDocumentationLinks: List - get() { - val links = mutableListOf() - if (!noJdkLink) - links += DokkaConfiguration.ExternalDocumentationLink.Builder("https://docs.oracle.com/javase/$jdkVersion/docs/api/").build() - - if (!noStdlibLink) - links += DokkaConfiguration.ExternalDocumentationLink.Builder("https://kotlinlang.org/api/latest/jvm/stdlib/").build() - return links - } - - - fun setSamples(ref: Path) { - samplesPath.append(ref) - } - - fun setSamplesRef(ref: Reference) { - samplesPath.createPath().refid = ref - } - - fun setInclude(ref: Path) { - includesPath.append(ref) - } - - fun setClasspath(classpath: Path) { - buildClassPath.append(classpath) - } - - fun createPackageOptions(): AntPackageOptions = AntPackageOptions().apply { perPackageOptions.add(this) } - - fun createSourceRoot(): AntSourceRoot = AntSourceRoot().apply { antSourceRoots.add(this) } - - fun createTarget(): TextProperty = TextProperty().apply { - buildTargets.add(this) - } - - fun setClasspathRef(ref: Reference) { - buildClassPath.createPath().refid = ref - } - - fun setSrc(src: Path) { - sourcePath.append(src) - } - - fun setSrcRef(ref: Reference) { - sourcePath.createPath().refid = ref - } - - fun createSourceLink(): AntSourceLinkDefinition { - val def = AntSourceLinkDefinition() - antSourceLinkDefinition.add(def) - return def - } - - fun createExternalDocumentationLink() = - ExternalDocumentationLink.Builder().apply { buildExternalLinksBuilders.add(this) } - -} - -class AntPackageOptions( - override var prefix: String = "", - override var includeNonPublic: Boolean = false, - override var reportUndocumented: Boolean = true, - override var skipDeprecated: Boolean = false, - override var suppress: Boolean = false) : DokkaConfiguration.PackageOptions - -class DokkaAntTask: Task(), DokkaConfiguration { - - override var format: String = "html" - override var generateIndexPages: Boolean = false - override var outputDir: String = "" - override var impliedPlatforms: List = listOf() - get() = buildImpliedPlatforms.map { it.value }.toList() - private val buildImpliedPlatforms: MutableList = mutableListOf() - - override var cacheRoot: String? = null - override val passesConfigurations: MutableList = mutableListOf() - override var pluginsClasspath: List = mutableListOf() - - fun createPassConfig() = AntPassConfig(this).apply { passesConfigurations.add(this) } - fun createImpliedPlatform(): TextProperty = TextProperty().apply { buildImpliedPlatforms.add(this) } - - - override fun execute() { - for (passConfig in passesConfigurations) { - if (passConfig.sourcePath.list().isEmpty() && passConfig.antSourceRoots.isEmpty()) { - throw BuildException("At least one source path needs to be specified") - } - - if (passConfig.moduleName == "") { - throw BuildException("Module name needs to be specified and not empty") - } - - for (sourceLink in passConfig.antSourceLinkDefinition) { - if (sourceLink.path == null) { - throw BuildException("'path' attribute of a element is required") - } - if (sourceLink.path!!.contains("\\")) { - throw BuildException("'dir' attribute of a - incorrect value, only Unix based path allowed") - } - - if (sourceLink.url == null) { - throw BuildException("'url' attribute of a element is required") - } - } - } - - if (outputDir == "") { - throw BuildException("Output directory needs to be specified and not empty") - } - - val generator = DokkaGenerator(this, AntLogger(this)) - generator.generate() - } -} \ No newline at end of file diff --git a/runners/ant/src/main/resources/dokka-antlib.xml b/runners/ant/src/main/resources/dokka-antlib.xml deleted file mode 100644 index 9c3373d5..00000000 --- a/runners/ant/src/main/resources/dokka-antlib.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/runners/cli/build.gradle.kts b/runners/cli/build.gradle.kts index 8c4955ca..bc09f2cd 100644 --- a/runners/cli/build.gradle.kts +++ b/runners/cli/build.gradle.kts @@ -10,7 +10,6 @@ repositories { dependencies { implementation("org.jetbrains.kotlinx:kotlinx-cli-jvm:0.2.1") - implementation("com.google.code.gson:gson:2.8.5") implementation(project(":core")) implementation(kotlin("stdlib")) } @@ -36,4 +35,4 @@ publishing { } } -configureBintrayPublication("dokkaCli") \ No newline at end of file +configureBintrayPublication("dokkaCli") diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index b0fb45b2..5e5cd6b2 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -1,6 +1,5 @@ package org.jetbrains.dokka -import com.google.gson.Gson import kotlinx.cli.* import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet.* @@ -34,7 +33,7 @@ class GlobalArguments(args: Array) : DokkaConfiguration { override val sourceSets by parser.option( ArgTypeArgument, description = "Single dokka source set", - fullName = "pass" + fullName = "sourceSet" ).multiple() override val pluginsConfiguration by parser.option( @@ -60,7 +59,7 @@ class GlobalArguments(args: Array) : DokkaConfiguration { val globalPackageOptions by parser.option( ArgType.String, - description = "List of package passConfiguration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" " + description = "List of package source sets in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" " ).delimiter(";") val globalLinks by parser.option( @@ -73,9 +72,9 @@ class GlobalArguments(args: Array) : DokkaConfiguration { description = "Mapping between a source directory and a Web site for browsing the code (allows many paths separated by the semicolon `;`)" ).delimiter(";") - val helpPass by parser.option( - ArgTypeHelpPass, - description = "Prints help for single -pass" + val helpSourceSet by parser.option( + ArgTypeHelpSourceSet, + description = "Prints help for single -sourceSet" ) override val modules: List = emptyList() @@ -94,8 +93,8 @@ class GlobalArguments(args: Array) : DokkaConfiguration { globalSrcLink.forEach { if (it.isNotEmpty() && it.contains("=")) - sourceSets.all { pass -> - pass.sourceLinks.cast>() + sourceSets.all { sourceSet -> + sourceSet.sourceLinks.cast>() .add(SourceLinkDefinitionImpl.parseSourceLinkDefinition(it)) } else { @@ -112,9 +111,9 @@ class GlobalArguments(args: Array) : DokkaConfiguration { } } -fun passArguments(args: Array): DokkaConfiguration.DokkaSourceSet { +private fun parseSourceSet(args: Array): DokkaConfiguration.DokkaSourceSet { - val parser = ArgParser("passConfiguration", prefixStyle = ArgParser.OptionPrefixStyle.JVM) + val parser = ArgParser("sourceSet", prefixStyle = ArgParser.OptionPrefixStyle.JVM) val moduleName by parser.option( ArgType.String, @@ -122,16 +121,21 @@ fun passArguments(args: Array): DokkaConfiguration.DokkaSourceSet { fullName = "module" ).required() - val displayName by parser.option( + val moduleDisplayName by parser.option( ArgType.String, - description = "Name of the source set" - ).default("JVM") + description = "Name of the documentation module" + ) - val sourceSetID by parser.option( + val name by parser.option( ArgType.String, - description = "ID of the source set" + description = "Name of the source set" ).default("main") + val displayName by parser.option( + ArgType.String, + description = "Displayed name of the source set" + ).default("JVM") + val classpath by parser.option( ArgType.String, description = "Classpath for symbol resolution (allows many paths separated by the semicolon `;`)" @@ -213,7 +217,7 @@ fun passArguments(args: Array): DokkaConfiguration.DokkaSourceSet { val perPackageOptions by parser.option( ArgType.String, - description = "List of package passConfiguration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" " + description = "List of package source set configuration in format \"prefix,-deprecated,-privateApi,+warnUndocumented,+suppress;...\" " ).delimiter(";") val externalDocumentationLinks by parser.option( @@ -230,12 +234,14 @@ fun passArguments(args: Array): DokkaConfiguration.DokkaSourceSet { parser.parse(args) return object : DokkaConfiguration.DokkaSourceSet { - override val moduleName = moduleName + override val moduleDisplayName = moduleDisplayName ?: moduleName override val displayName = displayName - override val sourceSetID = sourceSetID + override val sourceSetID = DokkaSourceSetID(moduleName, name) override val classpath = classpath override val sourceRoots = sourceRoots.map { SourceRootImpl(it.toAbsolutePath()) } - override val dependentSourceSets: List = dependentSourceSets + override val dependentSourceSets: Set = dependentSourceSets + .map { dependentSourceSetName -> DokkaSourceSetID(moduleName, dependentSourceSetName) } + .toSet() override val samples = samples.map { it.toAbsolutePath() } override val includes = includes.map { it.toAbsolutePath() } override val includeNonPublic = includeNonPublic @@ -294,15 +300,15 @@ object ArgTypeSourceLinkDefinition : ArgType(true) { override fun convert(value: kotlin.String, name: kotlin.String): DokkaConfiguration.DokkaSourceSet = - passArguments(value.split(" ").filter { it.isNotBlank() }.toTypedArray()) + parseSourceSet(value.split(" ").filter { it.isNotBlank() }.toTypedArray()) override val description: kotlin.String get() = "" } // Workaround for printing nested parsers help -object ArgTypeHelpPass : ArgType(false) { - override fun convert(value: kotlin.String, name: kotlin.String): Any = Any().also { passArguments(arrayOf("-h")) } +object ArgTypeHelpSourceSet : ArgType(false) { + override fun convert(value: kotlin.String, name: kotlin.String): Any = Any().also { parseSourceSet(arrayOf("-h")) } override val description: kotlin.String get() = "" @@ -345,11 +351,10 @@ fun parseLinks(links: List): List { fun main(args: Array) { val globalArguments = GlobalArguments(args) val configuration = if (globalArguments.json != null) - Gson().fromJson( - Paths.get(globalArguments.json).toFile().readText(), - DokkaConfigurationImpl::class.java + DokkaConfigurationImpl( + Paths.get(checkNotNull(globalArguments.json)).toFile().readText() ) else globalArguments DokkaGenerator(configuration, DokkaConsoleLogger).generate() -} \ No newline at end of file +} diff --git a/runners/gradle-plugin/build.gradle.kts b/runners/gradle-plugin/build.gradle.kts index 71d7e72f..2c25a707 100644 --- a/runners/gradle-plugin/build.gradle.kts +++ b/runners/gradle-plugin/build.gradle.kts @@ -19,6 +19,8 @@ dependencies { compileOnly(gradleKotlinDsl()) testImplementation(gradleApi()) testImplementation(kotlin("test-junit")) + testImplementation("org.jetbrains.kotlin:kotlin-gradle-plugin") + constraints { val kotlin_version: String by project compileOnly("org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}") { diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt index 3bd0b6ab..c9693467 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt @@ -169,4 +169,4 @@ class ConfigurationExtractor(private val project: Project) { val dependentSourceSets: List, val platform: String ) : Serializable -} \ No newline at end of file +} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt index ead0f90a..823206e3 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt @@ -19,7 +19,7 @@ open class DokkaCollectorTask : DefaultTask() { @TaskAction fun collect() { - val passesConfigurations = getProjects(project).filter { it.name in modules }.flatMap { + val sourceSets = getProjects(project).filter { it.name in modules }.flatMap { val tasks = try { it.tasks.withType(DokkaTask::class.java) } catch (e: UnknownTaskException) { @@ -30,11 +30,11 @@ open class DokkaCollectorTask : DefaultTask() { val initial = GradleDokkaConfigurationImpl().apply { outputDir = outputDirectory - cacheRoot = passesConfigurations.first().cacheRoot - format = passesConfigurations.first().format + cacheRoot = sourceSets.first().cacheRoot + format = sourceSets.first().format } - configuration = passesConfigurations.fold(initial) { acc, it: GradleDokkaConfigurationImpl -> + configuration = sourceSets.fold(initial) { acc, it: GradleDokkaConfigurationImpl -> if(acc.format != it.format || acc.cacheRoot != it.cacheRoot) throw IllegalStateException("Dokka task configurations differ on core arguments (format, cacheRoot)") acc.sourceSets = acc.sourceSets + it.sourceSets diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetIDFactory.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetIDFactory.kt new file mode 100644 index 00000000..3fadb4fd --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetIDFactory.kt @@ -0,0 +1,10 @@ +@file:Suppress("FunctionName") + +package org.jetbrains.dokka.gradle + +import org.gradle.api.Project +import org.jetbrains.dokka.DokkaSourceSetID + +internal fun DokkaSourceSetID(project: Project, sourceSetName: String): DokkaSourceSetID { + return DokkaSourceSetID(moduleName = project.path, sourceSetName = sourceSetName) +} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt index e27357c9..aac7e2a0 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt @@ -7,11 +7,9 @@ import org.gradle.api.file.FileCollection import org.gradle.api.internal.plugins.DslObject import org.gradle.api.plugins.JavaBasePlugin import org.gradle.api.tasks.* -import org.jetbrains.dokka.DokkaBootstrap +import org.jetbrains.dokka.* import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink.Builder import org.jetbrains.dokka.DokkaConfiguration.SourceRoot -import org.jetbrains.dokka.DokkaException -import org.jetbrains.dokka.Platform import org.jetbrains.dokka.ReflectDsl import org.jetbrains.dokka.ReflectDsl.isNotInstance import org.jetbrains.dokka.gradle.ConfigurationExtractor.PlatformData @@ -183,10 +181,7 @@ open class DokkaTask : DefaultTask(), Configurable { val defaultModulesConfiguration = configuredDokkaSourceSets .map { configureDefault(it, globalConfig) }.takeIf { it.isNotEmpty() } ?: listOf( - configureDefault( - configureDokkaSourceSet(GradleDokkaSourceSet("main")), - null - ) + configureDefault(configureDokkaSourceSet(GradleDokkaSourceSet("main", project)), null) ).takeIf { project.isNotMultiplatformProject() } ?: emptyList() if (defaultModulesConfiguration.isEmpty()) { @@ -288,28 +283,25 @@ open class DokkaTask : DefaultTask(), Configurable { protected fun mergeUserConfigurationAndPlatformData( userConfig: GradleDokkaSourceSet, autoConfig: PlatformData - ) = - userConfig.copy().apply { - sourceRoots.addAll(userConfig.sourceRoots.union(autoConfig.sourceRoots.toSourceRoots()).distinct()) - dependentSourceSets.addAll(userConfig.dependentSourceSets.union(autoConfig.dependentSourceSets).distinct()) - classpath = userConfig.classpath.union(autoConfig.classpath.map { it.absolutePath }).distinct() - if (userConfig.platform == null && autoConfig.platform != "") - platform = autoConfig.platform - } + ) = userConfig.copy().apply { + sourceRoots.addAll(userConfig.sourceRoots.union(autoConfig.sourceRoots.toSourceRoots()).distinct()) + dependentSourceSets.addAll(userConfig.dependentSourceSets) + dependentSourceSets.addAll(autoConfig.dependentSourceSets.map { DokkaSourceSetID(project, it) }) + classpath = userConfig.classpath.union(autoConfig.classpath.map { it.absolutePath }).distinct() + if (userConfig.platform == null && autoConfig.platform != "") + platform = autoConfig.platform + } protected fun configureDefault( config: GradleDokkaSourceSet, globalConfig: GradleDokkaSourceSet? ): GradleDokkaSourceSet { - if (config.moduleName.isBlank()) { - config.moduleName = project.name + if (config.moduleDisplayName.isBlank()) { + config.moduleDisplayName = project.name } - if (config.sourceSetID.isBlank()) { - config.sourceSetID = config.moduleName + "/" + config.name - } - config.dependentSourceSets = config.dependentSourceSets.map { config.moduleName + "/" + it }.toMutableList() + if (config.displayName.isBlank()) { - config.displayName = config.sourceSetID.substringBeforeLast("Main", config.platform.toString()) + config.displayName = config.name.substringBeforeLast("Main", config.platform.toString()) } config.classpath = (config.classpath as List).map { it.toString() }.distinct() // Workaround for Groovy's GStringImpl diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt index a28416d6..7b2d05a6 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt @@ -1,13 +1,19 @@ +@file:Suppress("FunctionName") + package org.jetbrains.dokka.gradle +import com.android.build.gradle.api.AndroidSourceSet import groovy.lang.Closure import org.gradle.api.Action +import org.gradle.api.Project import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Internal import org.gradle.api.tasks.Optional import org.gradle.util.ConfigureUtil import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.DokkaConfiguration.* import org.jetbrains.dokka.DokkaDefaults +import org.jetbrains.dokka.DokkaSourceSetID import org.jetbrains.dokka.Platform import java.io.File import java.io.Serializable @@ -15,6 +21,8 @@ import java.net.URL import java.util.concurrent.Callable import kotlin.reflect.KMutableProperty import kotlin.reflect.full.memberProperties +import org.gradle.api.tasks.SourceSet as GradleSourceSet +import org.jetbrains.kotlin.gradle.model.SourceSet as KotlinSourceSet class GradleSourceRootImpl : SourceRoot, Serializable { override var path: String = "" @@ -25,64 +33,113 @@ class GradleSourceRootImpl : SourceRoot, Serializable { override fun toString(): String = path } -open class GradleDokkaSourceSet(@Transient val name: String = "") : DokkaSourceSet { +open class GradleDokkaSourceSet constructor( + @Transient val name: String, + @Transient internal val project: Project +) : DokkaSourceSet { + @Input @Optional override var classpath: List = emptyList() + @Input - override var moduleName: String = "" + override var moduleDisplayName: String = "" + @Input override var displayName: String = "" - @Input - override var sourceSetID: String = "" + + @get:Internal + override val sourceSetID: DokkaSourceSetID = DokkaSourceSetID(project, name) + @Input override var sourceRoots: MutableList = mutableListOf() + @Input - override var dependentSourceSets: MutableList = mutableListOf() + override var dependentSourceSets: MutableSet = mutableSetOf() + @Input override var samples: List = emptyList() + @Input override var includes: List = emptyList() + @Input override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic + @Input override var includeRootPackage: Boolean = DokkaDefaults.includeRootPackage + @Input override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented + @Input override var skipEmptyPackages: Boolean = DokkaDefaults.skipEmptyPackages + @Input override var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated + @Input override var jdkVersion: Int = DokkaDefaults.jdkVersion + @Input override var sourceLinks: MutableList = mutableListOf() + @Input override var perPackageOptions: MutableList = mutableListOf() + @Input override var externalDocumentationLinks: MutableList = mutableListOf() + @Input @Optional override var languageVersion: String? = null + @Input @Optional override var apiVersion: String? = null + @Input override var noStdlibLink: Boolean = DokkaDefaults.noStdlibLink + @Input override var noJdkLink: Boolean = DokkaDefaults.noJdkLink + @Input var noAndroidSdkLink: Boolean = false + @Input override var suppressedFiles: List = emptyList() + @Input override var analysisPlatform: Platform = DokkaDefaults.analysisPlatform + @Input @Optional var platform: String? = null + @Transient var collectKotlinTasks: (() -> List?)? = null + fun DokkaSourceSetID(sourceSetName: String): DokkaSourceSetID { + return DokkaSourceSetID(project, sourceSetName) + } + + fun dependsOn(sourceSet: GradleSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) + } + + fun dependsOn(sourceSet: DokkaSourceSet) { + dependsOn(sourceSet.sourceSetID) + } + + fun dependsOn(sourceSetName: String) { + dependsOn(DokkaSourceSetID(sourceSetName)) + } + + fun dependsOn(sourceSetID: DokkaSourceSetID) { + dependentSourceSets.add(sourceSetID) + } + fun kotlinTasks(taskSupplier: Callable>) { collectKotlinTasks = { taskSupplier.call() } } @@ -136,6 +193,18 @@ open class GradleDokkaSourceSet(@Transient val name: String = "") : DokkaSourceS } } +fun GradleDokkaSourceSet.dependsOn(sourceSet: KotlinSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) +} + +fun GradleDokkaSourceSet.dependsOn(sourceSet: org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) +} + +fun GradleDokkaSourceSet.dependsOn(sourceSet: AndroidSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) +} + class GradleSourceLinkDefinitionImpl : SourceLinkDefinition, Serializable { override var path: String = "" override var url: String = "" @@ -174,16 +243,16 @@ class GradlePackageOptionsImpl : PackageOptions, Serializable { } internal fun GradleDokkaSourceSet.copy(): GradleDokkaSourceSet { - val newObj = GradleDokkaSourceSet(this.name) + val newObj = GradleDokkaSourceSet(this.name, this.project) this::class.memberProperties.forEach { field -> if (field is KMutableProperty<*>) { - val value = field.getter.call(this) - if (value is Collection<*>) { - field.setter.call(newObj, value.toMutableList()) - } else { - field.setter.call(newObj, field.getter.call(this)) + when (val value = field.getter.call(this)) { + is List<*> -> field.setter.call(newObj, value.toMutableList()) + is Set<*> -> field.setter.call(newObj, value.toMutableSet()) + else -> field.setter.call(newObj, field.getter.call(this)) } + } } return newObj -} \ No newline at end of file +} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt index 92d63a40..a92f5475 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt @@ -53,7 +53,9 @@ open class DokkaPlugin : Plugin { project.tasks.create(DOKKA_TASK_NAME, taskClass) } project.tasks.withType(taskClass) { task -> - task.dokkaSourceSets = project.container(GradleDokkaSourceSet::class.java) + task.dokkaSourceSets = project.container(GradleDokkaSourceSet::class.java) { name -> + GradleDokkaSourceSet(name, project) + } task.dokkaRuntime = runtimeConfiguration task.pluginsClasspathConfiguration = pluginsConfiguration task.outputDirectory = File(project.buildDir, DOKKA_TASK_NAME).absolutePath diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt index 0b80f4a2..da6daeea 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt @@ -1,6 +1,9 @@ package org.jetbrains.dokka.gradle +import org.gradle.api.plugins.JavaPluginExtension import org.gradle.testfixtures.ProjectBuilder +import org.jetbrains.dokka.DokkaSourceSetID +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import kotlin.test.Test import kotlin.test.assertEquals @@ -16,4 +19,78 @@ class KotlinDslDokkaTaskConfigurationTest { assertEquals("test", dokkaTask.outputFormat) } } + + @Test + fun `sourceSet dependsOn by String`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("org.jetbrains.dokka") + + project.dokka { + dokkaSourceSets.run { + val commonMain = create("commonMain") + val jvmMain = create("jvmMain") { + it.dependsOn("commonMain") + } + + assertEquals( + 0, commonMain.dependentSourceSets.size, + "Expected no dependent source set in commonMain" + ) + + assertEquals( + 1, jvmMain.dependentSourceSets.size, + "Expected only one dependent source set in jvmMain" + ) + + assertEquals( + commonMain.sourceSetID, jvmMain.dependentSourceSets.single(), + "Expected jvmMain to depend on commonMain" + ) + + assertEquals( + DokkaSourceSetID(project.path, "commonMain"), commonMain.sourceSetID + ) + } + } + } + + @Test + fun `sourceSet dependsOn by DokkaSourceSet`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("org.jetbrains.dokka") + + project.dokka { + dokkaSourceSets.run { + val commonMain = create("commonMain") + val jvmMain = create("jvmMain") { + it.dependsOn(commonMain) + } + + assertEquals( + commonMain.sourceSetID, jvmMain.dependentSourceSets.single() + ) + } + } + } + + @Test + fun `sourceSet dependsOn by KotlinSourceSet`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("org.jetbrains.dokka") + project.plugins.apply("org.jetbrains.kotlin.jvm") + + val kotlin = project.extensions.getByName("kotlin") as KotlinJvmProjectExtension + + project.dokka { + dokkaSourceSets.run { + val special = create("special") { + it.dependsOn(kotlin.sourceSets.getByName("main")) + } + + assertEquals( + DokkaSourceSetID(project, "main"), special.dependentSourceSets.single() + ) + } + } + } } diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index 4c10568c..8160ab87 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -90,9 +90,6 @@ abstract class AbstractDokkaMojo : AbstractMojo() { @Parameter var sourceRoots: List = emptyList() - @Parameter - var dependentSourceSets: List = emptyList() - @Parameter var samples: List = emptyList() @@ -108,6 +105,9 @@ abstract class AbstractDokkaMojo : AbstractMojo() { @Parameter(required = true, defaultValue = "\${project.artifactId}") var moduleName: String = "" + @Parameter + var moduleDisplayName: String = "" + @Parameter(required = false, defaultValue = "false") var skip: Boolean = false @@ -201,12 +201,12 @@ abstract class AbstractDokkaMojo : AbstractMojo() { } val sourceSet = DokkaSourceSetImpl( - moduleName = moduleName, + moduleDisplayName = moduleDisplayName.takeIf(String::isNotBlank) ?: moduleName, displayName = displayName, - sourceSetID = sourceSetName, + sourceSetID = DokkaSourceSetID(moduleName, sourceSetName), classpath = classpath, sourceRoots = sourceDirectories.map { SourceRootImpl(it) }, - dependentSourceSets = dependentSourceSets, + dependentSourceSets = emptySet(), samples = samples, includes = includes, includeNonPublic = includeNonPublic, @@ -246,7 +246,7 @@ abstract class AbstractDokkaMojo : AbstractMojo() { offlineMode = offlineMode, cacheRoot = cacheRoot, sourceSets = listOf(sourceSet).also { - if (sourceSet.moduleName.isEmpty()) logger.warn("Not specified module name. It can result in unexpected behaviour while including documentation for module") + if (sourceSet.moduleDisplayName.isEmpty()) logger.warn("Not specified module name. It can result in unexpected behaviour while including documentation for module") }, pluginsClasspath = getArtifactByAether("org.jetbrains.dokka", "dokka-base", dokkaVersion) + dokkaPlugins.map { getArtifactByAether(it.groupId, it.artifactId, it.version) }.flatten(), diff --git a/testApi/src/main/kotlin/testApi/context/MockContext.kt b/testApi/src/main/kotlin/testApi/context/MockContext.kt index 07aedf28..97347695 100644 --- a/testApi/src/main/kotlin/testApi/context/MockContext.kt +++ b/testApi/src/main/kotlin/testApi/context/MockContext.kt @@ -1,7 +1,6 @@ package org.jetbrains.dokka.testApi.context import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.plugability.ExtensionPoint @@ -45,4 +44,4 @@ class MockContext( private fun DokkaPlugin.injectContext(context: DokkaContext) { (DokkaPlugin::class.memberProperties.single { it.name == "context" } as KMutableProperty<*>) .setter.call(this, context) -} \ No newline at end of file +} diff --git a/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt b/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt index ec2be689..d3127263 100644 --- a/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt +++ b/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt @@ -1,7 +1,6 @@ package org.jetbrains.dokka.testApi.testRunner import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.DokkaGenerator import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.utilities.DokkaLogger @@ -43,4 +42,4 @@ internal class DokkaTestGenerator( dokkaGenerator.reportAfterRendering(context) } -} \ No newline at end of file +} diff --git a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt index 057045a8..381fb2af 100644 --- a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt +++ b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt @@ -174,25 +174,26 @@ abstract class AbstractCoreTest { failOnWarning = failOnWarning ) - fun passes(block: Passes.() -> Unit) { - sourceSets.addAll(Passes().apply(block)) + fun sourceSets(block: SourceSetsBuilder.() -> Unit) { + sourceSets.addAll(SourceSetsBuilder().apply(block)) } } @DokkaConfigurationDsl - protected class Passes : ArrayList() { - fun pass(block: DokkaSourceSetBuilder.() -> Unit) = - add(DokkaSourceSetBuilder().apply(block).build()) + protected class SourceSetsBuilder : ArrayList() { + fun sourceSet(block: DokkaSourceSetBuilder.() -> Unit): DokkaSourceSet = + DokkaSourceSetBuilder().apply(block).build().apply(::add) } @DokkaConfigurationDsl protected class DokkaSourceSetBuilder( var moduleName: String = "root", - var sourceSetID: String = "main", + var moduleDisplayName: String? = null, + var name: String = "main", var displayName: String = "JVM", var classpath: List = emptyList(), var sourceRoots: List = emptyList(), - var dependentSourceSets: List = emptyList(), + var dependentSourceSets: Set = emptySet(), var samples: List = emptyList(), var includes: List = emptyList(), var includeNonPublic: Boolean = false, @@ -212,9 +213,9 @@ abstract class AbstractCoreTest { var sourceLinks: List = emptyList() ) { fun build() = DokkaSourceSetImpl( - moduleName = moduleName, + moduleDisplayName = moduleDisplayName ?: moduleName, displayName = displayName, - sourceSetID = sourceSetID, + sourceSetID = DokkaSourceSetID(moduleName, name), classpath = classpath, sourceRoots = sourceRoots.map { SourceRootImpl(it) }, dependentSourceSets = dependentSourceSets, -- cgit