mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
Address warning diagnostics (#1395)
This addressess various warning diagnostics throughout the codebase.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,15 +27,7 @@ internal class ClassPageGenerator(
|
||||
pageScope: ClassScope,
|
||||
isTestMode: Boolean,
|
||||
consoleOut: OutputStream,
|
||||
) :
|
||||
ModuleOrClassPageGenerator<ClassScope>(
|
||||
docsiteInfo,
|
||||
docModule,
|
||||
clazz,
|
||||
pageScope,
|
||||
isTestMode,
|
||||
consoleOut,
|
||||
) {
|
||||
) : ModuleOrClassPageGenerator<ClassScope>(docsiteInfo, clazz, pageScope, isTestMode, consoleOut) {
|
||||
override val html: HTML.() -> Unit = {
|
||||
renderHtmlHead()
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,8 +25,3 @@ internal object HtmlConstants {
|
||||
/** The `known-usages` element ID. */
|
||||
const val KNOWN_USAGES: String = "known-usages"
|
||||
}
|
||||
|
||||
internal object CssConstants {
|
||||
/** The `current-version` CSS class. */
|
||||
const val CURRENT_VERSION: String = "current-version"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,7 +21,6 @@ import kotlinx.html.*
|
||||
internal abstract class MainOrPackagePageGenerator<S>(
|
||||
docsiteInfo: DocsiteInfo,
|
||||
pageScope: S,
|
||||
private val siteScope: SiteScope,
|
||||
consoleOut: OutputStream,
|
||||
) : PageGenerator<S>(docsiteInfo, pageScope, consoleOut) where S : PageScope {
|
||||
protected fun UL.renderModuleOrPackage(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,7 +23,7 @@ internal class MainPageGenerator(
|
||||
private val packagesData: List<PackageData>,
|
||||
pageScope: SiteScope,
|
||||
consoleOut: OutputStream,
|
||||
) : MainOrPackagePageGenerator<SiteScope>(docsiteInfo, pageScope, pageScope, consoleOut) {
|
||||
) : MainOrPackagePageGenerator<SiteScope>(docsiteInfo, pageScope, consoleOut) {
|
||||
override val html: HTML.() -> Unit = {
|
||||
renderHtmlHead()
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.pkl.doc
|
||||
|
||||
import java.io.OutputStream
|
||||
import java.io.StringWriter
|
||||
import kotlinx.html.*
|
||||
import org.pkl.core.Member
|
||||
import org.pkl.core.PClass
|
||||
@@ -24,11 +23,9 @@ import org.pkl.core.PClass.ClassMember
|
||||
import org.pkl.core.PClass.Method
|
||||
import org.pkl.core.TypeParameter
|
||||
import org.pkl.core.TypeParameter.Variance
|
||||
import org.pkl.core.ValueRenderers
|
||||
|
||||
internal abstract class ModuleOrClassPageGenerator<S>(
|
||||
docsiteInfo: DocsiteInfo,
|
||||
private val docModule: DocModule,
|
||||
protected val clazz: PClass,
|
||||
scope: S,
|
||||
private val isTestMode: Boolean,
|
||||
@@ -141,12 +138,6 @@ internal abstract class ModuleOrClassPageGenerator<S>(
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderExportedValue(value: Any): String {
|
||||
val writer = StringWriter()
|
||||
ValueRenderers.pcf(writer, " ", false, false).renderValue(value)
|
||||
return writer.toString()
|
||||
}
|
||||
|
||||
protected fun HtmlBlockTag.renderMethods() {
|
||||
if (!clazz.hasListedMethod) return
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,6 @@ internal class ModulePageGenerator(
|
||||
) :
|
||||
ModuleOrClassPageGenerator<ModuleScope>(
|
||||
docsiteInfo,
|
||||
docModule,
|
||||
docModule.schema.moduleClass,
|
||||
pageScope,
|
||||
isTestMode,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,7 +23,7 @@ internal class PackagePageGenerator(
|
||||
private val docPackage: DocPackage,
|
||||
pageScope: PackageScope,
|
||||
consoleOut: OutputStream,
|
||||
) : MainOrPackagePageGenerator<PackageScope>(docsiteInfo, pageScope, pageScope.parent, consoleOut) {
|
||||
) : MainOrPackagePageGenerator<PackageScope>(docsiteInfo, pageScope, consoleOut) {
|
||||
override val html: HTML.() -> Unit = {
|
||||
renderHtmlHead()
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -112,7 +112,7 @@ internal val String.uriEncodedComponent
|
||||
* Follows `encodeURI` from ECMAScript.
|
||||
*/
|
||||
internal val String.uriEncoded
|
||||
get(): String = replace(Regex("([^;/?:@&=+\$,#]+)")) { it.value.uriEncodedComponent }
|
||||
get(): String = replace(Regex("([^;/?:@&=+$,#]+)")) { it.value.uriEncodedComponent }
|
||||
|
||||
fun getModulePath(moduleName: String, packagePrefix: String): String =
|
||||
moduleName.substring(packagePrefix.length).replace('.', '/')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,7 +32,7 @@ class DocGeneratorTest {
|
||||
fun `uses virtual thread executor on JDK 21`() {
|
||||
// On older JDKs, we get a ThreadPoolExecutor.
|
||||
// not sure if there's a better assertion to make here.
|
||||
assertThat(DocGenerator.Companion.executor.javaClass.canonicalName)
|
||||
assertThat(DocGenerator.executor.javaClass.canonicalName)
|
||||
.isEqualTo("java.util.concurrent.ThreadPerTaskExecutor")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -85,17 +85,6 @@ class DocGeneratorTestHelper {
|
||||
|
||||
internal val cacheDir: Path by lazy { tempDir.resolve("cache") }
|
||||
|
||||
internal val sourceModules =
|
||||
listOf(
|
||||
docsiteModule,
|
||||
package1PackageModule,
|
||||
package2PackageModule,
|
||||
URI("package://localhost:0/birds@0.5.0"),
|
||||
URI("package://localhost:0/fruit@1.1.0"),
|
||||
URI("package://localhost:0/unlisted@1.0.0"),
|
||||
URI("package://localhost:0/deprecated@1.0.0"),
|
||||
) + package1InputModules + package2InputModules
|
||||
|
||||
internal val expectedRelativeOutputFiles: List<String> by lazy {
|
||||
expectedOutputFiles.map { path ->
|
||||
IoUtils.toNormalizedPathString(expectedOutputDir.relativize(path)).let { str ->
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.pkl.doc
|
||||
|
||||
import com.google.common.jimfs.Configuration
|
||||
import com.google.common.jimfs.Jimfs
|
||||
import java.net.URI
|
||||
import java.nio.file.FileSystem
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.createDirectories
|
||||
import kotlin.io.path.exists
|
||||
import org.pkl.commons.test.FileTestUtils
|
||||
import org.pkl.commons.test.listFilesRecursively
|
||||
import org.pkl.core.util.IoUtils
|
||||
|
||||
class TestUtils {
|
||||
val tempFileSystem: FileSystem by lazy { Jimfs.newFileSystem(Configuration.unix()) }
|
||||
|
||||
val tmpOutputDir by lazy { tempFileSystem.getPath("/work/output").apply { createDirectories() } }
|
||||
|
||||
val projectDir = FileTestUtils.rootProjectDir.resolve("pkl-doc")
|
||||
|
||||
val inputDir: Path by lazy {
|
||||
projectDir.resolve("src/test/files/DocGeneratorTest/input").apply { assert(exists()) }
|
||||
}
|
||||
|
||||
val docsiteModule: URI by lazy {
|
||||
inputDir.resolve("docsite-info.pkl").apply { assert(exists()) }.toUri()
|
||||
}
|
||||
|
||||
internal val package1PackageModule: URI by lazy {
|
||||
inputDir.resolve("com.package1/doc-package-info.pkl").apply { assert(exists()) }.toUri()
|
||||
}
|
||||
|
||||
val package2PackageModule: URI by lazy {
|
||||
inputDir.resolve("com.package2/doc-package-info.pkl").apply { assert(exists()) }.toUri()
|
||||
}
|
||||
|
||||
internal val package1InputModules: List<URI> by lazy {
|
||||
inputDir
|
||||
.resolve("com.package1")
|
||||
.listFilesRecursively()
|
||||
.filter { it.fileName.toString() != "doc-package-info.pkl" }
|
||||
.map { it.toUri() }
|
||||
}
|
||||
|
||||
val package2InputModules: List<URI> by lazy {
|
||||
inputDir
|
||||
.resolve("com.package2")
|
||||
.listFilesRecursively()
|
||||
.filter { it.fileName.toString() != "doc-package-info.pkl" }
|
||||
.map { it.toUri() }
|
||||
}
|
||||
|
||||
val expectedOutputDir: Path by lazy {
|
||||
projectDir.resolve("src/test/files/DocGeneratorTest/output").createDirectories()
|
||||
}
|
||||
|
||||
val expectedOutputFiles: List<Path> by lazy { expectedOutputDir.listFilesRecursively() }
|
||||
|
||||
val actualOutputDir: Path by lazy { tempFileSystem.getPath("/work/DocGeneratorTest") }
|
||||
|
||||
val actualOutputFiles: List<Path> by lazy { actualOutputDir.listFilesRecursively() }
|
||||
|
||||
val expectedRelativeOutputFiles: List<String> by lazy {
|
||||
expectedOutputFiles.map { path ->
|
||||
IoUtils.toNormalizedPathString(expectedOutputDir.relativize(path)).let { str ->
|
||||
// Git will by default clone symlinks as shortcuts on Windows, and shortcuts have a
|
||||
// `.lnk` extension.
|
||||
if (IoUtils.isWindows() && str.endsWith(".lnk")) str.dropLast(4) else str
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val actualRelativeOutputFiles: List<String> by lazy {
|
||||
actualOutputFiles.map { IoUtils.toNormalizedPathString(actualOutputDir.relativize(it)) }
|
||||
}
|
||||
|
||||
val binaryFileExtensions = setOf("woff2", "png", "svg")
|
||||
}
|
||||
Reference in New Issue
Block a user