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 --- plugins/base/src/test/kotlin/enums/EnumsTest.kt | 45 +++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 plugins/base/src/test/kotlin/enums/EnumsTest.kt (limited to 'plugins/base/src/test/kotlin/enums/EnumsTest.kt') diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt new file mode 100644 index 00000000..efc46595 --- /dev/null +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -0,0 +1,45 @@ +package enums + +import org.jetbrains.dokka.pages.ClasslikePageNode +import org.jetbrains.dokka.pages.ModulePageNode +import org.junit.Test +import testApi.testRunner.AbstractCoreTest + +class EnumsTest : AbstractCoreTest() { + + @Test + fun basicEnums() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package enums + | + |enum class Test { + | E1, + | E2 + |} + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { + val map = it.getClasslikeToMemberMap() + val test = map.filterKeys { it.name == "Test" }.values.firstOrNull() + assert(test != null) { "Test not found" } + assert(test!!.any { it.name == "E1" } && test.any { it.name == "E2" }) { "Enum entries missing in parent" } + assert(map.keys.any { it.name == "E1" } && map.keys.any { it.name == "E2" }) { "Enum entries missing" } + } + } + } + + + fun ModulePageNode.getClasslikeToMemberMap() = + this.parentMap.filterValues { it is ClasslikePageNode }.entries.groupBy({ it.value }) { it.key } +} \ No newline at end of file -- 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/enums/EnumsTest.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 2abdfd45a8c3d39745b38629153d83871b8ceae6 Mon Sep 17 00:00:00 2001 From: Szymon Świstun Date: Fri, 28 Feb 2020 17:54:26 +0100 Subject: fixed enum entries generation --- .../DefaultDescriptorToDocumentableTranslator.kt | 2 +- plugins/base/src/test/kotlin/enums/EnumsTest.kt | 52 +++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) (limited to 'plugins/base/src/test/kotlin/enums/EnumsTest.kt') diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 29441ac1..72ce296d 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -87,7 +87,6 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv override fun visitClassDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Classlike = when (descriptor.kind) { ClassKind.ENUM_CLASS -> enumDescriptor(descriptor, parent) - ClassKind.ENUM_ENTRY -> enumDescriptor(descriptor, parent) ClassKind.OBJECT -> objectDescriptor(descriptor, parent) ClassKind.INTERFACE -> interfaceDescriptor(descriptor, parent) else -> classDescriptor(descriptor, parent) @@ -378,6 +377,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv private fun MemberScope.enumEntries(parent: DRIWithPlatformInfo): List = this.getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS) { true } .filterIsInstance() + .filter { it.kind == ClassKind.ENUM_ENTRY } .map { enumEntryDescriptor(it, parent) } diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt index 9ea100a3..ea3238a5 100644 --- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -1,14 +1,17 @@ package enums +import org.jetbrains.dokka.model.Enum import org.jetbrains.dokka.pages.ClasslikePageNode import org.jetbrains.dokka.pages.ModulePageNode +import org.junit.Assert +import org.junit.Assert.* import org.junit.Test import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest class EnumsTest : AbstractCoreTest() { @Test - fun basicEnums() { + fun basicEnum() { val configuration = dokkaConfiguration { passes { pass { @@ -39,6 +42,53 @@ class EnumsTest : AbstractCoreTest() { } } + @Test + fun enumWithCompanion() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package enums + | + |enum class Test { + | E1, + | E2; + | companion object {} + |} + """.trimMargin(), + configuration + ) { + documentablesCreationStage = {m -> + assertTrue("Module list cannot be empty", m.isNotEmpty()) + m.first().packages.let { p -> + assertTrue("Package list cannot be empty", p.isNotEmpty()) + p.first().classlikes.let { c -> + assertTrue("Classlikes list cannot be empty", c.isNotEmpty()) + + val enum = c.first() as Enum + assertEquals(enum.name, "Test") + assertEquals(enum.entries.count(), 2) + assertNotNull(enum.companion) + } + } + } + pagesGenerationStage = { + val map = it.getClasslikeToMemberMap() + val test = map.filterKeys { it.name == "Test" }.values.firstOrNull() + assert(test != null) { "Test not found" } + assert(test!!.any { it.name == "E1" } && test.any { it.name == "E2" }) { "Enum entries missing in parent" } + assert(map.keys.any { it.name == "E1" } && map.keys.any { it.name == "E2" }) { "Enum entries missing" } + } + } + } + fun ModulePageNode.getClasslikeToMemberMap() = this.parentMap.filterValues { it is ClasslikePageNode }.entries.groupBy({ it.value }) { it.key } -- cgit From 996feefe717ac623daabaadda71b5b9d2bbe1cf1 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Mon, 16 Mar 2020 14:33:38 +0100 Subject: Rename Documentables to avoid name conflicts --- core/src/main/kotlin/DokkaGenerator.kt | 12 +- core/src/main/kotlin/model/Documentable.kt | 190 ++++++++++----------- .../main/kotlin/model/documentableProperties.kt | 6 +- .../DescriptorToDocumentableTranslator.kt | 4 +- .../documentation/DocumentableMerger.kt | 4 +- .../documentation/DocumentableToPageTranslator.kt | 4 +- .../documentation/DocumentableTransformer.kt | 4 +- .../psi/PsiToDocumentableTranslator.kt | 4 +- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 4 +- .../kotlin/signatures/KotlinSignatureProvider.kt | 35 ++-- .../documentables/DefaultDocumentableMerger.kt | 116 ++++++------- .../DefaultDescriptorToDocumentableTranslator.kt | 78 +++++---- .../DefaultDocumentableToPageTranslator.kt | 4 +- .../documentables/DefaultPageCreator.kt | 18 +- .../psi/DefaultPsiToDocumentableTranslator.kt | 40 ++--- plugins/base/src/test/kotlin/enums/EnumsTest.kt | 5 +- plugins/base/src/test/kotlin/issues/IssuesTest.kt | 18 +- plugins/base/src/test/kotlin/markdown/KDocTest.kt | 4 +- plugins/base/src/test/kotlin/model/ClassesTest.kt | 60 +++---- plugins/base/src/test/kotlin/model/CommentTest.kt | 32 ++-- .../base/src/test/kotlin/model/FunctionsTest.kt | 18 +- plugins/base/src/test/kotlin/model/JavaTest.kt | 38 ++--- plugins/base/src/test/kotlin/model/PackagesTest.kt | 16 +- plugins/base/src/test/kotlin/model/PropertyTest.kt | 20 +-- plugins/base/src/test/kotlin/utils/ModelUtils.kt | 6 +- plugins/base/src/test/kotlin/utils/TestUtils.kt | 8 +- .../kotlin/converters/KotlinToJavaConverter.kt | 54 +++--- .../kotlin/signatures/JavaSignatureProvider.kt | 34 ++-- .../KotlinAsJavaDocumentableTransformer.kt | 4 +- .../main/kotlin/testApi/testRunner/TestRunner.kt | 14 +- 30 files changed, 422 insertions(+), 432 deletions(-) (limited to 'plugins/base/src/test/kotlin/enums/EnumsTest.kt') diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index 1a0822d7..a3f72220 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -5,7 +5,7 @@ import com.intellij.psi.PsiJavaFile import com.intellij.psi.PsiManager import org.jetbrains.dokka.analysis.AnalysisEnvironment import org.jetbrains.dokka.analysis.DokkaResolutionFacade -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext @@ -76,17 +76,17 @@ class DokkaGenerator( platforms.map { (pdata, _) -> translatePsi(pdata, context) } fun mergeDocumentationModels( - modulesFromPlatforms: List, + modulesFromPlatforms: List, context: DokkaContext ) = context.single(CoreExtensions.documentableMerger).invoke(modulesFromPlatforms, context) fun transformDocumentationModel( - documentationModel: Module, + documentationModel: DModule, context: DokkaContext ) = context[CoreExtensions.documentableTransformer].fold(documentationModel) { acc, t -> t(acc, context) } fun createPages( - transformedDocumentation: Module, + transformedDocumentation: DModule, context: DokkaContext ) = context.single(CoreExtensions.documentableToPageTranslator).invoke(transformedDocumentation) @@ -119,7 +119,7 @@ class DokkaGenerator( EnvironmentAndFacade(environment, facade) } - private fun translateDescriptors(platformData: PlatformData, context: DokkaContext): Module { + private fun translateDescriptors(platformData: PlatformData, context: DokkaContext): DModule { val (environment, facade) = context.platforms.getValue(platformData) val packageFragments = environment.getSourceFiles().asSequence() @@ -132,7 +132,7 @@ class DokkaGenerator( .invoke(platformData.name, packageFragments, platformData) } - private fun translatePsi(platformData: PlatformData, context: DokkaContext): Module { + private fun translatePsi(platformData: PlatformData, context: DokkaContext): DModule { val (environment, _) = context.platforms.getValue(platformData) val sourceRoots = environment.configuration.get(CLIConfigurationKeys.CONTENT_ROOTS) diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index b697f4e4..22930bf2 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -48,9 +48,9 @@ interface WithExpectActual { } interface WithScope { - val functions: List - val properties: List - val classlikes: List + val functions: List + val properties: List + val classlikes: List } interface WithVisibility { @@ -81,15 +81,15 @@ sealed class JavaModifier(name: String) : Modifier(name) { } interface WithCompanion { - val companion: Object? + val companion: DObject? } interface WithConstructors { - val constructors: List + val constructors: List } interface WithGenerics { - val generics: List + val generics: List } interface WithSupertypes { @@ -97,232 +97,232 @@ interface WithSupertypes { } interface Callable : WithVisibility, WithType, WithAbstraction, WithExpectActual { - val receiver: Parameter? + val receiver: DParameter? } -abstract class Classlike : Documentable(), WithScope, WithVisibility, WithExpectActual +abstract class DClasslike : Documentable(), WithScope, WithVisibility, WithExpectActual -data class Module( +data class DModule( override val name: String, - val packages: List, + val packages: List, override val documentation: PlatformDependent, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : Documentable(), WithExtraProperties { override val dri: DRI = DRI.topLevel override val children: List get() = packages - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Package( +data class DPackage( override val dri: DRI, - override val functions: List, - override val properties: List, - override val classlikes: List, + override val functions: List, + override val properties: List, + override val classlikes: List, override val documentation: PlatformDependent, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithScope, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : Documentable(), WithScope, WithExtraProperties { override val name = dri.packageName.orEmpty() override val children: List get() = (properties + functions + classlikes) as List - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Class( +data class DClass( override val dri: DRI, override val name: String, - override val constructors: List, - override val functions: List, - override val properties: List, - override val classlikes: List, + override val constructors: List, + override val functions: List, + override val properties: List, + override val classlikes: List, override val sources: PlatformDependent, override val visibility: PlatformDependent, - override val companion: Object?, - override val generics: List, + override val companion: DObject?, + override val generics: List, override val supertypes: PlatformDependent>, override val documentation: PlatformDependent, override val modifier: Modifier, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Classlike(), WithAbstraction, WithCompanion, WithConstructors, WithGenerics, WithSupertypes, - WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : DClasslike(), WithAbstraction, WithCompanion, WithConstructors, WithGenerics, WithSupertypes, + WithExtraProperties { override val children: List get() = (functions + properties + classlikes + constructors) as List - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Enum( +data class DEnum( override val dri: DRI, override val name: String, - val entries: List, + val entries: List, override val documentation: PlatformDependent, override val sources: PlatformDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, + override val functions: List, + override val properties: List, + override val classlikes: List, override val visibility: PlatformDependent, - override val companion: Object?, - override val constructors: List, + override val companion: DObject?, + override val constructors: List, override val supertypes: PlatformDependent>, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Classlike(), WithCompanion, WithConstructors, WithSupertypes, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : DClasslike(), WithCompanion, WithConstructors, WithSupertypes, WithExtraProperties { override val children: List get() = (entries + functions + properties + classlikes + constructors) as List - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class EnumEntry( +data class DEnumEntry( override val dri: DRI, override val name: String, override val documentation: PlatformDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, + override val functions: List, + override val properties: List, + override val classlikes: List, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithScope, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : Documentable(), WithScope, WithExtraProperties { override val children: List get() = (functions + properties + classlikes) as List - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Function( +data class DFunction( override val dri: DRI, override val name: String, val isConstructor: Boolean, - val parameters: List, + val parameters: List, override val documentation: PlatformDependent, override val sources: PlatformDependent, override val visibility: PlatformDependent, override val type: Bound, - override val generics: List, - override val receiver: Parameter?, + override val generics: List, + override val receiver: DParameter?, override val modifier: Modifier, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), Callable, WithGenerics, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : Documentable(), Callable, WithGenerics, WithExtraProperties { override val children: List get() = parameters - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Interface( +data class DInterface( override val dri: DRI, override val name: String, override val documentation: PlatformDependent, override val sources: PlatformDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, + override val functions: List, + override val properties: List, + override val classlikes: List, override val visibility: PlatformDependent, - override val companion: Object?, - override val generics: List, + override val companion: DObject?, + override val generics: List, override val supertypes: PlatformDependent>, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Classlike(), WithCompanion, WithGenerics, WithSupertypes, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : DClasslike(), WithCompanion, WithGenerics, WithSupertypes, WithExtraProperties { override val children: List get() = (functions + properties + classlikes) as List - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Object( +data class DObject( override val name: String?, override val dri: DRI, override val documentation: PlatformDependent, override val sources: PlatformDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, + override val functions: List, + override val properties: List, + override val classlikes: List, override val visibility: PlatformDependent, override val supertypes: PlatformDependent>, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Classlike(), WithSupertypes, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : DClasslike(), WithSupertypes, WithExtraProperties { override val children: List get() = (functions + properties + classlikes) as List - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Annotation( +data class DAnnotation( override val name: String, override val dri: DRI, override val documentation: PlatformDependent, override val sources: PlatformDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, + override val functions: List, + override val properties: List, + override val classlikes: List, override val visibility: PlatformDependent, - override val companion: Object?, - override val constructors: List, + override val companion: DObject?, + override val constructors: List, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Classlike(), WithCompanion, WithConstructors, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : DClasslike(), WithCompanion, WithConstructors, WithExtraProperties { override val children: List get() = (functions + properties + classlikes + constructors) as List - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class Property( +data class DProperty( override val dri: DRI, override val name: String, override val documentation: PlatformDependent, override val sources: PlatformDependent, override val visibility: PlatformDependent, override val type: Bound, - override val receiver: Parameter?, - val setter: Function?, - val getter: Function?, + override val receiver: DParameter?, + val setter: DFunction?, + val getter: DFunction?, override val modifier: Modifier, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), Callable, WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : Documentable(), Callable, WithExtraProperties { override val children: List get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } // TODO: treat named Parameters and receivers differently -data class Parameter( +data class DParameter( override val dri: DRI, override val name: String?, override val documentation: PlatformDependent, val type: Bound, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : Documentable(), WithExtraProperties { override val children: List get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } -data class TypeParameter( +data class DTypeParameter( override val dri: DRI, override val name: String, override val documentation: PlatformDependent, val bounds: List, override val platformData: List, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithExtraProperties { + override val extra: PropertyContainer = PropertyContainer.empty() +) : Documentable(), WithExtraProperties { override val children: List get() = emptyList() - override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) + override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } sealed class Projection diff --git a/core/src/main/kotlin/model/documentableProperties.kt b/core/src/main/kotlin/model/documentableProperties.kt index 38a06451..67e5e88d 100644 --- a/core/src/main/kotlin/model/documentableProperties.kt +++ b/core/src/main/kotlin/model/documentableProperties.kt @@ -3,12 +3,12 @@ package org.jetbrains.dokka.model import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy -data class InheritedFunction(val isInherited: Boolean): ExtraProperty { - object InheritedFunctionKey: ExtraProperty.Key { +data class InheritedFunction(val isInherited: Boolean): ExtraProperty { + object InheritedFunctionKey: ExtraProperty.Key { override fun mergeStrategyFor(left: Boolean, right: Boolean) = MergeStrategy.Fail { throw IllegalArgumentException("Function inheritance should be consistent!") } } - override val key: ExtraProperty.Key = + override val key: ExtraProperty.Key = InheritedFunctionKey } \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentableTranslator.kt b/core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentableTranslator.kt index d72eeafd..ca66b90a 100644 --- a/core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentableTranslator.kt +++ b/core/src/main/kotlin/transformers/descriptors/DescriptorToDocumentableTranslator.kt @@ -1,6 +1,6 @@ package org.jetbrains.dokka.transformers.descriptors -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor @@ -9,5 +9,5 @@ interface DescriptorToDocumentableTranslator { moduleName: String, packageFragments: Iterable, platformData: PlatformData - ): Module + ): DModule } \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt b/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt index 5a17bc24..c8ae9c02 100644 --- a/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt +++ b/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt @@ -1,8 +1,8 @@ package org.jetbrains.dokka.transformers.documentation -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext interface DocumentableMerger { - operator fun invoke(modules: Collection, context: DokkaContext): Module + operator fun invoke(modules: Collection, context: DokkaContext): DModule } \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt b/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt index e41e0c84..83456f01 100644 --- a/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt +++ b/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt @@ -1,8 +1,8 @@ package org.jetbrains.dokka.transformers.documentation -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.ModulePageNode interface DocumentableToPageTranslator { - operator fun invoke(module: Module): ModulePageNode + operator fun invoke(module: DModule): ModulePageNode } \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt b/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt index 88a1514d..3eb4704e 100644 --- a/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt +++ b/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt @@ -1,8 +1,8 @@ package org.jetbrains.dokka.transformers.documentation -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext interface DocumentableTransformer { - operator fun invoke(original: Module, context: DokkaContext): Module + operator fun invoke(original: DModule, context: DokkaContext): DModule } \ No newline at end of file diff --git a/core/src/main/kotlin/transformers/psi/PsiToDocumentableTranslator.kt b/core/src/main/kotlin/transformers/psi/PsiToDocumentableTranslator.kt index 1ea07ff3..6f5025bd 100644 --- a/core/src/main/kotlin/transformers/psi/PsiToDocumentableTranslator.kt +++ b/core/src/main/kotlin/transformers/psi/PsiToDocumentableTranslator.kt @@ -1,7 +1,7 @@ package org.jetbrains.dokka.transformers.psi import com.intellij.psi.PsiJavaFile -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.plugability.DokkaContext @@ -11,5 +11,5 @@ interface PsiToDocumentableTranslator { psiFiles: List, platformData: PlatformData, context: DokkaContext - ): Module + ): DModule } diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index d7b2a912..34dac9f4 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -4,7 +4,7 @@ import kotlinx.html.* import kotlinx.html.stream.createHTML import org.jetbrains.dokka.base.renderers.DefaultRenderer import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import java.io.File @@ -269,7 +269,7 @@ private fun PageNode.pageKind() = when (this) { is PackagePageNode -> "package" is ClasslikePageNode -> "class" is MemberPageNode -> when (this.documentable) { - is Function -> "function" + is DFunction -> "function" else -> "other" } else -> "other" diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index f600a3bf..8a080bb9 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -6,12 +6,11 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.DriOfUnit import org.jetbrains.dokka.links.sureClassNames import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Annotation -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DAnnotation +import org.jetbrains.dokka.model.DEnum +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.pages.ContentKind import org.jetbrains.dokka.pages.ContentNode -import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.pages.TextStyle import org.jetbrains.dokka.utilities.DokkaLogger @@ -21,26 +20,26 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog private val ignoredVisibilities = setOf(JavaVisibility.Default, KotlinVisibility.Public) override fun signature(documentable: Documentable): ContentNode = when (documentable) { - is Function -> signature(documentable) - is Property -> signature(documentable) - is Classlike -> signature(documentable) - is TypeParameter -> signature(documentable) + is DFunction -> signature(documentable) + is DProperty -> signature(documentable) + is DClasslike -> signature(documentable) + is DTypeParameter -> signature(documentable) else -> throw NotImplementedError( "Cannot generate signature for ${documentable::class.qualifiedName} ${documentable.name}" ) } - private fun signature(c: Classlike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) { + private fun signature(c: DClasslike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) { platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " } - if (c is Class) { + if (c is DClass) { text(c.modifier.name + " ") } when (c) { - is Class -> text("class ") - is Interface -> text("interface ") - is Enum -> text("enum ") - is Object -> text("object ") - is Annotation -> text("annotation class ") + is DClass -> text("class ") + is DInterface -> text("interface ") + is DEnum -> text("enum ") + is DObject -> text("object ") + is DAnnotation -> text("annotation class ") } link(c.name!!, c.dri) if (c is WithSupertypes) { @@ -52,11 +51,11 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } } - private fun signature(p: Property) = contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace)) { + private fun signature(p: DProperty) = contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace)) { signatureForProjection(p.type) } - private fun signature(f: Function) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) { + private fun signature(f: DFunction) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) { platformText(f.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " } text(f.modifier.name + " ") text("fun ") @@ -82,7 +81,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } } - private fun signature(t: TypeParameter) = contentBuilder.contentFor(t) { + private fun signature(t: DTypeParameter) = contentBuilder.contentFor(t) { link(t.name, t.dri) list(t.bounds, prefix = " : ") { signatureForProjection(it) diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt index 4d47401b..bb7dbaaf 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt @@ -1,10 +1,10 @@ package org.jetbrains.dokka.base.transformers.documentables import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function -import org.jetbrains.dokka.model.Package -import org.jetbrains.dokka.model.Annotation +import org.jetbrains.dokka.model.DEnum +import org.jetbrains.dokka.model.DFunction +import org.jetbrains.dokka.model.DPackage +import org.jetbrains.dokka.model.DAnnotation import org.jetbrains.dokka.model.properties.mergeExtras import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.plugability.DokkaContext @@ -12,7 +12,7 @@ import org.jetbrains.dokka.transformers.documentation.DocumentableMerger import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult internal object DefaultDocumentableMerger : DocumentableMerger { - override fun invoke(modules: Collection, context: DokkaContext): Module { + override fun invoke(modules: Collection, context: DokkaContext): DModule { val name = modules.map { it.name }.distinct().singleOrNull() ?: run { context.logger.error("All module names need to be the same") modules.first().name @@ -21,11 +21,11 @@ internal object DefaultDocumentableMerger : DocumentableMerger { return modules.reduce { left, right -> val list = listOf(left, right) - Module( + DModule( name = name, packages = merge( list.flatMap { it.packages }, - Package::mergeWith + DPackage::mergeWith ), documentation = list.platformDependentFor { documentation }, platformData = list.flatMap { it.platformData }.distinct() @@ -106,25 +106,25 @@ private sealed class Expect { } } -fun Package.mergeWith(other: Package): Package = copy( - functions = mergeExpectActual(functions + other.functions, Function::mergeWith) { copy(platformData = it) }, - properties = mergeExpectActual(properties + other.properties, Property::mergeWith) { copy(platformData = it) }, - classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), +fun DPackage.mergeWith(other: DPackage): DPackage = copy( + functions = mergeExpectActual(functions + other.functions, DFunction::mergeWith) { copy(platformData = it) }, + properties = mergeExpectActual(properties + other.properties, DProperty::mergeWith) { copy(platformData = it) }, + classlikes = mergeExpectActual(classlikes + other.classlikes, DClasslike::mergeWith, DClasslike::setPlatformData), documentation = documentation.mergeWith(other.documentation), platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun Function.mergeWith(other: Function): Function = copy( - parameters = merge(this.parameters + other.parameters, Parameter::mergeWith), +fun DFunction.mergeWith(other: DFunction): DFunction = copy( + parameters = merge(this.parameters + other.parameters, DParameter::mergeWith), receiver = receiver?.let { r -> other.receiver?.let { r.mergeWith(it) } ?: r } ?: other.receiver, documentation = documentation.mergeWith(other.documentation), sources = sources.mergeWith(other.sources), visibility = visibility.mergeWith(other.visibility), platformData = (platformData + other.platformData).distinct(), - generics = merge(generics + other.generics, TypeParameter::mergeWith) + generics = merge(generics + other.generics, DTypeParameter::mergeWith) ).mergeExtras(this, other) -fun Property.mergeWith(other: Property): Property = copy( +fun DProperty.mergeWith(other: DProperty): DProperty = copy( receiver = receiver?.let { r -> other.receiver?.let { r.mergeWith(it) } ?: r } ?: other.receiver, documentation = documentation.mergeWith(other.documentation), sources = sources.mergeWith(other.sources), @@ -134,33 +134,33 @@ fun Property.mergeWith(other: Property): Property = copy( setter = setter?.let { s -> other.setter?.let { s.mergeWith(it) } ?: s } ?: other.setter ).mergeExtras(this, other) -fun Classlike.setPlatformData(platformData: List): Classlike = when (this) { - is Class -> copy(platformData = platformData) - is Enum -> copy(platformData = platformData) - is Interface -> copy(platformData = platformData) - is Object -> copy(platformData = platformData) +fun DClasslike.setPlatformData(platformData: List): DClasslike = when (this) { + is DClass -> copy(platformData = platformData) + is DEnum -> copy(platformData = platformData) + is DInterface -> copy(platformData = platformData) + is DObject -> copy(platformData = platformData) else -> throw IllegalStateException("${this::class.qualifiedName} ${this.name} cannot have platform set") } -fun Classlike.mergeWith(other: Classlike): Classlike = when { - this is Class && other is Class -> mergeWith(other) - this is Enum && other is Enum -> mergeWith(other) - this is Interface && other is Interface -> mergeWith(other) - this is Object && other is Object -> mergeWith(other) - this is Annotation && other is Annotation -> mergeWith(other) +fun DClasslike.mergeWith(other: DClasslike): DClasslike = when { + this is DClass && other is DClass -> mergeWith(other) + this is DEnum && other is DEnum -> mergeWith(other) + this is DInterface && other is DInterface -> mergeWith(other) + this is DObject && other is DObject -> mergeWith(other) + this is DAnnotation && other is DAnnotation -> mergeWith(other) else -> throw IllegalStateException("${this::class.qualifiedName} ${this.name} cannot be mergesd with ${other::class.qualifiedName} ${other.name}") } -fun Class.mergeWith(other: Class): Class = copy( +fun DClass.mergeWith(other: DClass): DClass = copy( constructors = mergeExpectActual( constructors + other.constructors, - Function::mergeWith + DFunction::mergeWith ) { copy(platformData = it) }, - functions = mergeExpectActual(functions + other.functions, Function::mergeWith) { copy(platformData = it) }, - properties = mergeExpectActual(properties + other.properties, Property::mergeWith) { copy(platformData = it) }, - classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), + functions = mergeExpectActual(functions + other.functions, DFunction::mergeWith) { copy(platformData = it) }, + properties = mergeExpectActual(properties + other.properties, DProperty::mergeWith) { copy(platformData = it) }, + classlikes = mergeExpectActual(classlikes + other.classlikes, DClasslike::mergeWith, DClasslike::setPlatformData), companion = companion?.let { c -> other.companion?.let { c.mergeWith(it) } ?: c } ?: other.companion, - generics = merge(generics + other.generics, TypeParameter::mergeWith), + generics = merge(generics + other.generics, DTypeParameter::mergeWith), supertypes = supertypes.mergeWith(other.supertypes), documentation = documentation.mergeWith(other.documentation), sources = sources.mergeWith(other.sources), @@ -168,15 +168,15 @@ fun Class.mergeWith(other: Class): Class = copy( platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun Enum.mergeWith(other: Enum): Enum = copy( - entries = merge(entries + other.entries, EnumEntry::mergeWith), +fun DEnum.mergeWith(other: DEnum): DEnum = copy( + entries = merge(entries + other.entries, DEnumEntry::mergeWith), constructors = mergeExpectActual( constructors + other.constructors, - Function::mergeWith + DFunction::mergeWith ) { copy(platformData = it) }, - functions = mergeExpectActual(functions + other.functions, Function::mergeWith) { copy(platformData = it) }, - properties = mergeExpectActual(properties + other.properties, Property::mergeWith) { copy(platformData = it) }, - classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), + functions = mergeExpectActual(functions + other.functions, DFunction::mergeWith) { copy(platformData = it) }, + properties = mergeExpectActual(properties + other.properties, DProperty::mergeWith) { copy(platformData = it) }, + classlikes = mergeExpectActual(classlikes + other.classlikes, DClasslike::mergeWith, DClasslike::setPlatformData), companion = companion?.let { c -> other.companion?.let { c.mergeWith(it) } ?: c } ?: other.companion, supertypes = supertypes.mergeWith(other.supertypes), documentation = documentation.mergeWith(other.documentation), @@ -185,18 +185,18 @@ fun Enum.mergeWith(other: Enum): Enum = copy( platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun EnumEntry.mergeWith(other: EnumEntry): EnumEntry = copy( - functions = mergeExpectActual(functions + other.functions, Function::mergeWith) { copy(platformData = it) }, - properties = mergeExpectActual(properties + other.properties, Property::mergeWith) { copy(platformData = it) }, - classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), +fun DEnumEntry.mergeWith(other: DEnumEntry): DEnumEntry = copy( + functions = mergeExpectActual(functions + other.functions, DFunction::mergeWith) { copy(platformData = it) }, + properties = mergeExpectActual(properties + other.properties, DProperty::mergeWith) { copy(platformData = it) }, + classlikes = mergeExpectActual(classlikes + other.classlikes, DClasslike::mergeWith, DClasslike::setPlatformData), documentation = documentation.mergeWith(other.documentation), platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun Object.mergeWith(other: Object): Object = copy( - functions = mergeExpectActual(functions + other.functions, Function::mergeWith) { copy(platformData = it) }, - properties = mergeExpectActual(properties + other.properties, Property::mergeWith) { copy(platformData = it) }, - classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), +fun DObject.mergeWith(other: DObject): DObject = copy( + functions = mergeExpectActual(functions + other.functions, DFunction::mergeWith) { copy(platformData = it) }, + properties = mergeExpectActual(properties + other.properties, DProperty::mergeWith) { copy(platformData = it) }, + classlikes = mergeExpectActual(classlikes + other.classlikes, DClasslike::mergeWith, DClasslike::setPlatformData), supertypes = supertypes.mergeWith(other.supertypes), documentation = documentation.mergeWith(other.documentation), sources = sources.mergeWith(other.sources), @@ -204,12 +204,12 @@ fun Object.mergeWith(other: Object): Object = copy( platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun Interface.mergeWith(other: Interface): Interface = copy( - functions = mergeExpectActual(functions + other.functions, Function::mergeWith) { copy(platformData = it) }, - properties = mergeExpectActual(properties + other.properties, Property::mergeWith) { copy(platformData = it) }, - classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), +fun DInterface.mergeWith(other: DInterface): DInterface = copy( + functions = mergeExpectActual(functions + other.functions, DFunction::mergeWith) { copy(platformData = it) }, + properties = mergeExpectActual(properties + other.properties, DProperty::mergeWith) { copy(platformData = it) }, + classlikes = mergeExpectActual(classlikes + other.classlikes, DClasslike::mergeWith, DClasslike::setPlatformData), companion = companion?.let { c -> other.companion?.let { c.mergeWith(it) } ?: c } ?: other.companion, - generics = merge(generics + other.generics, TypeParameter::mergeWith), + generics = merge(generics + other.generics, DTypeParameter::mergeWith), supertypes = supertypes.mergeWith(other.supertypes), documentation = documentation.mergeWith(other.documentation), sources = sources.mergeWith(other.sources), @@ -217,14 +217,14 @@ fun Interface.mergeWith(other: Interface): Interface = copy( platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun Annotation.mergeWith(other: Annotation): Annotation = copy( +fun DAnnotation.mergeWith(other: DAnnotation): DAnnotation = copy( constructors = mergeExpectActual( constructors + other.constructors, - Function::mergeWith + DFunction::mergeWith ) { copy(platformData = it) }, - functions = mergeExpectActual(functions + other.functions, Function::mergeWith) { copy(platformData = it) }, - properties = mergeExpectActual(properties + other.properties, Property::mergeWith) { copy(platformData = it) }, - classlikes = mergeExpectActual(classlikes + other.classlikes, Classlike::mergeWith, Classlike::setPlatformData), + functions = mergeExpectActual(functions + other.functions, DFunction::mergeWith) { copy(platformData = it) }, + properties = mergeExpectActual(properties + other.properties, DProperty::mergeWith) { copy(platformData = it) }, + classlikes = mergeExpectActual(classlikes + other.classlikes, DClasslike::mergeWith, DClasslike::setPlatformData), companion = companion?.let { c -> other.companion?.let { c.mergeWith(it) } ?: c } ?: other.companion, documentation = documentation.mergeWith(other.documentation), sources = sources.mergeWith(other.sources), @@ -232,12 +232,12 @@ fun Annotation.mergeWith(other: Annotation): Annotation = copy( platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun Parameter.mergeWith(other: Parameter): Parameter = copy( +fun DParameter.mergeWith(other: DParameter): DParameter = copy( documentation = documentation.mergeWith(other.documentation), platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) -fun TypeParameter.mergeWith(other: TypeParameter): TypeParameter = copy( +fun DTypeParameter.mergeWith(other: DTypeParameter): DTypeParameter = copy( documentation = documentation.mergeWith(other.documentation), platformData = (platformData + other.platformData).distinct() ).mergeExtras(this, other) \ 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 9a71145f..eb23ffd7 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -5,8 +5,8 @@ import org.jetbrains.dokka.links.Callable import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.withClass import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DEnum +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.pages.PlatformData @@ -21,7 +21,6 @@ import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBo import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.components.isVararg import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic -import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperclassesWithoutAny import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces @@ -30,7 +29,6 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeProjection import org.jetbrains.dokka.model.Variance -import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf.fqName import org.jetbrains.kotlin.idea.kdoc.findKDoc class DefaultDescriptorToDocumentableTranslator( @@ -47,7 +45,7 @@ class DefaultDescriptorToDocumentableTranslator( DRIWithPlatformInfo(DRI.topLevel, PlatformDependent.empty()) ) } - }.let { Module(moduleName, it, PlatformDependent.empty(), listOf(platformData)) } + }.let { DModule(moduleName, it, PlatformDependent.empty(), listOf(platformData)) } } @@ -69,11 +67,11 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv override fun visitPackageFragmentDescriptor( descriptor: PackageFragmentDescriptor, parent: DRIWithPlatformInfo - ): Package { + ): DPackage { val driWithPlatform = DRI(packageName = descriptor.fqName.asString()).withEmptyInfo() val scope = descriptor.getMemberScope() - return Package( + return DPackage( dri = driWithPlatform.dri, functions = scope.functions(driWithPlatform), properties = scope.properties(driWithPlatform), @@ -83,7 +81,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - override fun visitClassDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Classlike = + override fun visitClassDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): DClasslike = when (descriptor.kind) { ClassKind.ENUM_CLASS -> enumDescriptor(descriptor, parent) ClassKind.OBJECT -> objectDescriptor(descriptor, parent) @@ -91,12 +89,12 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv else -> classDescriptor(descriptor, parent) } - private fun interfaceDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Interface { + private fun interfaceDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): DInterface { val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() val scope = descriptor.unsubstitutedMemberScope val info = descriptor.resolveClassDescriptionData(platformData) - return Interface( + return DInterface( dri = driWithPlatform.dri, name = descriptor.name.asString(), functions = scope.functions(driWithPlatform), @@ -113,12 +111,12 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - private fun objectDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Object { + private fun objectDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): DObject { val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() val scope = descriptor.unsubstitutedMemberScope val info = descriptor.resolveClassDescriptionData(platformData) - return Object( + return DObject( dri = driWithPlatform.dri, name = descriptor.name.asString(), functions = scope.functions(driWithPlatform), @@ -133,12 +131,12 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - private fun enumDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Enum { + private fun enumDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): DEnum { val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() val scope = descriptor.unsubstitutedMemberScope val info = descriptor.resolveClassDescriptionData(platformData) - return Enum( + return DEnum( dri = driWithPlatform.dri, name = descriptor.name.asString(), entries = scope.enumEntries(driWithPlatform), @@ -156,11 +154,11 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - private fun enumEntryDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): EnumEntry { + private fun enumEntryDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): DEnumEntry { val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() val scope = descriptor.unsubstitutedMemberScope - return EnumEntry( + return DEnumEntry( dri = driWithPlatform.dri, name = descriptor.name.asString(), documentation = descriptor.resolveDescriptorData(platformData), @@ -172,13 +170,13 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - private fun classDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): Class { + private fun classDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): DClass { val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo() val scope = descriptor.unsubstitutedMemberScope val info = descriptor.resolveClassDescriptionData(platformData) val actual = descriptor.createSources() - return Class( + return DClass( dri = driWithPlatform.dri, name = descriptor.name.asString(), constructors = descriptor.constructors.map { @@ -203,11 +201,11 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - override fun visitPropertyDescriptor(descriptor: PropertyDescriptor, parent: DRIWithPlatformInfo): Property { + override fun visitPropertyDescriptor(descriptor: PropertyDescriptor, parent: DRIWithPlatformInfo): DProperty { val dri = parent.dri.copy(callable = Callable.from(descriptor)) val actual = descriptor.createSources() - return Property( + return DProperty( dri = dri, name = descriptor.name.asString(), receiver = descriptor.extensionReceiverParameter?.let { @@ -229,11 +227,11 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, parent: DRIWithPlatformInfo): Function { + override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, parent: DRIWithPlatformInfo): DFunction { val dri = parent.dri.copy(callable = Callable.from(descriptor)) val actual = descriptor.createSources() - return Function( + return DFunction( dri = dri, name = descriptor.name.asString(), isConstructor = false, @@ -254,10 +252,10 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } - override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor, parent: DRIWithPlatformInfo): Function { + override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor, parent: DRIWithPlatformInfo): DFunction { val dri = parent.dri.copy(callable = Callable.from(descriptor)) val actual = descriptor.createSources() - return Function( + return DFunction( dri = dri, name = "", isConstructor = true, @@ -281,7 +279,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv override fun visitReceiverParameterDescriptor( descriptor: ReceiverParameterDescriptor, parent: DRIWithPlatformInfo - ) = Parameter( + ) = DParameter( dri = parent.dri.copy(target = 0), name = null, type = descriptor.type.toBound(), @@ -293,12 +291,12 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv descriptor: PropertyAccessorDescriptor, propertyDescriptor: PropertyDescriptor, parent: DRI - ): Function { + ): DFunction { val dri = parent.copy(callable = Callable.from(descriptor)) val isGetter = descriptor is PropertyGetterDescriptor fun PropertyDescriptor.asParameter(parent: DRI) = - Parameter( + DParameter( parent.copy(target = 1), this.name.asString(), type = this.type.toBound(), @@ -320,7 +318,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv listOf(propertyDescriptor.asParameter(dri)) } - return Function( + return DFunction( dri, name, isConstructor = false, @@ -343,7 +341,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv } private fun parameter(index: Int, descriptor: ValueParameterDescriptor, parent: DRIWithPlatformInfo) = - Parameter( + DParameter( dri = parent.dri.copy(target = index + 1), name = descriptor.name.asString(), type = descriptor.type.toBound(), @@ -352,28 +350,28 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv extra = descriptor.additionalExtras() ) - private fun MemberScope.functions(parent: DRIWithPlatformInfo): List = + private fun MemberScope.functions(parent: DRIWithPlatformInfo): List = getContributedDescriptors(DescriptorKindFilter.FUNCTIONS) { true } .filterIsInstance() .map { visitFunctionDescriptor(it, parent) } - private fun MemberScope.properties(parent: DRIWithPlatformInfo): List = + private fun MemberScope.properties(parent: DRIWithPlatformInfo): List = getContributedDescriptors(DescriptorKindFilter.VALUES) { true } .filterIsInstance() .map { visitPropertyDescriptor(it, parent) } - private fun MemberScope.classlikes(parent: DRIWithPlatformInfo): List = + private fun MemberScope.classlikes(parent: DRIWithPlatformInfo): List = getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS) { true } .filterIsInstance() .map { visitClassDescriptor(it, parent) } - .mapNotNull { it as? Classlike } + .mapNotNull { it as? DClasslike } - private fun MemberScope.packages(parent: DRIWithPlatformInfo): List = + private fun MemberScope.packages(parent: DRIWithPlatformInfo): List = getContributedDescriptors(DescriptorKindFilter.PACKAGES) { true } .filterIsInstance() .map { visitPackageFragmentDescriptor(it, parent) } - private fun MemberScope.enumEntries(parent: DRIWithPlatformInfo): List = + private fun MemberScope.enumEntries(parent: DRIWithPlatformInfo): List = this.getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS) { true } .filterIsInstance() .filter { it.kind == ClassKind.ENUM_ENTRY } @@ -391,7 +389,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv } private fun TypeParameterDescriptor.toTypeParameter() = - TypeParameter( + DTypeParameter( DRI.from(this), name.identifier, PlatformDependent.from(platformData, getDocumentation()), @@ -428,7 +426,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv MarkdownParser(resolutionFacade, this).parseFromKDocTag(it) } - fun ClassDescriptor.companion(dri: DRIWithPlatformInfo): Object? = companionObjectDescriptor?.let { + fun ClassDescriptor.companion(dri: DRIWithPlatformInfo): DObject? = companionObjectDescriptor?.let { objectDescriptor(it, dri) } @@ -467,7 +465,7 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ExtraModifiers.OVERRIDE.takeIf { getSuperInterfaces().isNotEmpty() || getSuperClassNotAny() != null } ).toContainer() - fun ValueParameterDescriptor.additionalExtras(): PropertyContainer = + fun ValueParameterDescriptor.additionalExtras(): PropertyContainer = listOfNotNull( ExtraModifiers.DYNAMIC.takeIf { isDynamic() }, ExtraModifiers.NOINLINE.takeIf { isNoinline }, @@ -477,13 +475,13 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ExtraModifiers.VARARG.takeIf { isVararg } ).toContainer() - fun TypeParameterDescriptor.additionalExtras(): PropertyContainer = + fun TypeParameterDescriptor.additionalExtras(): PropertyContainer = listOfNotNull( ExtraModifiers.DYNAMIC.takeIf { isDynamic() }, ExtraModifiers.REIFIED.takeIf { isReified } ).toContainer() - fun PropertyDescriptor.additionalExtras(): PropertyContainer = listOfNotNull( + fun PropertyDescriptor.additionalExtras(): PropertyContainer = listOfNotNull( ExtraModifiers.DYNAMIC.takeIf { isDynamic() }, ExtraModifiers.CONST.takeIf { isConst }, ExtraModifiers.LATEINIT.takeIf { isLateInit }, diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt index 16f9b9b3..04251947 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultDocumentableToPageTranslator.kt @@ -2,7 +2,7 @@ package org.jetbrains.dokka.base.translators.documentables import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator import org.jetbrains.dokka.utilities.DokkaLogger @@ -12,6 +12,6 @@ class DefaultDocumentableToPageTranslator( private val signatureProvider: SignatureProvider, private val logger: DokkaLogger ) : DocumentableToPageTranslator { - override fun invoke(module: Module): ModulePageNode = + override fun invoke(module: DModule): ModulePageNode = DefaultPageCreator(commentsToContentConverter, signatureProvider, logger).pageForModule(module) } \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 560bda71..a0b5a072 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -4,7 +4,7 @@ import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.model.doc.Property import org.jetbrains.dokka.model.doc.TagWrapper import org.jetbrains.dokka.pages.* @@ -17,16 +17,16 @@ open class DefaultPageCreator( ) { protected open val contentBuilder = PageContentBuilder(commentsToContentConverter, signatureProvider, logger) - open fun pageForModule(m: Module) = + open fun pageForModule(m: DModule) = ModulePageNode(m.name.ifEmpty { "" }, contentForModule(m), m, m.packages.map(::pageForPackage)) - open fun pageForPackage(p: Package): PackagePageNode = PackagePageNode( + open fun pageForPackage(p: DPackage): PackagePageNode = PackagePageNode( p.name, contentForPackage(p), setOf(p.dri), p, p.classlikes.map(::pageForClasslike) + p.functions.map(::pageForFunction) ) - open fun pageForClasslike(c: Classlike): ClasslikePageNode { + open fun pageForClasslike(c: DClasslike): ClasslikePageNode { val constructors = if (c is WithConstructors) c.constructors else emptyList() return ClasslikePageNode( @@ -37,9 +37,9 @@ open class DefaultPageCreator( ) } - open fun pageForFunction(f: Function) = MemberPageNode(f.name, contentForFunction(f), setOf(f.dri), f) + open fun pageForFunction(f: DFunction) = MemberPageNode(f.name, contentForFunction(f), setOf(f.dri), f) - protected open fun contentForModule(m: Module) = contentBuilder.contentFor(m) { + protected open fun contentForModule(m: DModule) = contentBuilder.contentFor(m) { header(1) { text(m.name) } block("Packages", 2, ContentKind.Packages, m.packages, m.platformData.toSet()) { link(it.name, it.dri) @@ -48,7 +48,7 @@ open class DefaultPageCreator( // text("Link to allpage here") } - protected open fun contentForPackage(p: Package) = contentBuilder.contentFor(p) { + protected open fun contentForPackage(p: DPackage) = contentBuilder.contentFor(p) { header(1) { text("Package ${p.name}") } +contentForScope(p, p.dri, p.platformData) } @@ -87,7 +87,7 @@ open class DefaultPageCreator( } } - protected open fun contentForClasslike(c: Classlike) = contentBuilder.contentFor(c) { + protected open fun contentForClasslike(c: DClasslike) = contentBuilder.contentFor(c) { header(1) { text(c.name.orEmpty()) } +buildSignature(c) @@ -126,7 +126,7 @@ open class DefaultPageCreator( } }.children - protected open fun contentForFunction(f: Function) = contentBuilder.contentFor(f) { + protected open fun contentForFunction(f: DFunction) = contentBuilder.contentFor(f) { header(1) { text(f.name) } +buildSignature(f) +contentForComments(f) diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index 65f94843..c5c72a65 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -9,9 +9,9 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.JavaClassReference import org.jetbrains.dokka.links.withClass import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Annotation -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DAnnotation +import org.jetbrains.dokka.model.DEnum +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.plugability.DokkaContext @@ -31,17 +31,17 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { psiFiles: List, platformData: PlatformData, context: DokkaContext - ): Module { + ): DModule { val docParser = DokkaPsiParser( platformData, context.logger ) - return Module( + return DModule( moduleName, psiFiles.groupBy { it.packageName }.map { (packageName, psiFiles) -> val dri = DRI(packageName = packageName) - Package( + DPackage( dri, emptyList(), emptyList(), @@ -93,7 +93,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { private fun T.toPlatformDependant() = PlatformDependent(mapOf(platformData to this)) - fun parseClasslike(psi: PsiClass, parent: DRI): Classlike = with(psi) { + fun parseClasslike(psi: PsiClass, parent: DRI): DClasslike = with(psi) { val dri = parent.withClass(name.toString()) val ancestorsSet = hashSetOf() val superMethodsKeys = hashSetOf() @@ -133,7 +133,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { val ancestors = ancestorsSet.toList().toPlatformDependant() return when { isAnnotationType -> - Annotation( + DAnnotation( name.orEmpty(), dri, documentation, @@ -146,11 +146,11 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { constructors.map { parseFunction(it, dri, true) }, listOf(platformData) ) - isEnum -> Enum( + isEnum -> DEnum( dri, name.orEmpty(), fields.filterIsInstance().map { entry -> - EnumEntry( + DEnumEntry( dri.withClass("$name.${entry.name}"), entry.name.orEmpty(), javadocParser.parseDocumentation(entry).toPlatformDependant(), @@ -171,7 +171,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { ancestors, listOf(platformData) ) - isInterface -> Interface( + isInterface -> DInterface( dri, name.orEmpty(), documentation, @@ -185,7 +185,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { ancestors, listOf(platformData) ) - else -> Class( + else -> DClass( dri, name.orEmpty(), constructors.map { parseFunction(it, dri, true) }, @@ -209,7 +209,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { parent: DRI, isConstructor: Boolean = false, isInherited: Boolean = false - ): Function { + ): DFunction { val dri = parent.copy( callable = Callable( psi.name, @@ -218,12 +218,12 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { JavaClassReference(parameter.type.canonicalText) }) ) - return Function( + return DFunction( dri, if (isConstructor) "" else psi.name, isConstructor, psi.parameterList.parameters.mapIndexed { index, psiParameter -> - Parameter( + DParameter( dri.copy(target = index + 1), psiParameter.name, javadocParser.parseDocumentation(psiParameter).toPlatformDependant(), @@ -239,7 +239,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { null, psi.getModifier(), listOf(platformData), - PropertyContainer.empty() + InheritedFunction( + PropertyContainer.empty() + InheritedFunction( isInherited ) ) @@ -278,7 +278,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { else -> JavaModifier.Empty } - private fun PsiTypeParameterListOwner.mapTypeParameters(dri: DRI): List { + private fun PsiTypeParameterListOwner.mapTypeParameters(dri: DRI): List { fun mapBounds(bounds: Array): List = if (bounds.isEmpty()) emptyList() else bounds.mapNotNull { (it as? PsiClassType)?.let { classType -> @@ -286,7 +286,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { } } return typeParameters.mapIndexed { index, type -> - TypeParameter( + DTypeParameter( dri.copy(genericTarget = index), type.name.orEmpty(), javadocParser.parseDocumentation(type).toPlatformDependant(), @@ -323,7 +323,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { return regularMethods to accessors } - private fun parseField(psi: PsiField, parent: DRI, accessors: List): Property { + private fun parseField(psi: PsiField, parent: DRI, accessors: List): DProperty { val dri = parent.copy( callable = Callable( psi.name!!, // TODO: Investigate if this is indeed nullable @@ -331,7 +331,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { emptyList() ) ) - return Property( + return DProperty( dri, psi.name!!, // TODO: Investigate if this is indeed nullable javadocParser.parseDocumentation(psi).toPlatformDependant(), diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt index ea3238a5..34e92d82 100644 --- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -1,9 +1,8 @@ package enums -import org.jetbrains.dokka.model.Enum +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.Assert.* import org.junit.Test import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest @@ -72,7 +71,7 @@ class EnumsTest : AbstractCoreTest() { p.first().classlikes.let { c -> assertTrue("Classlikes list cannot be empty", c.isNotEmpty()) - val enum = c.first() as Enum + val enum = c.first() as DEnum assertEquals(enum.name, "Test") assertEquals(enum.entries.count(), 2) assertNotNull(enum.companion) diff --git a/plugins/base/src/test/kotlin/issues/IssuesTest.kt b/plugins/base/src/test/kotlin/issues/IssuesTest.kt index ea2f0f8e..e34c610a 100644 --- a/plugins/base/src/test/kotlin/issues/IssuesTest.kt +++ b/plugins/base/src/test/kotlin/issues/IssuesTest.kt @@ -1,7 +1,7 @@ package issues -import org.jetbrains.dokka.model.Class -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DClass +import org.jetbrains.dokka.model.DFunction import org.junit.Test import utils.AbstractModelTest @@ -33,16 +33,16 @@ class IssuesTest : AbstractModelTest("/src/main/kotlin/issues/Test.kt", "issues" |} """ ) { - with((this / "issues" / "Test").cast()) { + with((this / "issues" / "Test").cast()) { // passes - (this / "working").cast().type.constructorFqName equals "kotlin.String" - (this / "doSomething").cast().type.constructorFqName equals "kotlin.String" + (this / "working").cast().type.constructorFqName equals "kotlin.String" + (this / "doSomething").cast().type.constructorFqName equals "kotlin.String" // fails - (this / "brokenGenerics").cast().type.constructorFqName equals "kotlin.collections.List" - (this / "brokenApply").cast().type.constructorFqName equals "issues.Test" - (this / "brokenRun").cast().type.constructorFqName equals "issues.Test" - (this / "brokenLet").cast().type.constructorFqName equals "issues.Test" + (this / "brokenGenerics").cast().type.constructorFqName equals "kotlin.collections.List" + (this / "brokenApply").cast().type.constructorFqName equals "issues.Test" + (this / "brokenRun").cast().type.constructorFqName equals "issues.Test" + (this / "brokenLet").cast().type.constructorFqName equals "issues.Test" } } } diff --git a/plugins/base/src/test/kotlin/markdown/KDocTest.kt b/plugins/base/src/test/kotlin/markdown/KDocTest.kt index e250670a..fa538c3e 100644 --- a/plugins/base/src/test/kotlin/markdown/KDocTest.kt +++ b/plugins/base/src/test/kotlin/markdown/KDocTest.kt @@ -1,6 +1,6 @@ package markdown -import org.jetbrains.dokka.model.Package +import org.jetbrains.dokka.model.DPackage import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.pages.ModulePageNode import org.junit.Assert @@ -26,7 +26,7 @@ open class KDocTest : AbstractCoreTest() { """.trimMargin() private fun actualDocumentationNode(modulePageNode: ModulePageNode) = - (modulePageNode.documentable?.children?.first() as Package) + (modulePageNode.documentable?.children?.first() as DPackage) .classlikes.single() .documentation.values.single() diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt index a59174bf..d627dab4 100644 --- a/plugins/base/src/test/kotlin/model/ClassesTest.kt +++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt @@ -2,7 +2,7 @@ package model import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.KotlinModifier.* -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DFunction import org.junit.Test import utils.AbstractModelTest import utils.assertNotNull @@ -17,7 +17,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class """ |class Klass {}""" ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" children counts 4 } @@ -31,7 +31,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |object Obj {} """ ) { - with((this / "classes" / "Obj").cast()) { + with((this / "classes" / "Obj").cast()) { name equals "Obj" children counts 3 } @@ -45,7 +45,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |class Klass(name: String) """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" children counts 4 @@ -71,11 +71,11 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" children counts 5 - with((this / "fn").cast()) { + with((this / "fn").cast()) { type.constructorFqName equals "kotlin.Unit" parameters counts 0 visibility.values allEquals KotlinVisibility.Public @@ -93,11 +93,11 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" children counts 5 - with((this / "name").cast()) { + with((this / "name").cast()) { name equals "name" // TODO property name } @@ -117,19 +117,19 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" children counts 5 - with((this / "Companion").cast()) { + with((this / "Companion").cast()) { name equals "Companion" children counts 5 - with((this / "x").cast()) { + with((this / "x").cast()) { name equals "x" } - with((this / "foo").cast()) { + with((this / "foo").cast()) { name equals "foo" parameters counts 0 type.constructorFqName equals "kotlin.Unit" @@ -146,7 +146,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |data class Klass() {} """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" visibility.values allEquals KotlinVisibility.Public with(extra[AdditionalModifiers.AdditionalKey].assertNotNull("Extras")) { @@ -170,7 +170,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |sealed class Klass() {} """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" modifier equals KotlinModifier.Sealed } @@ -215,18 +215,18 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - val C = (this / "classes" / "C").cast() - val D = (this / "classes" / "D").cast() + val C = (this / "classes" / "C").cast() + val D = (this / "classes" / "D").cast() with(C) { modifier equals Open - with((this / "f").cast()) { + with((this / "f").cast()) { modifier equals Open } } with(D) { modifier equals Final - with((this / "f").cast()) { + with((this / "f").cast()) { modifier equals Open } D.supertypes.flatMap { it.component2() }.firstOrNull() equals C.dri @@ -249,13 +249,13 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - val C = (this / "classes" / "C").cast() - val D = (this / "classes" / "D").cast() - val E = (this / "classes" / "E").cast() + val C = (this / "classes" / "C").cast() + val D = (this / "classes" / "D").cast() + val E = (this / "classes" / "E").cast() with(C) { modifier equals Abstract - ((this / "foo").cast()).modifier equals Abstract + ((this / "foo").cast()).modifier equals Abstract } with(D) { @@ -280,9 +280,9 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - with((this / "classes" / "C").cast()) { + with((this / "classes" / "C").cast()) { - with((this / "D").cast()) { + with((this / "D").cast()) { } } } @@ -312,10 +312,10 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |val Klass.Default.x: Int get() = 1 """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" - with((this / "Default").cast()) { + with((this / "Default").cast()) { name equals "Default" // TODO extensions } @@ -342,7 +342,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - with((this / "classes" / "C").cast()) { + with((this / "classes" / "C").cast()) { name equals "C" constructors counts 2 @@ -384,14 +384,14 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class |} """ ) { - with((this / "classes" / "Klass").cast()) { + with((this / "classes" / "Klass").cast()) { name equals "Klass" - with((this / "Companion").cast()) { + with((this / "Companion").cast()) { name equals "Companion" visibility.values allEquals KotlinVisibility.Private - with((this / "fn").cast()) { + with((this / "fn").cast()) { name equals "fn" parameters counts 0 receiver equals null diff --git a/plugins/base/src/test/kotlin/model/CommentTest.kt b/plugins/base/src/test/kotlin/model/CommentTest.kt index d576cf49..055892af 100644 --- a/plugins/base/src/test/kotlin/model/CommentTest.kt +++ b/plugins/base/src/test/kotlin/model/CommentTest.kt @@ -1,6 +1,6 @@ package model -import org.jetbrains.dokka.model.Property +import org.jetbrains.dokka.model.DProperty import org.jetbrains.dokka.model.doc.CustomWrapperTag import org.jetbrains.dokka.model.doc.Text import org.junit.Test @@ -28,7 +28,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val prop2 = "" """ ) { - with((this / "comment" / "prop1").cast()) { + with((this / "comment" / "prop1").cast()) { name equals "prop1" with(this.docs().firstOrNull()?.root.assertNotNull("Code")) { (children.firstOrNull() as? Text) @@ -37,7 +37,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme params["lang"] equals "brainfuck" } } - with((this / "comment" / "prop2").cast()) { + with((this / "comment" / "prop2").cast()) { name equals "prop2" comments() equals "a + b - c" } @@ -51,7 +51,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { name equals "property" comments() equals "" } @@ -68,7 +68,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme """ ) { val p = this - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "" } } @@ -87,7 +87,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "doc1\ndoc2 doc3" } } @@ -107,7 +107,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "doc1\ndoc2 doc3" } } @@ -121,7 +121,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "doc" } } @@ -136,7 +136,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "doc" } } @@ -151,7 +151,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "doc" } } @@ -168,7 +168,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "Summary\none: []" docs().find { it is CustomWrapperTag && it.name == "one" }.let { with(it.assertNotNull("'one' entry")) { @@ -188,7 +188,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals """it's "useful"""" } } @@ -205,7 +205,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "Summary\none: [section one]" } } @@ -224,7 +224,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "Summary\none: [section one]\ntwo: [section two]" } } @@ -243,7 +243,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |val property = "test" """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { comments() equals "Summary\none: [line one line two]" } } @@ -290,7 +290,7 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme |} """ ) { - with((this / "comment" / "property").cast()) { + with((this / "comment" / "property").cast()) { this } } diff --git a/plugins/base/src/test/kotlin/model/FunctionsTest.kt b/plugins/base/src/test/kotlin/model/FunctionsTest.kt index 9554ad02..f3a7adc7 100644 --- a/plugins/base/src/test/kotlin/model/FunctionsTest.kt +++ b/plugins/base/src/test/kotlin/model/FunctionsTest.kt @@ -1,7 +1,7 @@ package model -import org.jetbrains.dokka.model.Function -import org.jetbrains.dokka.model.Package +import org.jetbrains.dokka.model.DFunction +import org.jetbrains.dokka.model.DPackage import org.junit.Test import utils.* @@ -17,7 +17,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun |fun fn() {} """ ) { - with((this / "function" / "fn").cast()) { + with((this / "function" / "fn").cast()) { name equals "fn" type.constructorFqName equals "kotlin.Unit" this.children.assertCount(0, "Function children: ") @@ -39,7 +39,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun |fun fn(i: Int) {} """ ) { - with((this / "function").cast()) { + with((this / "function").cast()) { val fn1 = functions.find { it.name == "fn" && it.parameters.isNullOrEmpty() }.assertNotNull("fn()") @@ -76,7 +76,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun |fun String.fn(x: Int) {} """ ) { - with((this / "function").cast()) { + with((this / "function").cast()) { val fn1 = functions.find { it.name == "fn" && it.parameters.isNullOrEmpty() }.assertNotNull("fn()") @@ -114,7 +114,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun |} """ ) { - with((this / "function" / "function").cast()) { + with((this / "function" / "function").cast()) { comments() equals "Multiline\nFunction Documentation" name equals "function" @@ -141,7 +141,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun ) { // TODO add annotations - with((this / "function" / "f").cast()) { + with((this / "function" / "f").cast()) { assert(false) { "No annotation data" } } } @@ -162,7 +162,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun ) { // TODO add data about inline - with((this / "function" / "f").cast()) { + with((this / "function" / "f").cast()) { assert(false) { "No inline data" } } } @@ -184,7 +184,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun ) { // TODO add data about suspend - with((this / "function" / "f").cast()) { + with((this / "function" / "f").cast()) { assert(false) { "No suspend data" } } } diff --git a/plugins/base/src/test/kotlin/model/JavaTest.kt b/plugins/base/src/test/kotlin/model/JavaTest.kt index ea454763..c2545e7a 100644 --- a/plugins/base/src/test/kotlin/model/JavaTest.kt +++ b/plugins/base/src/test/kotlin/model/JavaTest.kt @@ -1,8 +1,8 @@ package model import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DEnum +import org.jetbrains.dokka.model.DFunction import org.junit.Assert.assertTrue import org.junit.Test import utils.AbstractModelTest @@ -24,10 +24,10 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "Test").cast()) { + with((this / "java" / "Test").cast()) { name equals "Test" children counts 1 - with((this / "fn").cast()) { + with((this / "fn").cast()) { name equals "fn" this } @@ -82,7 +82,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "Test" / "fn").cast()) { + with((this / "java" / "Test" / "fn").cast()) { this } } @@ -108,7 +108,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |public class Foo extends Exception implements Cloneable {} """ ) { - with((this / "java" / "Foo").cast()) { + with((this / "java" / "Foo").cast()) { val sups = listOf("Exception", "Cloneable") assertTrue( "Foo must extend ${sups.joinToString(", ")}", @@ -128,11 +128,11 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "Test").cast()) { + with((this / "java" / "Test").cast()) { name equals "Test" children counts 1 - with((this / "arrayToString").cast()) { + with((this / "arrayToString").cast()) { name equals "arrayToString" type.constructorFqName equals "java.lang.String[]" with(parameters.firstOrNull().assertNotNull("parameters")) { @@ -153,7 +153,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "Foo").cast()) { + with((this / "java" / "Foo").cast()) { this } } @@ -189,7 +189,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "Test").cast()) { + with((this / "java" / "Test").cast()) { name equals "Test" constructors counts 2 @@ -211,9 +211,9 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "InnerClass").cast()) { + with((this / "java" / "InnerClass").cast()) { children counts 1 - with((this / "D").cast()) { + with((this / "D").cast()) { name equals "D" children counts 0 } @@ -230,11 +230,11 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "Foo").cast()) { + with((this / "java" / "Foo").cast()) { name equals "Foo" children counts 1 - with((this / "bar").cast()) { + with((this / "bar").cast()) { name equals "bar" with(parameters.firstOrNull().assertNotNull("parameter")) { name equals "x" @@ -255,15 +255,15 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "Test").cast()) { + with((this / "java" / "Test").cast()) { children counts 2 - with((this / "i").cast()) { + with((this / "i").cast()) { getter.assertNotNull("i.get") setter.assertNotNull("i.set") } - with((this / "s").cast()) { + with((this / "s").cast()) { getter.assertNotNull("s.get") setter.assertNotNull("s.set") @@ -344,11 +344,11 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { |} """ ) { - with((this / "java" / "E").cast()) { + with((this / "java" / "E").cast()) { name equals "E" entries counts 1 - with((this / "Foo").cast()) { + with((this / "Foo").cast()) { name equals "Foo" } } diff --git a/plugins/base/src/test/kotlin/model/PackagesTest.kt b/plugins/base/src/test/kotlin/model/PackagesTest.kt index e19cc82d..008ae14d 100644 --- a/plugins/base/src/test/kotlin/model/PackagesTest.kt +++ b/plugins/base/src/test/kotlin/model/PackagesTest.kt @@ -1,6 +1,6 @@ package model -import org.jetbrains.dokka.model.Package +import org.jetbrains.dokka.model.DPackage import org.junit.Test import utils.AbstractModelTest @@ -14,7 +14,7 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac """.trimIndent(), prependPackage = false ) { - with((this / "").cast()) { + with((this / "").cast()) { name equals "" children counts 0 } @@ -29,7 +29,7 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac """.trimIndent(), prependPackage = false ) { - with((this / "simple").cast()) { + with((this / "simple").cast()) { name equals "simple" children counts 0 } @@ -44,7 +44,7 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac """.trimIndent(), prependPackage = false ) { - with((this / "dot.name").cast()) { + with((this / "dot.name").cast()) { name equals "dot.name" children counts 0 } @@ -63,11 +63,11 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac prependPackage = false ) { children counts 2 - with((this / "dot.name").cast()) { + with((this / "dot.name").cast()) { name equals "dot.name" children counts 0 } - with((this / "simple").cast()) { + with((this / "simple").cast()) { name equals "simple" children counts 0 } @@ -85,7 +85,7 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac prependPackage = false ) { children counts 1 - with((this / "simple").cast()) { + with((this / "simple").cast()) { name equals "simple" children counts 0 } @@ -102,7 +102,7 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac """.trimIndent(), prependPackage = false ) { - with((this / "simple.name").cast()) { + with((this / "simple.name").cast()) { name equals "simple.name" children counts 1 } diff --git a/plugins/base/src/test/kotlin/model/PropertyTest.kt b/plugins/base/src/test/kotlin/model/PropertyTest.kt index e4ef0aec..d12e292b 100644 --- a/plugins/base/src/test/kotlin/model/PropertyTest.kt +++ b/plugins/base/src/test/kotlin/model/PropertyTest.kt @@ -1,8 +1,8 @@ package model import org.jetbrains.dokka.model.KotlinVisibility -import org.jetbrains.dokka.model.Package -import org.jetbrains.dokka.model.Property +import org.jetbrains.dokka.model.DPackage +import org.jetbrains.dokka.model.DProperty import org.junit.Test import utils.AbstractModelTest import utils.assertNotNull @@ -15,7 +15,7 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro """ |val property = "test"""" ) { - with((this / "property" / "property").cast()) { + with((this / "property" / "property").cast()) { name equals "property" children counts 0 with(getter.assertNotNull("Getter")) { @@ -33,7 +33,7 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro |var property = "test" """ ) { - with((this / "property" / "property").cast()) { + with((this / "property" / "property").cast()) { name equals "property" children counts 0 setter.assertNotNull("Setter") @@ -53,7 +53,7 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro | get() = "test" """ ) { - with((this / "property" / "property").cast()) { + with((this / "property" / "property").cast()) { name equals "property" children counts 0 with(getter.assertNotNull("Getter")) { @@ -73,7 +73,7 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro | set(value) {} """ ) { - with((this / "property" / "property").cast()) { + with((this / "property" / "property").cast()) { name equals "property" children counts 0 setter.assertNotNull("Setter") @@ -93,7 +93,7 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro | get() = size() * 2 """ ) { - with((this / "property" / "property").cast()) { + with((this / "property" / "property").cast()) { name equals "property" children counts 0 with(receiver.assertNotNull("property receiver")) { @@ -120,15 +120,15 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro |} """ ) { - with((this / "property").cast()) { - with((this / "Foo" / "property").cast()) { + with((this / "property").cast()) { + with((this / "Foo" / "property").cast()) { name equals "property" children counts 0 with(getter.assertNotNull("Getter")) { type.constructorFqName equals "kotlin.Int" } } - with((this / "Bar" / "property").cast()) { + with((this / "Bar" / "property").cast()) { name equals "property" children counts 0 with(getter.assertNotNull("Getter")) { diff --git a/plugins/base/src/test/kotlin/utils/ModelUtils.kt b/plugins/base/src/test/kotlin/utils/ModelUtils.kt index 75c8e008..1e6f64c6 100644 --- a/plugins/base/src/test/kotlin/utils/ModelUtils.kt +++ b/plugins/base/src/test/kotlin/utils/ModelUtils.kt @@ -1,8 +1,6 @@ package utils -import org.jetbrains.dokka.model.Module -import org.jetbrains.dokka.model.doc.DocumentationNode -import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.jetbrains.dokka.model.DModule abstract class AbstractModelTest(val path: String? = null, val pkg: String) : ModelDSL(), AssertDSL { @@ -11,7 +9,7 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo platform: String = "jvm", targetList: List = listOf("jvm"), prependPackage: Boolean = true, - block: Module.() -> Unit + block: DModule.() -> Unit ) { val configuration = dokkaConfiguration { passes { diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index 6913ba5b..bf86c1b1 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -1,13 +1,9 @@ package utils -import org.jetbrains.dokka.model.Class +import org.jetbrains.dokka.model.DClass 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 org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest -import kotlin.reflect.KClass -import kotlin.reflect.full.safeCast @DslMarker annotation class TestDSL @@ -64,5 +60,5 @@ fun T?.assertNotNull(name: String = ""): T = this ?: throw AssertionError("$ fun T?.docs() = this?.documentation.orEmpty().values.flatMap { it.children } -val Class.supers +val DClass.supers get() = supertypes.flatMap{it.component2()} \ No newline at end of file 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 cf777e67..991ee07d 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt @@ -4,9 +4,9 @@ import org.jetbrains.dokka.links.Callable import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.withClass import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Annotation -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DAnnotation +import org.jetbrains.dokka.model.DEnum +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap import org.jetbrains.kotlin.name.ClassId @@ -21,21 +21,21 @@ private fun List.groupedByLocation() = } // TODO: first() does not look reasonable }) { it.second } -internal fun Package.asJava(): Package { +internal fun DPackage.asJava(): DPackage { @Suppress("UNCHECKED_CAST") val syntheticClasses = ((properties + functions) as List) .groupedByLocation() .map { (syntheticClassName, nodes) -> - Class( + DClass( dri = dri.withClass(syntheticClassName), name = syntheticClassName, - properties = nodes.filterIsInstance().map { it.asJava() }, + properties = nodes.filterIsInstance().map { it.asJava() }, constructors = emptyList(), functions = ( - nodes.filterIsInstance() + nodes.filterIsInstance() .map { it.javaAccessors() } + - nodes.filterIsInstance() - .map { it.asJava(syntheticClassName) }) as List, // TODO: methods are static and receiver is a param + nodes.filterIsInstance() + .map { it.asJava(syntheticClassName) }) as List, // TODO: methods are static and receiver is a param classlikes = emptyList(), sources = PlatformDependent.empty(), visibility = PlatformDependent( @@ -60,7 +60,7 @@ internal fun Package.asJava(): Package { ) } -internal fun Property.asJava(isTopLevel: Boolean = false, relocateToClass: String? = null) = +internal fun DProperty.asJava(isTopLevel: Boolean = false, relocateToClass: String? = null) = copy( dri = if (relocateToClass.isNullOrBlank()) { dri @@ -81,7 +81,7 @@ internal fun Property.asJava(isTopLevel: Boolean = false, relocateToClass: Strin extra = if (isTopLevel) extra.plus(extra.mergeAdditionalModifiers(setOf(ExtraModifiers.STATIC))) else extra ) -internal fun Property.javaAccessors(isTopLevel: Boolean = false, relocateToClass: String? = null): List = +internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClass: String? = null): List = listOfNotNull( getter?.copy( dri = if (relocateToClass.isNullOrBlank()) { @@ -122,7 +122,7 @@ internal fun Property.javaAccessors(isTopLevel: Boolean = false, relocateToClass ) -internal fun Function.asJava(containingClassName: String): Function { +internal fun DFunction.asJava(containingClassName: String): DFunction { val newName = when { isConstructor -> containingClassName else -> name @@ -137,16 +137,16 @@ internal fun Function.asJava(containingClassName: String): Function { ) // TODO static if toplevel } -internal fun Classlike.asJava(): Classlike = when (this) { - is Class -> asJava() - is Enum -> asJava() - is Annotation -> asJava() - is Object -> asJava() - is Interface -> asJava() +internal fun DClasslike.asJava(): DClasslike = when (this) { + is DClass -> asJava() + is DEnum -> asJava() + is DAnnotation -> asJava() + is DObject -> asJava() + is DInterface -> asJava() else -> throw IllegalArgumentException("$this shouldn't be here") } -internal fun Class.asJava(): Class = copy( +internal fun DClass.asJava(): DClass = copy( constructors = constructors.map { it.asJava(name) }, functions = (functions + properties.map { it.getter } + properties.map { it.setter }).filterNotNull().map { it.asJava(name) @@ -160,7 +160,7 @@ internal fun Class.asJava(): Class = copy( modifier = if (modifier is KotlinModifier.Empty) JavaModifier.Final else modifier ) -private fun TypeParameter.asJava(): TypeParameter = copy( +private fun DTypeParameter.asJava(): DTypeParameter = copy( dri = dri.possiblyAsJava(), bounds = bounds.map { it.asJava() } ) @@ -175,7 +175,7 @@ private fun Bound.asJava(): Bound = when (this) { else -> this } -internal fun Enum.asJava(): Enum = copy( +internal fun DEnum.asJava(): DEnum = copy( constructors = constructors.map { it.asJava(name) }, functions = (functions + properties.map { it.getter } + properties.map { it.setter }).filterNotNull().map { it.asJava(name) @@ -188,12 +188,12 @@ internal fun Enum.asJava(): Enum = copy( // , entries = entries.map { it.asJava() } ) -internal fun Object.asJava(): Object = copy( +internal fun DObject.asJava(): DObject = copy( functions = (functions + properties.map { it.getter } + properties.map { it.setter }) .filterNotNull() .map { it.asJava(name.orEmpty()) }, properties = properties.map { it.asJava() } + - Property( + DProperty( name = "INSTANCE", modifier = JavaModifier.Final, dri = dri.copy(callable = Callable("INSTANCE", null, emptyList())), @@ -209,7 +209,7 @@ internal fun Object.asJava(): Object = copy( getter = null, platformData = platformData, receiver = null, - extra = PropertyContainer.empty() + AdditionalModifiers(setOf(ExtraModifiers.STATIC)) + extra = PropertyContainer.empty() + AdditionalModifiers(setOf(ExtraModifiers.STATIC)) ), classlikes = classlikes.map { it.asJava() }, supertypes = supertypes.copy( @@ -217,7 +217,7 @@ internal fun Object.asJava(): Object = copy( ) ) -internal fun Interface.asJava(): Interface = copy( +internal fun DInterface.asJava(): DInterface = copy( functions = (functions + properties.map { it.getter } + properties.map { it.setter }) .filterNotNull() .map { it.asJava(name) }, @@ -229,13 +229,13 @@ internal fun Interface.asJava(): Interface = copy( ) ) -internal fun Annotation.asJava(): Annotation = copy( +internal fun DAnnotation.asJava(): DAnnotation = copy( properties = properties.map { it.asJava() }, constructors = emptyList(), classlikes = classlikes.map { it.asJava() } ) // TODO investigate if annotation class can have methods and properties not from constructor -internal fun Parameter.asJava(): Parameter = copy( +internal fun DParameter.asJava(): DParameter = copy( type = type.asJava(), name = if (name.isNullOrBlank()) "\$self" else name ) diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt index 55dd7a97..0ec7d0af 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt @@ -5,9 +5,9 @@ import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentCon import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder import org.jetbrains.dokka.links.sureClassNames import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.Annotation -import org.jetbrains.dokka.model.Enum -import org.jetbrains.dokka.model.Function +import org.jetbrains.dokka.model.DAnnotation +import org.jetbrains.dokka.model.DEnum +import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.pages.ContentKind import org.jetbrains.dokka.pages.ContentNode import org.jetbrains.dokka.pages.TextStyle @@ -22,28 +22,28 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge override fun signature(documentable: Documentable): ContentNode = when (documentable) { - is Function -> signature(documentable) - is Property -> signature(documentable) - is Classlike -> signature(documentable) - is TypeParameter -> signature(documentable) + is DFunction -> signature(documentable) + is DProperty -> signature(documentable) + is DClasslike -> signature(documentable) + is DTypeParameter -> signature(documentable) else -> throw NotImplementedError( "Cannot generate signature for ${documentable::class.qualifiedName} ${documentable.name}" ) } - private fun signature(c: Classlike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) { + private fun signature(c: DClasslike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) { platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " } - if (c is Class) { + if (c is DClass) { text(c.modifier.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " ") } when (c) { - is Class -> text("class ") - is Interface -> text("interface ") - is Enum -> text("enum ") - is Object -> text("class ") - is Annotation -> text("@interface ") + is DClass -> text("class ") + is DInterface -> text("interface ") + is DEnum -> text("enum ") + is DObject -> text("class ") + is DAnnotation -> text("@interface ") } link(c.name!!, c.dri) if (c is WithGenerics) { @@ -60,11 +60,11 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge } } - private fun signature(p: Property) = contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace)) { + private fun signature(p: DProperty) = contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace)) { signatureForProjection(p.type) } - private fun signature(f: Function) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) { + private fun signature(f: DFunction) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) { text(f.modifier.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " ") val returnType = f.type signatureForProjection(returnType) @@ -82,7 +82,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge text(")") } - private fun signature(t: TypeParameter) = contentBuilder.contentFor(t) { + private fun signature(t: DTypeParameter) = contentBuilder.contentFor(t) { text(t.name.substringAfterLast(".")) list(t.bounds, prefix = " extends ") { signatureForProjection(it) diff --git a/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt b/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt index 8f51e105..8b07670f 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/transformers/KotlinAsJavaDocumentableTransformer.kt @@ -1,11 +1,11 @@ package org.jetbrains.dokka.kotlinAsJava.transformers import org.jetbrains.dokka.kotlinAsJava.converters.asJava -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer class KotlinAsJavaDocumentableTransformer : DocumentableTransformer { - override fun invoke(original: Module, context: DokkaContext): Module = + override fun invoke(original: DModule, context: DokkaContext): DModule = original.copy(packages = original.packages.map { it.asJava() }) } diff --git a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt index 641cc5f9..a0e3b709 100644 --- a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt +++ b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt @@ -1,7 +1,7 @@ package org.jetbrains.dokka.testApi.testRunner import org.jetbrains.dokka.* -import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.pages.RootPageNode @@ -104,9 +104,9 @@ abstract class AbstractCoreTest { protected class TestBuilder { var analysisSetupStage: (Map) -> Unit = {} var pluginsSetupStage: (DokkaContext) -> Unit = {} - var documentablesCreationStage: (List) -> Unit = {} - var documentablesMergingStage: (Module) -> Unit = {} - var documentablesTransformationStage: (Module) -> Unit = {} + var documentablesCreationStage: (List) -> Unit = {} + var documentablesMergingStage: (DModule) -> Unit = {} + var documentablesTransformationStage: (DModule) -> Unit = {} var pagesGenerationStage: (ModulePageNode) -> Unit = {} var pagesTransformationStage: (RootPageNode) -> Unit = {} var renderingStage: (RootPageNode, DokkaContext) -> Unit = { a, b -> } @@ -216,9 +216,9 @@ abstract class AbstractCoreTest { data class TestMethods( val analysisSetupStage: (Map) -> Unit, val pluginsSetupStage: (DokkaContext) -> Unit, - val documentablesCreationStage: (List) -> Unit, - val documentablesMergingStage: (Module) -> Unit, - val documentablesTransformationStage: (Module) -> Unit, + val documentablesCreationStage: (List) -> Unit, + val documentablesMergingStage: (DModule) -> Unit, + val documentablesTransformationStage: (DModule) -> Unit, val pagesGenerationStage: (ModulePageNode) -> Unit, val pagesTransformationStage: (RootPageNode) -> Unit, val renderingStage: (RootPageNode, DokkaContext) -> Unit -- 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/enums/EnumsTest.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/enums/EnumsTest.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 ca2d5042c608951cd2f12ccc324543b59b7cc154 Mon Sep 17 00:00:00 2001 From: Błażej Kardyś Date: Tue, 24 Mar 2020 23:10:27 +0100 Subject: Restricting pages generation for inherited functions --- .../main/kotlin/model/documentableProperties.kt | 7 +++--- .../DefaultDescriptorToDocumentableTranslator.kt | 14 ++++++++--- .../documentables/DefaultPageCreator.kt | 7 ++++-- .../psi/DefaultPsiToDocumentableTranslator.kt | 28 ++++++++++------------ .../base/src/test/kotlin/basic/DokkaBasicTests.kt | 2 +- plugins/base/src/test/kotlin/enums/EnumsTest.kt | 2 -- .../kotlin/multiplatform/BasicMultiplatformTest.kt | 2 +- .../PageTransformerBuilderTest.kt | 2 +- .../annotatedFunctionWithAnnotationParameters.kt | 14 ++++++++++- .../src/functionWithAnnotatedParam.kt | 15 +++++++++++- 10 files changed, 62 insertions(+), 31 deletions(-) (limited to 'plugins/base/src/test/kotlin/enums/EnumsTest.kt') diff --git a/core/src/main/kotlin/model/documentableProperties.kt b/core/src/main/kotlin/model/documentableProperties.kt index 67e5e88d..f630ba3b 100644 --- a/core/src/main/kotlin/model/documentableProperties.kt +++ b/core/src/main/kotlin/model/documentableProperties.kt @@ -4,11 +4,10 @@ import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy data class InheritedFunction(val isInherited: Boolean): ExtraProperty { - object InheritedFunctionKey: ExtraProperty.Key { - override fun mergeStrategyFor(left: Boolean, right: Boolean) = MergeStrategy.Fail { + companion object : ExtraProperty.Key { + override fun mergeStrategyFor(left: InheritedFunction, right: InheritedFunction) = MergeStrategy.Fail { throw IllegalArgumentException("Function inheritance should be consistent!") } } - override val key: ExtraProperty.Key = - InheritedFunctionKey + override val key: ExtraProperty.Key = InheritedFunction } \ 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 1c374626..dd154ce2 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -20,7 +20,6 @@ import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies import org.jetbrains.kotlin.idea.kdoc.findKDoc import org.jetbrains.kotlin.psi.KtExpression -import org.jetbrains.kotlin.psi.psiUtil.findDescendantOfType import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.components.isVararg import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic @@ -270,8 +269,14 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv ) } + fun CallableMemberDescriptor.createDRI(wasOverriden: Boolean = false): Pair = + if (kind == CallableMemberDescriptor.Kind.DECLARATION || overriddenDescriptors.isEmpty()) + Pair(DRI.from(this), wasOverriden) + else + overriddenDescriptors.first().createDRI(true) + override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, parent: DRIWithPlatformInfo): DFunction { - val dri = parent.dri.copy(callable = Callable.from(descriptor)) + val (dri, isInherited) = descriptor.createDRI() val isExpect = descriptor.isExpect val actual = descriptor.createSources() @@ -294,7 +299,10 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv else PlatformDependent.from(platformData, descriptor.modifier()), type = descriptor.returnType!!.toBound(), platformData = listOf(platformData), - extra = PropertyContainer.withAll(descriptor.additionalExtras(), descriptor.getAnnotations()) + extra = PropertyContainer.withAll( + InheritedFunction(isInherited), + descriptor.additionalExtras(), descriptor.getAnnotations() + ) ) } diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index b217117b..11f57696 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -33,7 +33,7 @@ open class DefaultPageCreator( ClasslikePageNode( e.name.orEmpty(), contentForEnumEntry(e), setOf(e.dri), e, e.classlikes.map(::pageForClasslike) + - e.functions.map(::pageForFunction) + e.filteredFunctions.map(::pageForFunction) ) open fun pageForClasslike(c: DClasslike): ClasslikePageNode { @@ -43,13 +43,16 @@ open class DefaultPageCreator( c.name.orEmpty(), contentForClasslike(c), setOf(c.dri), c, constructors.map(::pageForFunction) + c.classlikes.map(::pageForClasslike) + - c.functions.map(::pageForFunction) + + c.filteredFunctions.map(::pageForFunction) + if (c is DEnum) c.entries.map(::pageForEnumEntry) else emptyList() ) } open fun pageForFunction(f: DFunction) = MemberPageNode(f.name, contentForFunction(f), setOf(f.dri), f) + private val WithScope.filteredFunctions + get() = functions.filter { it.extra[InheritedFunction]?.isInherited != true } + protected open fun contentForModule(m: DModule) = contentBuilder.contentFor(m) { header(1) { text(m.name) } block("Packages", 2, ContentKind.Packages, m.packages, m.platformData.toSet()) { diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index ee862fb8..87c78aa8 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -5,7 +5,6 @@ import com.intellij.lang.jvm.types.JvmReferenceType import com.intellij.psi.* import com.intellij.psi.impl.source.PsiClassReferenceType import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.links.DriOfAny import org.jetbrains.dokka.links.withClass import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.properties.PropertyContainer @@ -116,8 +115,8 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { parseSupertypes(superTypes) val (regularFunctions, accessors) = splitFunctionsAndAccessors() val documentation = javadocParser.parseDocumentation(this).toPlatformDependant() - val allFunctions = regularFunctions.mapNotNull { if (!it.isConstructor) parseFunction(it, dri) else null } + - superMethods.map { parseFunction(it, dri, isInherited = true) } + val allFunctions = regularFunctions.mapNotNull { if (!it.isConstructor) parseFunction(it) else null } + + superMethods.map { parseFunction(it, isInherited = true) } val source = PsiDocumentableSource(this).toPlatformDependant() val classlikes = innerClasses.map { parseClasslike(it, dri) } val visibility = getVisibility().toPlatformDependant() @@ -131,11 +130,11 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { documentation, source, allFunctions, - fields.mapNotNull { parseField(it, dri, accessors[it].orEmpty()) }, + fields.mapNotNull { parseField(it, accessors[it].orEmpty()) }, classlikes, visibility, null, - constructors.map { parseFunction(it, dri, true) }, + constructors.map { parseFunction(it, true) }, listOf(platformData), PropertyContainer.empty() + annotations.toList().toExtra() ) @@ -157,11 +156,11 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { documentation, source, allFunctions, - fields.filter { it !is PsiEnumConstant }.map { parseField(it, dri, accessors[it].orEmpty()) }, + fields.filter { it !is PsiEnumConstant }.map { parseField(it, accessors[it].orEmpty()) }, classlikes, visibility, null, - constructors.map { parseFunction(it, dri, true) }, + constructors.map { parseFunction(it, true) }, ancestors, listOf(platformData), PropertyContainer.empty() + annotations.toList().toExtra() @@ -172,7 +171,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { documentation, source, allFunctions, - fields.mapNotNull { parseField(it, dri, accessors[it].orEmpty()) }, + fields.mapNotNull { parseField(it, accessors[it].orEmpty()) }, classlikes, visibility, null, @@ -184,9 +183,9 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { else -> DClass( dri, name.orEmpty(), - constructors.map { parseFunction(it, dri, true) }, + constructors.map { parseFunction(it, true) }, allFunctions, - fields.mapNotNull { parseField(it, dri, accessors[it].orEmpty()) }, + fields.mapNotNull { parseField(it, accessors[it].orEmpty()) }, classlikes, source, visibility, @@ -203,11 +202,10 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { private fun parseFunction( psi: PsiMethod, - parent: DRI, isConstructor: Boolean = false, isInherited: Boolean = false ): DFunction { - val dri = DRI.from(psi).copy(classNames = parent.classNames) + val dri = DRI.from(psi) return DFunction( dri, if (isConstructor) "" else psi.name, @@ -328,7 +326,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { return regularMethods to accessors } - private fun parseField(psi: PsiField, parent: DRI, accessors: List): DProperty { + private fun parseField(psi: PsiField, accessors: List): DProperty { val dri = DRI.from(psi) return DProperty( dri, @@ -338,8 +336,8 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator { psi.getVisibility().toPlatformDependant(), getBound(psi.type), null, - accessors.firstOrNull { it.hasParameters() }?.let { parseFunction(it, parent) }, - accessors.firstOrNull { it.returnType == psi.type }?.let { parseFunction(it, parent) }, + accessors.firstOrNull { it.hasParameters() }?.let { parseFunction(it) }, + accessors.firstOrNull { it.returnType == psi.type }?.let { parseFunction(it) }, psi.getModifier().toPlatformDependant(), listOf(platformData), PropertyContainer.empty() + psi.annotations.toList().toExtra() diff --git a/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt b/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt index dae1b2be..c1044e09 100644 --- a/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt +++ b/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt @@ -32,7 +32,7 @@ class DokkaBasicTests : AbstractCoreTest() { ) { pagesGenerationStage = { println(it.dri) - assertTrue(it.getClasslikeToMemberMap().filterKeys { it.name == "Test" }.entries.firstOrNull()?.value?.size == 5) + assertTrue(it.getClasslikeToMemberMap().filterKeys { it.name == "Test" }.entries.firstOrNull()?.value?.size == 2) } } } diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt index c9024a72..e765d203 100644 --- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -36,7 +36,6 @@ class EnumsTest : AbstractCoreTest() { val test = map.filterKeys { it.name == "Test" }.values.firstOrNull() 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" } } } } @@ -83,7 +82,6 @@ class EnumsTest : AbstractCoreTest() { val test = map.filterKeys { it.name == "Test" }.values.firstOrNull() 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/multiplatform/BasicMultiplatformTest.kt b/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt index 0111e8fb..5facd194 100644 --- a/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt +++ b/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt @@ -47,7 +47,7 @@ class BasicMultiplatformTest : AbstractCoreTest() { configuration ) { pagesGenerationStage = { - assertEquals(6, it.parentMap.size) + assertEquals(3, it.parentMap.size) } } } diff --git a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt index 20ee7490..e66490c1 100644 --- a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt +++ b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt @@ -49,7 +49,7 @@ class PageTransformerBuilderTest : AbstractCoreTest() { orig = it } pagesTransformationStage = { root -> - list.assertCount(7, "Page list: ") + list.assertCount(4, "Page list: ") orig?.let { root.assertTransform(it) } } } diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/src/annotatedFunctionWithAnnotationParameters.kt b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/src/annotatedFunctionWithAnnotationParameters.kt index e559713a..2f872c11 100644 --- a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/src/annotatedFunctionWithAnnotationParameters.kt +++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/src/annotatedFunctionWithAnnotationParameters.kt @@ -1,7 +1,19 @@ @Target(AnnotationTarget.VALUE_PARAMETER) @Retention(AnnotationRetention.SOURCE) @MustBeDocumented -public annotation class Fancy(val size: Int) +public annotation class Fancy(val size: Int) { + override fun equals(other: Any?): Boolean { + return super.equals(other) + } + + override fun hashCode(): Int { + return super.hashCode() + } + + override fun toString(): String { + return super.toString() + } +} @Fancy(1) fun f() {} diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/src/functionWithAnnotatedParam.kt b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/src/functionWithAnnotatedParam.kt index f858e671..0988d4b3 100644 --- a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/src/functionWithAnnotatedParam.kt +++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/src/functionWithAnnotatedParam.kt @@ -1,7 +1,20 @@ @Target(AnnotationTarget.VALUE_PARAMETER) @Retention(AnnotationRetention.SOURCE) @MustBeDocumented -public annotation class Fancy +public annotation class Fancy { + + override fun equals(other: Any?): Boolean { + return super.equals(other) + } + + override fun hashCode(): Int { + return super.hashCode() + } + + override fun toString(): String { + return super.toString() + } +} fun function(@Fancy notInlined: () -> Unit) { } -- cgit From 8ee246fe89011506d8456c48c5dfc04d92ef88cf Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Wed, 8 Apr 2020 17:08:38 +0200 Subject: Fix test --- core/src/main/kotlin/model/Documentable.kt | 9 ++++----- plugins/base/src/test/kotlin/enums/EnumsTest.kt | 5 ++--- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'plugins/base/src/test/kotlin/enums/EnumsTest.kt') diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index 2155b00d..f3eb6b9a 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -7,7 +7,6 @@ import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor import org.jetbrains.kotlin.load.kotlin.toSourceElement abstract class Documentable { @@ -423,10 +422,10 @@ interface DocumentableSource { val path: String } -class DescriptorDocumentableSource(source: DeclarationDescriptor) : DocumentableSource { - override val path = source.toSourceElement.containingFile.toString() +class DescriptorDocumentableSource(val descriptor: DeclarationDescriptor) : DocumentableSource { + override val path = descriptor.toSourceElement.containingFile.toString() } -class PsiDocumentableSource(source: PsiNamedElement) : DocumentableSource { - override val path = source.containingFile.virtualFile.path +class PsiDocumentableSource(val psi: PsiNamedElement) : DocumentableSource { + override val path = psi.containingFile.virtualFile.path } diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt index e765d203..5f8bf8c8 100644 --- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -63,9 +63,8 @@ class EnumsTest : AbstractCoreTest() { """.trimMargin(), configuration ) { - documentablesCreationStage = {m -> - assertTrue(m.isNotEmpty(), "Module list cannot be empty") - m.first().packages.let { p -> + documentablesTransformationStage = { m -> + m.packages.let { p -> assertTrue(p.isNotEmpty(), "Package list cannot be empty") p.first().classlikes.let { c -> assertTrue(c.isNotEmpty(), "Classlikes list cannot be empty") -- cgit From f0742fb7f8a937ef7c2e5a92d6f4a0fd079baa62 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Mon, 25 May 2020 14:40:59 +0200 Subject: Enum constructor values --- core/src/main/kotlin/model/aditionalExtras.kt | 11 ++ .../kotlin/signatures/KotlinSignatureProvider.kt | 14 +- .../DefaultDescriptorToDocumentableTranslator.kt | 26 +++- .../base/src/main/resources/dokka/styles/style.css | 1 - plugins/base/src/test/kotlin/enums/EnumsTest.kt | 146 ++++++++++++++++++++- plugins/base/src/test/kotlin/utils/contentUtils.kt | 2 +- 6 files changed, 189 insertions(+), 11 deletions(-) (limited to 'plugins/base/src/test/kotlin/enums/EnumsTest.kt') diff --git a/core/src/main/kotlin/model/aditionalExtras.kt b/core/src/main/kotlin/model/aditionalExtras.kt index f71852c4..055fc5a6 100644 --- a/core/src/main/kotlin/model/aditionalExtras.kt +++ b/core/src/main/kotlin/model/aditionalExtras.kt @@ -59,4 +59,15 @@ data class ActualTypealias(val underlyingType: SourceSetDependent) : Extr } override val key: ExtraProperty.Key = ActualTypealias +} + +data class ConstructorValues(val values: List) : ExtraProperty{ + companion object : ExtraProperty.Key { + override fun mergeStrategyFor(left: ConstructorValues, right: ConstructorValues) = + MergeStrategy.Fail{ + throw IllegalArgumentException("Merging constructor parameters not applicable") + } + } + + override val key: ExtraProperty.Key = ConstructorValues } \ No newline at end of file diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index 33c82458..367a7a95 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -33,8 +33,16 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } private fun signature(e: DEnumEntry) = - contentBuilder.contentFor(e, ContentKind.Symbol, setOf(TextStyle.Monospace)) { - link(e.name, e.dri) + contentBuilder.contentFor(e, ContentKind.Symbol, setOf(TextStyle.Monospace), sourceSets = e.sourceSets.toSet()) { + group(styles = setOf(TextStyle.Block)){ + annotationsBlock(e) + link(e.name, e.dri, styles = emptySet()) + e.extra[ConstructorValues]?.let { + list(it.values, prefix = "(", suffix = ")"){ + text(it) + } + } + } } private fun actualTypealiasedSignature(dri: DRI, name: String, aliasedTypes: SourceSetDependent) = @@ -87,7 +95,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog +buildSignature(it) } } - if (c is DClass) { + if (c is WithConstructors) { val pConstructor = c.constructors.singleOrNull { it.extra[PrimaryConstructorExtra] != null } if (pConstructor?.annotations()?.isNotEmpty() == true) { text(nbsp.toString()) diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 60182ba9..a56eb454 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -24,8 +24,9 @@ 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.load.kotlin.toSourceElement -import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.calls.callUtil.getValueArgumentsInParentheses import org.jetbrains.kotlin.resolve.calls.components.isVararg import org.jetbrains.kotlin.resolve.constants.ConstantValue import org.jetbrains.kotlin.resolve.constants.AnnotationValue as ConstantsAnnotationValue @@ -41,9 +42,12 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.resolve.source.KotlinSourceElement +import org.jetbrains.kotlin.resolve.source.PsiSourceElement import org.jetbrains.kotlin.types.DynamicType import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeProjection +import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance +import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import org.jetbrains.kotlin.utils.addToStdlib.safeAs import java.nio.file.Paths import kotlin.IllegalArgumentException @@ -212,7 +216,11 @@ private class DokkaDescriptorVisitor( properties = scope.properties(driWithPlatform), sourceSets = listOf(sourceSet), expectPresentInSet = sourceSet.takeIf { isExpect }, - extra = PropertyContainer.withAll(descriptor.additionalExtras(), descriptor.getAnnotations()) + extra = PropertyContainer.withAll( + descriptor.additionalExtras(), + descriptor.getAnnotations(), + ConstructorValues(descriptor.getAppliedConstructorParameters()) + ) ) } @@ -499,7 +507,6 @@ private class DokkaDescriptorVisitor( getContributedDescriptors(DescriptorKindFilter.CLASSIFIERS, packageLevel) .filter { it is ClassDescriptor && it.kind != ClassKind.ENUM_ENTRY } .map { visitClassDescriptor(it as ClassDescriptor, parent) } - .mapNotNull { it as? DClasslike } private fun MemberScope.packages(parent: DRIWithPlatformInfo): List = getContributedDescriptors(DescriptorKindFilter.PACKAGES) { true } @@ -681,6 +688,19 @@ private class DokkaDescriptorVisitor( private fun ValueParameterDescriptor.getDefaultValue(): String? = (source as? KotlinSourceElement)?.psi?.children?.find { it is KtExpression }?.text + private fun ClassDescriptor.getAppliedConstructorParameters() = + (source as PsiSourceElement).psi?.children?.flatMap { + it.safeAs()?.initializersAsText().orEmpty() + }.orEmpty() + + private fun KtInitializerList.initializersAsText() = + initializers.firstIsInstanceOrNull() + ?.getValueArgumentsInParentheses() + ?.flatMap { it.childrenAsText() } + .orEmpty() + + private fun ValueArgument.childrenAsText() = this.safeAs()?.children?.map {it.text }.orEmpty() + private data class ClassInfo(val supertypes: List, val docs: SourceSetDependent) private fun Visibility.toDokkaVisibility(): org.jetbrains.dokka.model.Visibility = when (this) { diff --git a/plugins/base/src/main/resources/dokka/styles/style.css b/plugins/base/src/main/resources/dokka/styles/style.css index d9927046..d573b76c 100644 --- a/plugins/base/src/main/resources/dokka/styles/style.css +++ b/plugins/base/src/main/resources/dokka/styles/style.css @@ -172,7 +172,6 @@ padding: 8px 16px; box-sizing: border-box; font-weight: bold; - white-space: pre; flex-wrap: wrap; } diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt index 5f8bf8c8..6c44dc35 100644 --- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -1,11 +1,16 @@ package enums +import matchers.content.assertNode +import matchers.content.group +import matchers.content.header +import matchers.content.link +import org.jetbrains.dokka.model.ConstructorValues import org.jetbrains.dokka.model.DEnum -import org.jetbrains.dokka.pages.ClasslikePageNode -import org.jetbrains.dokka.pages.ModulePageNode -import org.junit.jupiter.api.Test +import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test +import utils.unwrapAnnotation class EnumsTest : AbstractCoreTest() { @@ -85,7 +90,142 @@ class EnumsTest : AbstractCoreTest() { } } + @Test + fun enumWithConstructor() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package enums + | + | + |enum class Test(name: String, index: Int, excluded: Boolean) { + | E1("e1", 1, true), + | E2("e2", 2, false); + |} + """.trimMargin(), + configuration + ) { + documentablesTransformationStage = { m -> + m.packages.let { p -> + p.first().classlikes.let { c -> + val enum = c.first() as DEnum + val (first, second) = enum.entries + + assertEquals(1, first.extra.allOfType().size) + assertEquals(1, second.extra.allOfType().size) + assertEquals(listOf("\"e1\"", "1", "true"), first.extra.allOfType().first().values) + assertEquals(listOf("\"e2\"", "2", "false"), second.extra.allOfType().first().values) + } + } + } + pagesGenerationStage = { module -> + val entryPage = module.dfs { it.name == "E1" } as ClasslikePageNode + val signaturePart = (entryPage.content.dfs { + it is ContentGroup && it.dci.toString() == "[enums/Test.E1///PointingToDeclaration/][Symbol]" + } as ContentGroup).children.first() as ContentGroup + assertEquals("(\"e1\", 1, true)", signaturePart.constructorSignature()) + } + } + } + + @Test + fun enumWithMethods() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package enums + | + | + |interface Sample { + | fun toBeImplemented(): String + |} + | + |enum class Test: Sample { + | E1 { + | override fun toBeImplemented(): String = "e1" + | } + |} + """.trimMargin(), + configuration + ) { + documentablesTransformationStage = { m -> + m.packages.let { p -> + p.first().classlikes.let { c -> + val enum = c.first { it is DEnum } as DEnum + val first = enum.entries.first() + + assertEquals(1, first.extra.allOfType().size) + assertEquals(emptyList(), first.extra.allOfType().first().values) + assertNotNull(first.functions.find { it.name == "toBeImplemented" }) + } + } + } + } + } + + @Test + fun enumWithAnnotationsOnEntries(){ + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package enums + | + |enum class Test { + | @SinceKotlin("1.3") + | E1 + |} + """.trimMargin(), + configuration + ) { + pagesTransformationStage = { m -> + val entryNode = m.children.first { it.name == "enums" }.children.first { it.name == "Test" }.children.first() as ClasslikePageNode + val signature = (entryNode.content as ContentGroup).dfs { it is ContentGroup && it.dci.toString() == "[enums/Test.E1///PointingToDeclaration/][Cover]" } as ContentGroup + + signature.assertNode { + header(1) { +"E1" } + group { + mapOf("SinceKotlin" to setOf("version")).entries.forEach { + group { + group { + unwrapAnnotation(it) + } + link { +"E1" } + } + } + } + } + } + } + } + fun ModulePageNode.getClasslikeToMemberMap() = this.parentMap.filterValues { it is ClasslikePageNode }.entries.groupBy({ it.value }) { it.key } + + private fun ContentGroup.constructorSignature(): String = + children.drop(1).joinToString(separator = "") { (it as ContentText).text } } \ No newline at end of file diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index 4aba3e9d..7e1b8bf4 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -184,7 +184,7 @@ fun ContentMatcherBuilder<*>.unnamedTag(tag: String, content: ContentMatcherBuil group { content() } } -private fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry>) { +fun ContentMatcherBuilder<*>.unwrapAnnotation(elem: Map.Entry>) { +"@" link { +elem.key } +"(" -- cgit From 23e0d26139a09c7e2e157d1e0099ceab58d9bb48 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Thu, 4 Jun 2020 16:44:25 +0200 Subject: Make enum entry constructor sourceset dependent --- core/src/main/kotlin/model/aditionalExtras.kt | 6 ++---- .../kotlin/signatures/KotlinSignatureProvider.kt | 6 +++--- .../DefaultDescriptorToDocumentableTranslator.kt | 2 +- .../documentables/DefaultPageCreator.kt | 6 ++++-- plugins/base/src/test/kotlin/enums/EnumsTest.kt | 24 +++++++++++----------- 5 files changed, 22 insertions(+), 22 deletions(-) (limited to 'plugins/base/src/test/kotlin/enums/EnumsTest.kt') diff --git a/core/src/main/kotlin/model/aditionalExtras.kt b/core/src/main/kotlin/model/aditionalExtras.kt index 055fc5a6..1023545d 100644 --- a/core/src/main/kotlin/model/aditionalExtras.kt +++ b/core/src/main/kotlin/model/aditionalExtras.kt @@ -61,12 +61,10 @@ data class ActualTypealias(val underlyingType: SourceSetDependent) : Extr override val key: ExtraProperty.Key = ActualTypealias } -data class ConstructorValues(val values: List) : ExtraProperty{ +data class ConstructorValues(val values: SourceSetDependent>) : ExtraProperty{ companion object : ExtraProperty.Key { override fun mergeStrategyFor(left: ConstructorValues, right: ConstructorValues) = - MergeStrategy.Fail{ - throw IllegalArgumentException("Merging constructor parameters not applicable") - } + MergeStrategy.Replace(ConstructorValues(left.values + right.values)) } override val key: ExtraProperty.Key = ConstructorValues diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index 367a7a95..c05dab3c 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -37,9 +37,9 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog group(styles = setOf(TextStyle.Block)){ annotationsBlock(e) link(e.name, e.dri, styles = emptySet()) - e.extra[ConstructorValues]?.let { - list(it.values, prefix = "(", suffix = ")"){ - text(it) + e.extra[ConstructorValues]?.let { constructorValues -> + platformText(constructorValues.values, constructorValues.values.keys){ + it.joinToString(prefix = "(", postfix = ")") } } } diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index a56eb454..f3b047bc 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -219,7 +219,7 @@ private class DokkaDescriptorVisitor( extra = PropertyContainer.withAll( descriptor.additionalExtras(), descriptor.getAnnotations(), - ConstructorValues(descriptor.getAppliedConstructorParameters()) + ConstructorValues(descriptor.getAppliedConstructorParameters().toSourceSetDependent()) ) ) } diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 7f9a8074..1954cec9 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -141,8 +141,10 @@ open class DefaultPageCreator( protected open fun contentForEnumEntry(e: DEnumEntry) = contentBuilder.contentFor(e) { group(kind = ContentKind.Cover) { header(1, e.name) - +buildSignature(e) - +contentForDescription(e) + sourceSetDependentHint(e.dri, e.sourceSets.toSet()) { + +buildSignature(e) + +contentForDescription(e) + } } group(styles = setOf(ContentStyle.TabbedContent)){ +contentForComments(e) diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt index 6c44dc35..74fc18c4 100644 --- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt +++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt @@ -1,9 +1,6 @@ package enums -import matchers.content.assertNode -import matchers.content.group -import matchers.content.header -import matchers.content.link +import matchers.content.* import org.jetbrains.dokka.model.ConstructorValues import org.jetbrains.dokka.model.DEnum import org.jetbrains.dokka.pages.* @@ -121,8 +118,8 @@ class EnumsTest : AbstractCoreTest() { assertEquals(1, first.extra.allOfType().size) assertEquals(1, second.extra.allOfType().size) - assertEquals(listOf("\"e1\"", "1", "true"), first.extra.allOfType().first().values) - assertEquals(listOf("\"e2\"", "2", "false"), second.extra.allOfType().first().values) + assertEquals(listOf("\"e1\"", "1", "true"), first.extra.allOfType().first().values.values.first()) + assertEquals(listOf("\"e2\"", "2", "false"), second.extra.allOfType().first().values.values.first()) } } } @@ -171,7 +168,7 @@ class EnumsTest : AbstractCoreTest() { val first = enum.entries.first() assertEquals(1, first.extra.allOfType().size) - assertEquals(emptyList(), first.extra.allOfType().first().values) + assertEquals(emptyList(), first.extra.allOfType().first().values.values.first()) assertNotNull(first.functions.find { it.name == "toBeImplemented" }) } } @@ -207,13 +204,16 @@ class EnumsTest : AbstractCoreTest() { signature.assertNode { header(1) { +"E1" } - group { - mapOf("SinceKotlin" to setOf("version")).entries.forEach { - group { + platformHinted { + group { + mapOf("SinceKotlin" to setOf("version")).entries.forEach { group { - unwrapAnnotation(it) + group { + unwrapAnnotation(it) + } + link { +"E1" } + +"()" } - link { +"E1" } } } } -- cgit From 77c8777b7f66bddd374d68decd507547d356d602 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Sun, 31 May 2020 21:02:46 +0200 Subject: Improve CSS, pages navigation tree and create anchors on page --- core/src/main/kotlin/pages/ContentNodes.kt | 14 +- core/src/main/kotlin/pages/PageNodes.kt | 1 - .../frontend/src/main/components/app/index.scss | 8 +- .../frontend/src/main/components/app/index.tsx | 45 +-- .../src/main/components/search/search.scss | 14 + .../frontend/src/main/components/search/search.tsx | 16 +- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 258 +++++++++++----- .../kotlin/renderers/html/htmlPreprocessors.kt | 20 +- .../kotlin/signatures/KotlinSignatureProvider.kt | 2 +- .../documentables/DefaultPageCreator.kt | 67 ++--- .../documentables/PageContentBuilder.kt | 14 +- .../src/main/resources/dokka/scripts/clipboard.js | 52 ++++ .../resources/dokka/scripts/navigationLoader.js | 11 + .../base/src/main/resources/dokka/styles/style.css | 330 ++++++++++++++++++--- .../kotlin/content/params/ContentForParamsTest.kt | 146 ++++----- .../content/seealso/ContentForSeeAlsoTest.kt | 170 +++++------ plugins/base/src/test/kotlin/enums/EnumsTest.kt | 8 + .../kotlin/linkableContent/LinkableContentTest.kt | 4 +- plugins/base/src/test/kotlin/markdown/LinkTest.kt | 13 +- .../test/kotlin/renderers/RenderingOnlyTestBase.kt | 1 + .../test/kotlin/renderers/html/DivergentTest.kt | 26 +- 21 files changed, 842 insertions(+), 378 deletions(-) create mode 100644 plugins/base/frontend/src/main/components/search/search.scss create mode 100644 plugins/base/src/main/resources/dokka/scripts/clipboard.js (limited to 'plugins/base/src/test/kotlin/enums/EnumsTest.kt') diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt index 95b7b371..d6105bec 100644 --- a/core/src/main/kotlin/pages/ContentNodes.kt +++ b/core/src/main/kotlin/pages/ContentNodes.kt @@ -13,6 +13,8 @@ interface ContentNode : WithExtraProperties { val dci: DCI val sourceSets: Set val style: Set