Skip to content

Commit 5192f5c

Browse files
committed
feat: configured dokka
fix: workflow
1 parent 65918ef commit 5192f5c

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

build.gradle.kts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
import kotlinx.html.*
2+
import kotlinx.html.stream.createHTML
3+
4+
buildscript {
5+
dependencies {
6+
classpath("org.jetbrains.dokka:versioning-plugin:1.8.10")
7+
}
8+
}
9+
110
plugins {
211
kotlin("multiplatform") apply false
312
kotlin("plugin.serialization") apply false
@@ -30,6 +39,10 @@ fun computeVersion(): Any {
3039
}
3140
}
3241

42+
dependencies {
43+
dokkaPlugin("org.jetbrains.dokka:versioning-plugin:1.8.10")
44+
}
45+
3346
subprojects {
3447
apply(plugin = "maven-publish")
3548
apply(plugin = "org.jetbrains.dokka")
@@ -96,3 +109,62 @@ subprojects {
96109
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask> {
97110
dependsOn(":ts-model-api:npm_run_build")
98111
}
112+
val docsDir = buildDir.resolve("dokka")
113+
114+
tasks.dokkaHtmlMultiModule {
115+
outputDirectory.set(docsDir.resolve("$version"))
116+
doLast {
117+
val index = file(docsDir.resolve("index.html"))
118+
index.writeText(createDocsIndexPage())
119+
}
120+
}
121+
122+
fun createDocsIndexPage(): String {
123+
return createHTML().html {
124+
head {
125+
style {
126+
+"""
127+
body {
128+
font-family: sans-serif;
129+
}
130+
131+
ul {
132+
list-style-type: none;
133+
}
134+
.wrapper {
135+
margin: auto;
136+
width: 50%;
137+
border: 1px solid;
138+
border-radius: 15px;
139+
padding: 20px;
140+
text-align: center;
141+
}
142+
""".trimIndent()
143+
}
144+
}
145+
body {
146+
header {
147+
h1 { +"Modelix Core API Reference" }
148+
}
149+
div("wrapper") {
150+
151+
ul {
152+
val versionDirs = docsDir.listFiles()
153+
?.filter { it.isDirectory }
154+
?.sortedByDescending { it.name }
155+
?: return@ul
156+
for (versionDir in versionDirs) {
157+
val versionIndex = versionDir.resolve("index.html")
158+
if (versionIndex.exists()) {
159+
li {
160+
a(href = versionIndex.relativeTo(docsDir).path) {
161+
+"modelix.core ${versionDir.name}"
162+
}
163+
}
164+
}
165+
}
166+
}
167+
}
168+
}
169+
}
170+
}

0 commit comments

Comments
 (0)