Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Dokka's version with general maintenance #40

Merged
merged 3 commits into from
Apr 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ allprojects {

tasks.withType<KotlinCompile> {
kotlinOptions.apply {
languageVersion = "1.3"
languageVersion = "1.6"
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs + listOf("-Xskip-runtime-version-check")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Afaik 1.3 is not supported in 1.6 anymore, so had to bump it. Can change to 1.5 or 1.4 if there's a need for this
  2. Not sure why it was initially added, but I believe -Xskip-runtime-version-check is not needed anymore since it's the same version of kotlin and dokka -- there's no error now. Can revert, but would love to know why it's needed then :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to stick with 1.4, otherwise Gradle 6.x won't be able to consume newer Knit (because it's bundling Kotlin 1.4). You may need -Xsuppress-version-warnings for that.

Regarding 2, sure, it's no longer needed

allWarningsAsErrors = true
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
version=0.3.0-SNAPSHOT
group=org.jetbrains.kotlinx

kotlinVersion=1.4.32
dokkaVersion=1.5.0
kotlinVersion=1.6.10
dokkaVersion=1.6.10
freemarkerVersion=2.3.29
pluginPublishVersion=0.15.0
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions src/Knit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ private fun String.capitalizeAfter(char: Char): String = buildString {
var cap = false
for (c in this@capitalizeAfter) {
cap = if (c == char) true else {
append(if (cap) c.toUpperCase() else c)
append(if (cap) c.uppercaseChar() else c)
false
}
}
Expand All @@ -462,7 +462,7 @@ private fun String.capitalizeAfter(char: Char): String = buildString {
data class TocRef(val levelPrefix: String, val name: String, val ref: String)

fun makeTest(knit: KnitRef, testLines: List<String>, param: String): TestCase =
TestCase(knit.props, knit.name, knit.name.capitalize(), param, testLines)
TestCase(knit.props, knit.name, knit.name.capitalizeFirstChar(), param, testLines)

@Suppress("unused") // This class is passed to freemarker template
class TestTemplateEnv(
Expand Down Expand Up @@ -542,7 +542,7 @@ private const val skippedTocSymbols = "\\,`*{}[]()/#+.!"
fun makeSectionRef(name: String): String = name
.replace(' ', '-')
.replace(("[" + Regex.escape(skippedTocSymbols) + "]").toRegex(), "")
.toLowerCase()
.lowercase()

enum class IncludeType { INCLUDE, PREFIX, SUFFIX }

Expand Down
4 changes: 2 additions & 2 deletions src/KnitApiParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ApiIndex {

// taking the shortest reference among candidates, prefer classes to functions
operator fun get(name: String): String? =
m[name]?.minWith(apiLinkComparator)?.link
m[name]?.minWithOrNull(apiLinkComparator)?.link
}

private fun ApiIndex.addName(pkg: String, name: String, path: String, link: String, type: DocumentableType, namePrefix: String) {
Expand Down Expand Up @@ -160,7 +160,7 @@ fun KnitContext.processApiIndex(
val siteLink = "$siteRoot/$link"
indexList += "[$refName]: $siteLink"
it.remove()
val oldNameCase = uppercaseApiRefNames.put(refName.toUpperCase(Locale.ROOT), refName)
val oldNameCase = uppercaseApiRefNames.put(refName.uppercase(Locale.ROOT), refName)
if (oldNameCase != null) {
log.warn("WARNING: $inputFile: References [$refName] and [$oldNameCase] are different only in case, not distinguishable in markdown.")
}
Expand Down
11 changes: 10 additions & 1 deletion src/KnitUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package kotlinx.knit

import java.io.*
import java.util.*

fun <T : LineNumberReader> KnitContext.withLineNumberReader(file: File, factory: (Reader) -> T, block: T.() -> Unit): T? {
val reader = factory(file.reader())
Expand All @@ -19,4 +20,12 @@ fun <T : LineNumberReader> KnitContext.withLineNumberReader(file: File, factory:
return reader
}

operator fun File.div(path: String): File = File(this, path.replace("/", File.separator))
operator fun File.div(path: String): File = File(this, path.replace("/", File.separator))

internal fun String.capitalizeFirstChar() = this.replaceFirstChar {
IgnatBeresnev marked this conversation as resolved.
Show resolved Hide resolved
if (it.isLowerCase()) {
it.titlecase(Locale.getDefault())
} else {
it.toString()
}
}
2 changes: 1 addition & 1 deletion test/TestDataGen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private fun writeTest(out: PrintWriter, type: TestCaseType, inPath: Path) {
val inFileName = inPath.fileName.toString()
assertTrue(inFileName.endsWith(type.inSuffix))
val testPrefix = inFileName.substring(0, inFileName.length - type.inSuffix.length)
val testName = testPrefix.split("-").map { it.capitalize() }.joinToString("")
val testName = testPrefix.split("-").joinToString("") { it.capitalizeFirstChar() }
val outPath = TEST_DATA_DIR.resolve(testPrefix + type.outSuffix).takeIfExists() ?: inPath
val propsPath = TEST_DATA_DIR.resolve(testPrefix + PROPERTIES_SUFFIX).takeIfExists()
val params = mutableListOf<Any?>(testName, inPath, outPath, propsPath)
Expand Down