Run spotless formatting (#958)

When we updated spotless's Java and Kotlin formatter, we changed the underlying
formatting rules.
However, due to spotless ratcheting, these formatting changes don't get applied unless a file
gets touched in a commit.

To avoid future PRs introducing lines of change that aren't related to the intention of the PR,
this is a one-time format of all files.
This commit is contained in:
Daniel Chao
2025-02-17 07:36:43 -08:00
committed by GitHub
parent d270829ed3
commit 28b128f86f
79 changed files with 679 additions and 682 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-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.
@@ -24,7 +24,7 @@ internal class ClassPageGenerator(
docModule: DocModule,
clazz: PClass,
pageScope: ClassScope,
isTestMode: Boolean
isTestMode: Boolean,
) : ModuleOrClassPageGenerator<ClassScope>(docsiteInfo, docModule, clazz, pageScope, isTestMode) {
override val html: HTML.() -> Unit = {
renderHtmlHead()
@@ -71,13 +71,13 @@ internal class ClassPageGenerator(
id = HtmlConstants.KNOWN_VERSIONS
classes = runtimeDataClasses
},
)
),
)
renderMemberGroupLinks(
Triple("Overview", "#_overview", memberDocs.isExpandable),
Triple("Properties", "#_properties", clazz.hasListedProperty),
Triple("Methods", "#_methods", clazz.hasListedMethod)
Triple("Methods", "#_methods", clazz.hasListedMethod),
)
renderAnchor("_overview")

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-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.
@@ -57,7 +57,7 @@ class CliDocGenerator(private val options: CliDocGeneratorOptions) : CliCommand(
PklInfo.current()
.packageIndex
.getPackagePage("pkl", Release.current().version().toString())
)
),
)
private fun DependencyMetadata.getPackageDependencies(): List<DocPackageInfo.PackageDependency> {
@@ -78,7 +78,7 @@ class CliDocGenerator(private val options: CliDocGeneratorOptions) : CliCommand(
version = metadata.version.toString(),
sourceCode = metadata.sourceCode,
sourceCodeUrlScheme = metadata.sourceCodeUrlScheme,
documentation = metadata.documentation
documentation = metadata.documentation,
)
add(packageDependency)
}
@@ -269,7 +269,7 @@ class CliDocGenerator(private val options: CliDocGeneratorOptions) : CliCommand(
importedModules::getValue,
versionComparator,
options.normalizedOutputDir,
options.isTestMode
options.isTestMode,
)
.run()
} catch (e: DocGeneratorException) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-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.
@@ -35,7 +35,7 @@ constructor(
* Generates source URLs with fixed line numbers `#L123-L456` to avoid churn in expected output
* files (e.g., when stdlib line numbers change).
*/
val isTestMode: Boolean = false
val isTestMode: Boolean = false,
) {
/** [outputDir] after undergoing normalization. */
val normalizedOutputDir: Path = base.normalizedWorkingDir.resolveSafely(outputDir)

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-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.
@@ -125,7 +125,7 @@ internal class SiteScope(
docPackages: List<DocPackage>,
private val overviewImports: Map<String, URI>,
private val importResolver: (URI) -> ModuleSchema,
outputDir: Path
outputDir: Path,
) : PageScope() {
private val pklVersion = Release.current().version().withBuild(null).toString()
@@ -139,7 +139,7 @@ internal class SiteScope(
docPackage.docModules.map { it.schema },
pklBaseModule,
docPackage.docPackageInfo.overviewImports,
this
this,
)
}
}
@@ -162,7 +162,7 @@ internal class SiteScope(
name: String,
version: String,
sourceCodeUrlScheme: String?,
sourceCode: URI?
sourceCode: URI?,
): PackageScope =
PackageScope(
DocPackageInfo(
@@ -175,12 +175,12 @@ internal class SiteScope(
importUri = "",
issueTracker = null,
overview = null,
uri = null
uri = null,
),
emptyList(),
pklBaseModule,
emptyMap(),
this
this,
)
override fun getMethod(name: String): MethodScope? = null
@@ -196,7 +196,7 @@ internal class SiteScope(
name.startsWith("pkl.") -> {
val packagePage =
packageScopes["pkl"]?.url // link to locally generated stdlib docs if available
?: PklInfo.current().packageIndex.getPackagePage("pkl", pklVersion).toUri()
?: PklInfo.current().packageIndex.getPackagePage("pkl", pklVersion).toUri()
packagePage.resolve(name.substring(4) + "/")
}
// doesn't make much sense to search in [packageScopes]
@@ -227,8 +227,7 @@ internal class SiteScope(
overviewImports[name]?.let { uri ->
val mod = resolveImport(uri)
resolveModuleNameToDocUrl(mod.moduleName)?.let { url -> ModuleScope(mod, url, null) }
}
?: pklBaseScope.getProperty(name)
} ?: pklBaseScope.getProperty(name)
}
internal class PackageScope(
@@ -236,7 +235,7 @@ internal class PackageScope(
modules: List<ModuleSchema>,
pklBaseModule: ModuleSchema,
private val overviewImports: Map<String, URI>,
override val parent: SiteScope
override val parent: SiteScope,
) : PageScope() {
val name = docPackageInfo.name
@@ -305,8 +304,7 @@ internal class PackageScope(
overviewImports[name]?.let { uri ->
val mod = resolveImport(uri)
resolveModuleNameToDocUrl(mod.moduleName)?.let { url -> ModuleScope(mod, url, null) }
}
?: getPklBaseProperty(name)
} ?: getPklBaseProperty(name)
override fun equals(other: Any?): Boolean =
other is PackageScope && docPackageInfo.name == other.docPackageInfo.name
@@ -318,7 +316,7 @@ internal class PackageScope(
internal class ModuleScope(
val module: ModuleSchema,
override val url: URI,
override val parent: PackageScope?
override val parent: PackageScope?,
) : PageScope() {
val name: String
get() = module.moduleName
@@ -335,7 +333,7 @@ internal class ModuleScope(
override fun getProperty(name: String): DocScope? =
module.moduleClass.allProperties[name]?.let { PropertyScope(it, this) }
?: module.allClasses[name]?.let { ClassScope(it, url, this) }
?: module.allTypeAliases[name]?.let { TypeAliasScope(it, url, this) }
?: module.allTypeAliases[name]?.let { TypeAliasScope(it, url, this) }
private fun resolveImport(uri: URI): ModuleSchema = parent!!.resolveImport(uri)
@@ -358,7 +356,8 @@ internal class ModuleScope(
override fun resolveMethod(name: String): MethodScope? =
module.moduleClass.methods[name]?.let { MethodScope(it, this) }
?: parent!!.getPklBaseMethod(name) ?: getMethod(name)
?: parent!!.getPklBaseMethod(name)
?: getMethod(name)
override fun resolveVariable(name: String): DocScope? =
name.takeIf { it == "module" }?.let { this }
@@ -366,11 +365,12 @@ internal class ModuleScope(
val mod = resolveImport(uri)
resolveModuleNameToDocUrl(mod.moduleName)?.let { url -> ModuleScope(mod, url, null) }
}
?: module.moduleClass.properties[name]?.let { PropertyScope(it, this) }
?: module.moduleClass.properties[name]?.let { PropertyScope(it, this) }
// inherited classes/type aliases are in scope when resolving types -> search `all`
?: module.allClasses[name]?.let { ClassScope(it, url, this) }
?: module.allTypeAliases[name]?.let { TypeAliasScope(it, url, this) }
?: parent!!.getPklBaseProperty(name) ?: getProperty(name)
?: module.allTypeAliases[name]?.let { TypeAliasScope(it, url, this) }
?: parent!!.getPklBaseProperty(name)
?: getProperty(name)
override fun equals(other: Any?): Boolean = other is ModuleScope && module == other.module
@@ -380,7 +380,7 @@ internal class ModuleScope(
internal class ClassScope(
val clazz: PClass,
private val parentUrl: URI,
override val parent: ModuleScope?
override val parent: ModuleScope?,
) : PageScope() {
override val url: URI by lazy {
// `isModuleClass` distinction is relevant when this scope is a link target
@@ -406,12 +406,14 @@ internal class ClassScope(
override fun resolveMethod(name: String): MethodScope? =
clazz.methods[name]?.let { MethodScope(it, this) }
?: parent!!.resolveMethod(name) ?: getMethod(name)
?: parent!!.resolveMethod(name)
?: getMethod(name)
override fun resolveVariable(name: String): DocScope? =
clazz.typeParameters.find { it.name == name }?.let { ParameterScope(name, this) }
?: clazz.properties[name]?.let { PropertyScope(it, this) } ?: parent!!.resolveVariable(name)
?: clazz.allProperties[name]?.let { PropertyScope(it, this) }
?: clazz.properties[name]?.let { PropertyScope(it, this) }
?: parent!!.resolveVariable(name)
?: clazz.allProperties[name]?.let { PropertyScope(it, this) }
override fun equals(other: Any?): Boolean = other is ClassScope && clazz == other.clazz
@@ -421,7 +423,7 @@ internal class ClassScope(
internal class TypeAliasScope(
val typeAlias: TypeAlias,
private val parentDocUrl: URI,
override val parent: ModuleScope?
override val parent: ModuleScope?,
) : DocScope() {
override val url: URI
get() = parentDocUrl.resolve("#${typeAlias.simpleName}")
@@ -468,7 +470,8 @@ internal class MethodScope(val method: PClass.Method, override val parent: DocSc
override fun resolveVariable(name: String): DocScope? =
method.typeParameters.find { it.name == name }?.let { ParameterScope(name, this) }
?: method.parameters[name]?.let { ParameterScope(name, this) } ?: parent.resolveVariable(name)
?: method.parameters[name]?.let { ParameterScope(name, this) }
?: parent.resolveVariable(name)
override fun equals(other: Any?): Boolean = other is MethodScope && method == other.method
@@ -477,7 +480,7 @@ internal class MethodScope(val method: PClass.Method, override val parent: DocSc
internal class PropertyScope(
val property: PClass.Property,
override val parent: DocScope // ModuleScope|ClassScope
override val parent: DocScope, // ModuleScope|ClassScope
) : DocScope() {
override val url: URI
get() = parent.url.resolve("#${property.simpleName}")

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-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.
@@ -33,7 +33,7 @@ data class DocsiteInfo(
val overview: String?,
/** Imports used to resolve Pkldoc links in [overview]. */
val overviewImports: Map<String, URI>
val overviewImports: Map<String, URI>,
) {
companion object {
@Suppress("UNCHECKED_CAST")

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-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.
@@ -24,7 +24,7 @@ internal class HtmlGenerator(
docPackages: List<DocPackage>,
importResolver: (URI) -> ModuleSchema,
private val outputDir: Path,
private val isTestMode: Boolean
private val isTestMode: Boolean,
) {
private val siteScope =
SiteScope(docPackages, docsiteInfo.overviewImports, importResolver, outputDir)
@@ -50,7 +50,7 @@ internal class HtmlGenerator(
docModule,
clazz,
ClassScope(clazz, moduleScope.url, moduleScope),
isTestMode
isTestMode,
)
.run()
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-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.
@@ -20,12 +20,12 @@ import kotlinx.html.*
internal abstract class MainOrPackagePageGenerator<S>(
docsiteInfo: DocsiteInfo,
pageScope: S,
private val siteScope: SiteScope
private val siteScope: SiteScope,
) : PageGenerator<S>(docsiteInfo, pageScope) where S : PageScope {
protected fun UL.renderModuleOrPackage(
name: String,
moduleOrPackageScope: DocScope,
memberDocs: MemberDocs
memberDocs: MemberDocs,
) {
li {
renderAnchor(name)
@@ -47,7 +47,7 @@ internal abstract class MainOrPackagePageGenerator<S>(
renderModifiers(
setOf(),
if (moduleOrPackageScope is PackageScope) "package" else "module"
if (moduleOrPackageScope is PackageScope) "package" else "module",
)
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-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.
@@ -30,7 +30,7 @@ internal abstract class ModuleOrClassPageGenerator<S>(
private val docModule: DocModule,
protected val clazz: PClass,
scope: S,
private val isTestMode: Boolean
private val isTestMode: Boolean,
) : PageGenerator<S>(docsiteInfo, scope) where S : PageScope {
protected fun HtmlBlockTag.renderProperties() {
if (!clazz.hasListedProperty) return
@@ -279,9 +279,8 @@ internal abstract class ModuleOrClassPageGenerator<S>(
val moduleSourceUrl =
pageScope.resolveModuleNameToSourceUrl(
member.moduleName,
Member.SourceLocation(startLine, endLine)
)
?: return
Member.SourceLocation(startLine, endLine),
) ?: return
a {
classes = setOf("member-source-link")
href = moduleSourceUrl.toString()

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-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.
@@ -46,7 +46,7 @@ class DocScopeTest {
"sourceCode".toUri(),
"https://example.com/mypackage/blob/1.2.3%{path}#L%{line}-L%{endLine}",
"issueTracker".toUri(),
overview = "overview docs"
overview = "overview docs",
)
private val module: ModuleSchema by lazy {
@@ -87,7 +87,7 @@ class DocScopeTest {
listOf(DocPackage(docPackageInfo, mutableListOf(module))),
mapOf(),
{ evaluator.evaluateSchema(uri(it)) },
"/output/dir".toPath()
"/output/dir".toPath(),
)
}
@@ -122,7 +122,7 @@ class DocScopeTest {
classScope,
typeAliasScope,
classPropertyScope,
classMethodScope
classMethodScope,
)
@JvmStatic

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-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.
@@ -45,10 +45,10 @@ class SearchTest {
base =
CliBaseOptions(
sourceModules = listOf(packageModule) + inputModules,
settings = URI("pkl:settings")
settings = URI("pkl:settings"),
),
outputDir = pkldocDir,
true
true,
)
)
.run()
@@ -145,8 +145,8 @@ class SearchTest {
"com.package1.modulePropertyComments",
"com.package1.modulePropertyModifiers",
"com.package1.modulePropertyTypeAnnotations",
"com.package1.modulePropertyTypeReferences"
)
"com.package1.modulePropertyTypeReferences",
),
)
}
@@ -159,8 +159,8 @@ class SearchTest {
"com.package1.classMethodTypeReferences",
"com.package1.classPropertyTypeReferences",
"com.package1.moduleMethodTypeReferences",
"com.package1.modulePropertyTypeReferences"
)
"com.package1.modulePropertyTypeReferences",
),
)
}
@@ -172,8 +172,8 @@ class SearchTest {
"prpertyWithExpandableComment",
"AnnotatedClssWithExpandableComment",
"ClassWithAnnotatedProperty",
"mthodWithExpandableComment"
)
"mthodWithExpandableComment",
),
)
}
@@ -195,8 +195,8 @@ class SearchTest {
"com.package1.modulePropertyTypeAnnotations",
"com.package1.modulePropertyCommentInheritance",
"com.package1.docExampleSubject1",
"com.package1.docExampleSubject2"
)
"com.package1.docExampleSubject2",
),
)
}
@@ -208,8 +208,8 @@ class SearchTest {
"com.package1.classInheritance",
"city", // disregard
"com.package1.moduleMethodCommentInheritance",
"com.package1.modulePropertyCommentInheritance"
)
"com.package1.modulePropertyCommentInheritance",
),
)
}