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
+
1
10
plugins {
2
11
kotlin(" multiplatform" ) apply false
3
12
kotlin(" plugin.serialization" ) apply false
@@ -30,6 +39,10 @@ fun computeVersion(): Any {
30
39
}
31
40
}
32
41
42
+ dependencies {
43
+ dokkaPlugin(" org.jetbrains.dokka:versioning-plugin:1.8.10" )
44
+ }
45
+
33
46
subprojects {
34
47
apply (plugin = " maven-publish" )
35
48
apply (plugin = " org.jetbrains.dokka" )
@@ -96,3 +109,62 @@ subprojects {
96
109
tasks.withType< org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask > {
97
110
dependsOn(" :ts-model-api:npm_run_build" )
98
111
}
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