Skip to content

Commit 62ff66d

Browse files
committed
Add Dokka public API docs and Pages deploy workflow
1 parent a7226b2 commit 62ff66d

File tree

9 files changed

+135
-8
lines changed

9 files changed

+135
-8
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Deploy API Docs
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [main]
7+
paths:
8+
- "lib/**"
9+
- ".github/workflows/deploy-gh-pages.yml"
10+
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: pages
18+
cancel-in-progress: true
19+
20+
jobs:
21+
build:
22+
name: Build Dokka Docs
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Set up JDK 17
29+
uses: actions/setup-java@v4
30+
with:
31+
distribution: zulu
32+
java-version: "17"
33+
cache: gradle
34+
35+
- name: Generate Dokka docs
36+
run: ./gradlew -p lib dokkaPublicApi --no-daemon
37+
38+
- name: Prepare Pages artifact
39+
shell: bash
40+
run: |
41+
set -euo pipefail
42+
mkdir -p site
43+
cp -R lib/build/dokka/public-api/* site/
44+
45+
cat > site/index.html << 'EOF'
46+
<!doctype html>
47+
<html>
48+
<head>
49+
<meta charset="utf-8">
50+
<meta name="viewport" content="width=device-width,initial-scale=1">
51+
<title>Compose GIF Recorder API</title>
52+
</head>
53+
<body>
54+
<h1>Compose GIF Recorder API</h1>
55+
<ul>
56+
<li><a href="./recorder-annotations/">Annotations</a></li>
57+
<li><a href="./recorder-core/">Core</a></li>
58+
<li><a href="./recorder-ksp/">KSP</a></li>
59+
<li><a href="./recorder-android/">Android</a></li>
60+
<li><a href="./recorder-gradle-plugin/">Gradle Plugin</a></li>
61+
</ul>
62+
</body>
63+
</html>
64+
EOF
65+
66+
- name: Configure Pages
67+
uses: actions/configure-pages@v5
68+
69+
- name: Upload Pages artifact
70+
uses: actions/upload-pages-artifact@v3
71+
with:
72+
path: site
73+
74+
deploy:
75+
name: Deploy to GitHub Pages
76+
needs: build
77+
runs-on: ubuntu-latest
78+
environment:
79+
name: github-pages
80+
url: ${{ steps.deployment.outputs.page_url }}
81+
steps:
82+
- name: Deploy
83+
id: deployment
84+
uses: actions/deploy-pages@v4

lib/build.gradle.kts

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
base
3+
alias(libs.plugins.dokka) apply false
34
alias(libs.plugins.kotlin.jvm) apply false
45
alias(libs.plugins.kotlin.compose) apply false
56
alias(libs.plugins.android.library) apply false
@@ -8,6 +9,14 @@ plugins {
89
alias(libs.plugins.ktlint) apply false
910
}
1011

12+
val publishableModules = listOf(
13+
":recorder-annotations",
14+
":recorder-core",
15+
":recorder-ksp",
16+
":recorder-android",
17+
":recorder-gradle-plugin"
18+
)
19+
1120
subprojects {
1221
apply(plugin = "org.jlleitschuh.gradle.ktlint")
1322

@@ -27,14 +36,6 @@ allprojects {
2736
}
2837
}
2938

30-
val publishableModules = listOf(
31-
":recorder-annotations",
32-
":recorder-core",
33-
":recorder-ksp",
34-
":recorder-android",
35-
":recorder-gradle-plugin"
36-
)
37-
3839
val testableJvmModules = listOf(
3940
":recorder-annotations",
4041
":recorder-core",
@@ -60,3 +61,24 @@ tasks.register("publishRecorderModulesToMavenLocal") {
6061
description = "Publishes all recorder modules to Maven Local"
6162
dependsOn(publishableModules.map { "$it:publishToMavenLocal" })
6263
}
64+
65+
tasks.register("dokkaPublicApi") {
66+
group = "documentation"
67+
description = "Generates Dokka HTML docs for published recorder modules"
68+
dependsOn(publishableModules.map { "$it:dokkaGeneratePublicationHtml" })
69+
outputs.dir(layout.buildDirectory.dir("dokka/public-api"))
70+
doLast {
71+
val outputRoot = layout.buildDirectory.dir("dokka/public-api").get().asFile
72+
outputRoot.mkdirs()
73+
publishableModules.forEach { modulePath ->
74+
val moduleName = modulePath.removePrefix(":")
75+
val moduleDocsDir = project(modulePath).layout.buildDirectory.dir("dokka/html").get().asFile
76+
if (moduleDocsDir.exists()) {
77+
copy {
78+
from(moduleDocsDir)
79+
into(outputRoot.resolve(moduleName))
80+
}
81+
}
82+
}
83+
}
84+
}

lib/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8
22
android.useAndroidX=true
33
kotlin.code.style=official
4+
org.jetbrains.dokka.experimental.gradle.pluginMode=V2EnabledWithHelpers
45

56
#Maven Central Publishing (gradle-maven-publish-plugin 0.34.0+)
67
mavenCentralPublishing=true

lib/gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ androidx-test-ext = "1.3.0"
1010
junit4 = "4.13.2"
1111
kotlinpoet = "2.2.0"
1212
ktlint = "14.0.1"
13+
dokka = "2.1.0"
1314

1415
[libraries]
1516
compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose-ui" }
@@ -37,3 +38,4 @@ gradle-plugin-publish = { id = "java-gradle-plugin" }
3738
maven-publish = { id = "maven-publish" }
3839
vanniktech-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech-publish" }
3940
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
41+
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }

lib/recorder-android/build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
alias(libs.plugins.android.library)
33
alias(libs.plugins.kotlin.compose)
4+
alias(libs.plugins.dokka)
45
`maven-publish`
56
signing
67
alias(libs.plugins.vanniktech.publish)
@@ -52,6 +53,19 @@ dependencies {
5253
debugImplementation(libs.compose.ui.test.manifest)
5354
}
5455

56+
dokka {
57+
dokkaSourceSets.register("main") {
58+
sourceRoots.from(file("src/main/kotlin"))
59+
sourceRoots.from(file("src/main/java"))
60+
classpath.from(configurations.getByName("releaseCompileClasspath"))
61+
analysisPlatform.set(org.jetbrains.dokka.gradle.engine.parameters.KotlinPlatform.AndroidJVM)
62+
documentedVisibilities.set(
63+
setOf(org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier.Public),
64+
)
65+
jdkVersion.set(17)
66+
}
67+
}
68+
5569
mavenPublishing {
5670
configure(
5771
com.vanniktech.maven.publish.AndroidSingleVariantLibrary(

lib/recorder-annotations/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
alias(libs.plugins.kotlin.jvm)
3+
alias(libs.plugins.dokka)
34
`maven-publish`
45
signing
56
alias(libs.plugins.vanniktech.publish)

lib/recorder-core/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
alias(libs.plugins.kotlin.jvm)
33
alias(libs.plugins.kotlin.compose)
4+
alias(libs.plugins.dokka)
45
`maven-publish`
56
signing
67
alias(libs.plugins.vanniktech.publish)

lib/recorder-gradle-plugin/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
alias(libs.plugins.kotlin.jvm)
3+
alias(libs.plugins.dokka)
34
id("java-gradle-plugin")
45
`maven-publish`
56
signing

lib/recorder-ksp/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
alias(libs.plugins.kotlin.jvm)
3+
alias(libs.plugins.dokka)
34
`maven-publish`
45
signing
56
alias(libs.plugins.vanniktech.publish)

0 commit comments

Comments
 (0)