Files
pkl/pkl-doc/pkl-doc.gradle.kts
Daniel Chao 5d90cf8f4e Introduce pkl-doc model version 2 (#1169)
Currently, in order to update a pkl-doc documentation site,
almost the entire existing site is read in order to update metadata
like known versions, known subtypes, and more.

For example, adding a new version of a package requires that the
existing runtime data of all existing versions be updated.
Eventually, this causes the required storage size to balloon
exponentially to the number of versions.

This addresses these limitations by:

1. Updating the runtime data structure to move "known versions" metadata
   to the package level (the same JSON file is used for all versions).
2. Eliminating known subtype and known usage information at a
   cross-package level.
3. Generating the search index by consuming the previously generated
   search index.
4. Generating the main page by consuming the search index.

Because this changes how runtime data is stored, an existing docsite
needs to be migrated.

This also introduces a new migration command, `pkl-doc --migrate`,
which transforms an older version of the website into a newer version.
2025-09-29 16:10:44 -07:00

98 lines
3.0 KiB
Kotlin

/*
* 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.
* 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.
*/
plugins {
pklAllProjects
pklKotlinLibrary
pklJavaExecutable
pklNativeExecutable
pklHtmlValidator
alias(libs.plugins.kotlinxSerialization)
}
executable {
mainClass = "org.pkl.doc.Main"
name = "pkldoc"
javaName = "jpkldoc"
documentationName = "Pkldoc CLI"
publicationName = "pkldoc"
javaPublicationName = "jpkldoc"
website = "https://pkl-lang.org/main/current/pkl-doc/index.html"
}
dependencies {
implementation(projects.pklCore)
implementation(projects.pklCommonsCli)
implementation(projects.pklCommons)
implementation(projects.pklParser)
implementation(libs.commonMark)
implementation(libs.commonMarkTables)
implementation(libs.kotlinxHtml)
implementation(libs.kotlinxSerializationJson) {
// use our own Kotlin version
// (exclude is supported both for Maven and Gradle metadata, whereas dependency constraints
// aren't)
exclude(group = "org.jetbrains.kotlin")
}
implementation(libs.kotlinxCoroutinesCore) { exclude(group = "org.jetbrains.kotlin") }
testImplementation(projects.pklCommonsTest)
testImplementation(libs.jimfs)
// Graal.JS
testImplementation(libs.graalSdk)
testImplementation(libs.graalJs)
}
publishing {
publications {
named<MavenPublication>("library") {
pom {
url.set("https://github.com/apple/pkl/tree/main/pkl-doc")
description.set("Documentation generator for Pkl modules.")
}
}
}
}
val testNativeExecutable by
tasks.registering(Test::class) {
inputs.dir("src/test/files/DocGeneratorTest/input")
outputs.dir("src/test/files/DocGeneratorTest/output")
systemProperty("org.pkl.doc.NativeExecutableTest", "true")
include(listOf("**/NativeExecutableTest.class"))
}
val testJavaExecutable by
tasks.registering(Test::class) {
dependsOn(tasks.javaExecutable)
inputs.dir("src/test/files/DocGeneratorTest/input")
outputs.dir("src/test/files/DocGeneratorTest/output")
systemProperty("org.pkl.doc.JavaExecutableTest", "true")
include(listOf("**/JavaExecutableTest.class"))
}
tasks.check { dependsOn(testJavaExecutable) }
tasks.testNative { dependsOn(testNativeExecutable) }
tasks.withType<NativeImageBuild> { extraNativeImageArgs.add("-H:IncludeResources=org/pkl/doc/.*") }
tasks.jar { manifest { attributes += mapOf("Main-Class" to "org.pkl.doc.Main") } }
htmlValidator { sources = files("src/test/files/DocGeneratorTest/output") }
tasks.validateHtml { mustRunAfter(testJavaExecutable) }