Skip to content

Commit

Permalink
Generate documentation with Dokka.
Browse files Browse the repository at this point in the history
  • Loading branch information
christiandeange committed Mar 19, 2024
1 parent 1a4133d commit ad06ae0
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 1 deletion.
36 changes: 35 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,38 @@ jobs :
ORG_GRADLE_PROJECT_mavenCentralPassword="$SONATYPE_NEXUS_PASSWORD" \
ORG_GRADLE_PROJECT_signingInMemoryKey="$ARTIFACT_SIGNING_PRIVATE_KEY" \
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword="$ARTIFACT_SIGNING_PRIVATE_KEY_PASSWORD" \
./gradlew clean publish :generator:publish --no-daemon --stacktrace
./gradlew clean publish :generator:publish dokkaHtmlCollector --no-daemon --stacktrace
deploy-docs :
runs-on: ubuntu-latest
if: github.repository == 'christiandeange/ozone'
needs:
- publish-release

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

permissions:
contents: read
pages: write
id-token: write

steps:
- uses : actions/checkout@v3
- uses : gradle/wrapper-validation-action@v1
- uses : actions/setup-java@v3
with:
distribution : 'temurin'
java-version : '17'
check-latest : true
- uses : actions/configure-pages@v4

- name : Upload artifact
uses : actions/upload-pages-artifact@v3
with:
path : './docs'

- name : Deploy to GitHub Pages
id : deployment
uses : actions/deploy-pages@v4
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@

### Mac OS ###
.DS_Store

### Project ###
/docs
1 change: 1 addition & 0 deletions api-gen-runtime/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
id("ozone-dokka")
id("ozone-multiplatform")
id("ozone-publish")
kotlin("plugin.serialization")
Expand Down
1 change: 1 addition & 0 deletions bluesky/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import com.android.build.gradle.internal.tasks.factory.dependsOn
import sh.christian.ozone.api.generator.ApiReturnType

plugins {
id("ozone-dokka")
id("ozone-multiplatform")
id("ozone-publish")
id("sh.christian.ozone.generator")
Expand Down
6 changes: 6 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies {
implementation(libs.maven.publish)

compileOnly(libs.agp)
compileOnly(libs.dokka)
compileOnly(kotlin("gradle-plugin"))
}

Expand All @@ -36,6 +37,11 @@ gradlePlugin {
implementationClass = "sh.christian.plugin.ComposePlugin"
}

create("ozone-dokka") {
id = "ozone-dokka"
implementationClass = "sh.christian.plugin.DokkaPlugin"
}

create("ozone-multiplatform") {
id = "ozone-multiplatform"
implementationClass = "sh.christian.plugin.MultiplatformPlugin"
Expand Down
36 changes: 36 additions & 0 deletions build-logic/src/main/kotlin/sh/christian/plugin/DokkaPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package sh.christian.plugin

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.withType
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask

@Suppress("unused")
class DokkaPlugin : Plugin<Project> {
override fun apply(target: Project) = target.applyPlugin()
}

private fun Project.applyPlugin() {
plugins.apply("org.jetbrains.dokka")

val libs = project.rootProject.extensions.getByType<VersionCatalogsExtension>().named("libs")

tasks.withType<AbstractDokkaLeafTask>().configureEach {
dokkaSourceSets.configureEach {
reportUndocumented.set(true)
suppressGeneratedFiles.set(false)

externalDocumentationLink(
url = "https://kotlinlang.org/api/kotlinx.serialization/",
)

val ktorVersion = libs.findVersion("ktor").get().displayName
externalDocumentationLink(
url = "https://api.ktor.io/older/$ktorVersion/ktor-client",
packageListUrl = "https://api.ktor.io/older/$ktorVersion/package-list",
)
}
}
}
13 changes: 13 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import org.jetbrains.dokka.gradle.DokkaCollectorTask
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
val agp = libs.versions.agp
val compose = libs.versions.compose
val dokka = libs.versions.dokka
val kotlin = libs.versions.kotlin
val ksp = libs.versions.ksp
val mavenPublish = libs.versions.maven.publish
Expand All @@ -16,6 +20,7 @@ plugins {
id("com.google.devtools.ksp") version ksp apply false
id("com.vanniktech.maven.publish") version mavenPublish apply false
id("org.jetbrains.compose") version compose apply false
id("org.jetbrains.dokka") version dokka apply true
id("org.jetbrains.kotlinx.binary-compatibility-validator") version kotlinxAbi apply false
}

Expand All @@ -33,3 +38,11 @@ allprojects {
}
}
}

tasks.withType<DokkaMultiModuleTask>().configureEach {
outputDirectory.set(file("$rootDir/docs"))
}

tasks.withType<DokkaCollectorTask>().configureEach {
outputDirectory.set(file("$rootDir/docs"))
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
agp = "8.1.4"
buildconfig = "4.1.2"
compose = "1.5.11"
dokka = "1.9.20"
kotlin = "1.9.21"
kotlinx-abi-plugin = "0.13.2"
kotlinx-datetime = "0.5.0"
Expand Down Expand Up @@ -57,6 +58,7 @@ ktor-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
ktor-serialization-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
ktor-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" }

dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
maven-publish = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "maven-publish" }

workflow-core = { module = "com.squareup.workflow1:workflow-core", version.ref = "workflow" }
Expand Down

0 comments on commit ad06ae0

Please sign in to comment.