Skip to content

WIP API Reference #163

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import com.sun.net.httpserver.HttpExchange
import com.sun.net.httpserver.HttpServer
import java.net.InetSocketAddress
import java.net.URLDecoder
import java.nio.file.Files

plugins {
alias(libs.plugins.jetbrainsCompose) apply false
alias(libs.plugins.compose.compiler) apply false
Expand All @@ -16,6 +22,7 @@ plugins {
alias(libs.plugins.kotlinter) apply false
alias(libs.plugins.keeper) apply false
alias(libs.plugins.kotlin.atomicfu) apply false
id("org.jetbrains.dokka") version "2.0.0"
}

allprojects {
Expand Down Expand Up @@ -57,3 +64,41 @@ subprojects {
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}

tasks.register("serveDokka") {
dependsOn("dokkaHtml")
doLast {
val server = HttpServer.create(InetSocketAddress(0), 0)
val root = file("core/build/dokka/html")

val handler =
com.sun.net.httpserver.HttpHandler { exchange: HttpExchange ->
val rawPath = exchange.requestURI.path
val cleanPath = URLDecoder.decode(rawPath.removePrefix("/"), "UTF-8")
val requestedFile = File(root, cleanPath)

val file =
when {
requestedFile.exists() && !requestedFile.isDirectory -> requestedFile
else -> File(root, "index.html") // fallback
}

val contentType =
Files.probeContentType(file.toPath()) ?: "application/octet-stream"
val bytes = file.readBytes()
exchange.responseHeaders.add("Content-Type", contentType)
exchange.sendResponseHeaders(200, bytes.size.toLong())
exchange.responseBody.use { it.write(bytes) }
}

server.createContext("/", handler)
server.executor = null
server.start()

println("📘 Serving Dokka docs at http://localhost:${server.address.port}/")
println("Press Ctrl+C to stop.")

// Keep the task alive
Thread.currentThread().join()
}
}
5 changes: 3 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ plugins {
id("com.powersync.plugins.sonatype")
alias(libs.plugins.mokkery)
alias(libs.plugins.kotlin.atomicfu)
id("org.jetbrains.dokka")
}

val binariesFolder = project.layout.buildDirectory.dir("binaries/desktop")
Expand Down Expand Up @@ -315,8 +316,8 @@ android {
}

androidComponents.onVariants {
tasks.named("preBuild") {
dependsOn(moveJDBCJNIFiles)
tasks.named("preBuild") {
dependsOn(moveJDBCJNIFiles)
}
}

Expand Down
Loading