Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into project-structure-r…
Browse files Browse the repository at this point in the history
…efactoring

# Conflicts:
#	dokka-subprojects/plugin-base/src/main/resources/dokka/images/homepage.svg
#	dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/HeaderTest.kt
  • Loading branch information
IgnatBeresnev committed Nov 9, 2023
2 parents f2dd017 + 64cce58 commit b0f2297
Show file tree
Hide file tree
Showing 34 changed files with 239 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.10
dokka_it_kotlin_version=1.9.20
dokka_it_android_gradle_plugin_version=4.2.2
android.useAndroidX=true
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.10
dokka_it_kotlin_version=1.9.20
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ buildscript {
}
}

version = "1.9.10-SNAPSHOT"
version = "1.9.20-SNAPSHOT"

apply(from = "../template.root.gradle.kts")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.10
dokka_it_kotlin_version=1.9.20
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.10
dokka_it_kotlin_version=1.9.20
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@ plugins {
kotlin("jvm")
id("org.jetbrains.dokka")
}

allprojects {
tasks.withType<org.jetbrains.dokka.gradle.AbstractDokkaTask> {
pluginsMapConfiguration.set(
mapOf(
"org.jetbrains.dokka.base.DokkaBase" to """{ "homepageLink" : "https://github.com/Kotlin/dokka/tree/master/integration-tests/gradle/projects/it-multimodule-0/" }"""
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildscript {
}
}

version = "1.9.10-SNAPSHOT"
version = "1.9.20-SNAPSHOT"

apply(from = "../template.root.gradle.kts")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.10
dokka_it_kotlin_version=1.9.20
fail_on_warning=false
report_undocumented=false
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.10
dokka_it_kotlin_version=1.9.20
react_version=18.2.0-pre.467
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.10
dokka_it_kotlin_version=1.9.20
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.10
dokka_it_kotlin_version=1.9.20
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.10
dokka_it_kotlin_version=1.9.20

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ kotlin {
jvm()
linuxX64("linux")
macosX64("macos")
js(BOTH)
js(IR) // Starting with Kotlin 1.9.0, using compiler types LEGACY or BOTH leads to an error.
//TODO Add wasm when kx.coroutines will be supported and published into the main repo
sourceSets {
val commonMain by sourceSets.getting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@
# Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.10
#these flags are enabled by default since 1.6.20.
#remove when this test is executed with Kotlin >= 1.6.20
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
dokka_it_kotlin_version=1.9.20
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.10
dokka_it_kotlin_version=1.9.20
task_number=100
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.10
dokka_it_kotlin_version=1.9.20
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class BasicGradleIntegrationTest : AbstractGradleIntegrationTest() {
val indexFile = File(this, "index.html")
assertTrue(indexFile.isFile, "Missing index.html")
assertTrue(
"""<title>Basic Project 1.9.10-SNAPSHOT API </title>""" in indexFile.readText(),
"""<title>Basic Project 1.9.20-SNAPSHOT API </title>""" in indexFile.readText(),
"Header with version number not present in index.html"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ class MultiModule0IntegrationTest : AbstractGradleIntegrationTest() {
"Expected moduleC being mentioned in -modules.html"
)

val htmlsWithHomepageLink = outputDir.walkTopDown().filter {
it.isFile && it.extension == "html" && it.name != "navigation.html"
}.toList()

assertEquals(16, htmlsWithHomepageLink.size)

htmlsWithHomepageLink.forEach {
assertTrue(
it.readText().contains(
"""https://github.com/Kotlin/dokka/tree/master/integration-tests/gradle/projects/it-multimodule-0/"""
),
"File ${it.absolutePath} doesn't contain link to homepage"
)
}

val gfmOutputDir = File(projectDir, "moduleA/build/dokka/gfmMultiModule")
assertTrue(gfmOutputDir.isDirectory, "Missing dokka GFM output directory")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,19 @@ class Multiplatform0GradleIntegrationTest : AbstractGradleIntegrationTest() {
@ParameterizedTest(name = "{0}")
@ArgumentsSource(AllSupportedTestedVersionsArgumentsProvider::class)
fun execute(buildVersions: BuildVersions) {
val result = createGradleRunner(buildVersions, "dokkaHtml", "-i", "-s").buildRelaxed()
// `enableGranularSourceSetsMetadata` and `enableDependencyPropagation` flags are enabled by default since 1.6.20.
// remove when this test is executed with Kotlin >= 1.6.20
val result = if (buildVersions.kotlinVersion < "1.6.20")
createGradleRunner(
buildVersions,
"dokkaHtml",
"-i",
"-s",
"-Pkotlin.mpp.enableGranularSourceSetsMetadata=true",
"-Pkotlin.native.enableDependencyPropagation=false"
).buildRelaxed()
else
createGradleRunner(buildVersions, "dokkaHtml", "-i", "-s").buildRelaxed()

assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokkaHtml")).outcome)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal open class AllSupportedTestedVersionsArgumentsProvider : TestedVersions

internal object TestedVersions {

val LATEST = BuildVersions("7.6.2", "1.9.10")
val LATEST = BuildVersions("7.6.2", "1.9.20")

/**
* All supported Gradle/Kotlin versions, including [LATEST]
Expand All @@ -24,7 +24,7 @@ internal object TestedVersions {
val ALL_SUPPORTED =
BuildVersions.permutations(
gradleVersions = listOf("7.6.2"),
kotlinVersions = listOf("1.9.0", "1.8.20", "1.7.20", "1.6.21", "1.5.31"),
kotlinVersions = listOf("1.9.10", "1.8.20", "1.7.20", "1.6.21", "1.5.31"),
) + BuildVersions.permutations(
gradleVersions = listOf(*ifExhaustive("7.0", "6.1.1")),
kotlinVersions = listOf(*ifExhaustive( "1.8.0", "1.7.0", "1.6.0", "1.5.0"))
Expand Down Expand Up @@ -61,6 +61,7 @@ internal object TestedVersions {
"1.8.20" to "18.2.0-pre.546",
"1.9.0" to "18.2.0-pre.597",
"1.9.10" to "18.2.0-pre.597",
"1.9.20" to "18.2.0-pre.635",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ internal class WasmTestedVersionsArgumentsProvider : AllSupportedTestedVersionsA
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> {
return super.provideArguments(context).filter {
val buildVersions = it.get().single() as BuildVersions
buildVersions.kotlinVersion >= "1.8.20" // 1.8.20 is the first public version that can be tested with wasm
buildVersions.kotlinVersion >= "1.8.20" && // 1.8.20 is the first public version that can be tested with wasm
buildVersions.kotlinVersion <= "1.9.10"// in 1.9.20 wasm target was split into `wasm-js` and `wasm-wasi`
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion dokka-integration-tests/maven/projects/it-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<version>1.0-SNAPSHOT</version>

<properties>
<kotlin.version>1.9.10</kotlin.version>
<kotlin.version>1.9.20</kotlin.version>
</properties>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ internal class DokkaJsResolverForModuleFactory(
metadataFactories.DefaultDescriptorFactory,
metadataFactories.DefaultPackageFragmentsFactory,
metadataFactories.flexibleTypeDeserializer,
metadataFactories.platformDependentTypeTransformer
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import org.jetbrains.kotlin.library.metadata.DeserializedKlibModuleOrigin
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.library.metadata.KlibMetadataFactories
import org.jetbrains.kotlin.library.KotlinLibrary
import org.jetbrains.kotlin.library.metadata.NativeTypeTransformer
import org.jetbrains.kotlin.library.metadata.NullFlexibleTypeDeserializer
import org.jetbrains.kotlin.library.metadata.parseModuleHeader
import org.jetbrains.kotlin.name.Name
Expand Down Expand Up @@ -107,8 +106,7 @@ internal class DokkaKlibMetadataCommonDependencyContainer(
KlibMetadataModuleDescriptorFactoryImpl(
MetadataFactories.DefaultDescriptorFactory,
MetadataFactories.DefaultPackageFragmentsFactory,
MetadataFactories.flexibleTypeDeserializer,
MetadataFactories.platformDependentTypeTransformer
MetadataFactories.flexibleTypeDeserializer
)
}

Expand Down Expand Up @@ -138,6 +136,5 @@ internal class DokkaKlibMetadataCommonDependencyContainer(
private val MetadataFactories =
KlibMetadataFactories(
{ DefaultBuiltIns.Instance },
NullFlexibleTypeDeserializer,
NativeTypeTransformer()
NullFlexibleTypeDeserializer
)
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,11 @@ public abstract class AbstractTest<M : TestMethods, T : TestBuilder<M>, D : Dokk
?.replaceAfter(".jar", "")
}

protected val commonStdlibPath: String? by lazy {
// TODO: feels hacky, find a better way to do it
ClassLoader.getSystemResource("kotlin/UInt.kotlin_metadata")
?.file
?.replace("file:", "")
?.replaceAfter(".jar", "")
protected val commonStdlibPath: String? by lazy {
// `kotlin-stdlib-common` is legacy
// we can use any platform dependency
// since common code should be resolved with all platform
jvmStdlibPath
}

protected val stdlibExternalDocumentationLink: ExternalDocumentationLinkImpl = ExternalDocumentationLinkImpl(
Expand Down
11 changes: 7 additions & 4 deletions dokka-subprojects/plugin-base/api/plugin-base.api
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,30 @@ public final class org/jetbrains/dokka/base/DokkaBaseConfiguration : org/jetbrai
public static final field mergeImplicitExpectActualDeclarationsDefault Z
public static final field separateInheritedMembersDefault Z
public fun <init> ()V
public fun <init> (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;)V
public synthetic fun <init> (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;Ljava/lang/String;)V
public synthetic fun <init> (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/util/List;
public final fun component2 ()Ljava/util/List;
public final fun component3 ()Z
public final fun component4 ()Ljava/lang/String;
public final fun component5 ()Z
public final fun component6 ()Ljava/io/File;
public final fun copy (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;)Lorg/jetbrains/dokka/base/DokkaBaseConfiguration;
public static synthetic fun copy$default (Lorg/jetbrains/dokka/base/DokkaBaseConfiguration;Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;ILjava/lang/Object;)Lorg/jetbrains/dokka/base/DokkaBaseConfiguration;
public final fun component7 ()Ljava/lang/String;
public final fun copy (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;Ljava/lang/String;)Lorg/jetbrains/dokka/base/DokkaBaseConfiguration;
public static synthetic fun copy$default (Lorg/jetbrains/dokka/base/DokkaBaseConfiguration;Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZLjava/io/File;Ljava/lang/String;ILjava/lang/Object;)Lorg/jetbrains/dokka/base/DokkaBaseConfiguration;
public fun equals (Ljava/lang/Object;)Z
public final fun getCustomAssets ()Ljava/util/List;
public final fun getCustomStyleSheets ()Ljava/util/List;
public final fun getFooterMessage ()Ljava/lang/String;
public final fun getHomepageLink ()Ljava/lang/String;
public final fun getMergeImplicitExpectActualDeclarations ()Z
public final fun getSeparateInheritedMembers ()Z
public final fun getTemplatesDir ()Ljava/io/File;
public fun hashCode ()I
public final fun setCustomAssets (Ljava/util/List;)V
public final fun setCustomStyleSheets (Ljava/util/List;)V
public final fun setFooterMessage (Ljava/lang/String;)V
public final fun setHomepageLink (Ljava/lang/String;)V
public final fun setMergeImplicitExpectActualDeclarations (Z)V
public final fun setSeparateInheritedMembers (Z)V
public final fun setTemplatesDir (Ljava/io/File;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public data class DokkaBaseConfiguration(
var separateInheritedMembers: Boolean = separateInheritedMembersDefault,
var footerMessage: String = defaultFooterMessage,
var mergeImplicitExpectActualDeclarations: Boolean = mergeImplicitExpectActualDeclarationsDefault,
var templatesDir: File? = defaultTemplatesDir
var templatesDir: File? = defaultTemplatesDir,
var homepageLink: String? = null,
) : ConfigurableBlock {
public companion object {
public val defaultFooterMessage: String = "© ${Year.now().value} Copyright"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public object AssetsInstaller : PageTransformer {
"images/copy-successful-icon.svg",
"images/theme-toggle.svg",
"images/burger.svg",
"images/homepage.svg",

// navigation icons
"images/nav-icons/abstract-class.svg",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,16 @@ public class DefaultTemplateModelFactory(
return mapper
}

override fun buildSharedModel(): TemplateMap = mapOf<String, Any>(
"footerMessage" to (configuration?.footerMessage?.takeIf { it.isNotEmpty() }
?: DokkaBaseConfiguration.defaultFooterMessage)
)
override fun buildSharedModel(): TemplateMap {
val mapper = mutableMapOf<String, Any>()

mapper["footerMessage"] =
(configuration?.footerMessage?.takeIf(String::isNotBlank) ?: DokkaBaseConfiguration.defaultFooterMessage)

configuration?.homepageLink?.takeIf(String::isNotBlank)?.let { mapper["homepageLink"] = it }

return mapper
}

private val DisplaySourceSet.comparableKey
get() = sourceSetIDs.merged.let { it.scopeId + it.sourceSetName }
Expand All @@ -107,6 +113,7 @@ public class DefaultTemplateModelFactory(
rel = LinkRel.stylesheet,
href = if (resource.isAbsolute) resource else "$pathToRoot$resource"
)

resource.URIExtension == "js" ->
script(
type = ScriptType.textJavaScript,
Expand All @@ -117,6 +124,7 @@ public class DefaultTemplateModelFactory(
else
async = true
}

resource.isImage() -> link(href = if (resource.isAbsolute) resource else "$pathToRoot$resource")
else -> null
}
Expand All @@ -125,6 +133,7 @@ public class DefaultTemplateModelFactory(
append(resourceHtml)
}
}

}

private class PrintDirective(val generateData: () -> String) : TemplateDirectiveModel {
Expand All @@ -144,7 +153,10 @@ private class PrintDirective(val generateData: () -> String) : TemplateDirective
}
}

private class TemplateDirective(val configuration: DokkaConfiguration, val pathToRoot: String) : TemplateDirectiveModel {
private class TemplateDirective(
val configuration: DokkaConfiguration,
val pathToRoot: String
) : TemplateDirectiveModel {
override fun execute(
env: Environment,
params: MutableMap<Any?, Any?>?,
Expand All @@ -170,6 +182,7 @@ private class TemplateDirective(val configuration: DokkaConfiguration, val pathT
Context(env, body)
)
}

"projectName" -> {
body ?: throw TemplateModelException(
"No directive body $commandName command."
Expand All @@ -183,6 +196,7 @@ private class TemplateDirective(val configuration: DokkaConfiguration, val pathT
Context(env, body)
)
}

else -> throw TemplateModelException(
"The parameter $PARAM_NAME $commandName is unknown"
)
Expand Down
Loading

0 comments on commit b0f2297

Please sign in to comment.