1
+ import kotlinx.html.*
2
+ import kotlinx.html.stream.createHTML
3
+ import org.jetbrains.dokka.base.DokkaBase
4
+ import org.jetbrains.dokka.base.DokkaBaseConfiguration
5
+
6
+ buildscript {
7
+ dependencies {
8
+ classpath(" org.jetbrains.dokka:versioning-plugin:1.8.10" )
9
+ }
10
+ }
11
+
1
12
plugins {
2
13
kotlin(" multiplatform" ) apply false
3
14
kotlin(" plugin.serialization" ) apply false
@@ -6,6 +17,13 @@ plugins {
6
17
id(" org.jlleitschuh.gradle.ktlint" ) version " 10.3.0" apply false
7
18
id(" com.diffplug.spotless" ) version " 5.0.0" apply false
8
19
id(" com.dorongold.task-tree" ) version " 2.1.0"
20
+ id(" org.jetbrains.dokka" ) version " 1.8.10"
21
+ }
22
+
23
+ repositories {
24
+ mavenLocal()
25
+ maven { url = uri(" https://artifacts.itemis.cloud/repository/maven-mps/" ) }
26
+ mavenCentral()
9
27
}
10
28
11
29
group = " org.modelix"
@@ -23,8 +41,13 @@ fun computeVersion(): Any {
23
41
}
24
42
}
25
43
44
+ dependencies {
45
+ dokkaPlugin(" org.jetbrains.dokka:versioning-plugin:1.8.10" )
46
+ }
47
+
26
48
subprojects {
27
49
apply (plugin = " maven-publish" )
50
+ apply (plugin = " org.jetbrains.dokka" )
28
51
version = rootProject.version
29
52
group = rootProject.group
30
53
@@ -88,3 +111,122 @@ subprojects {
88
111
tasks.withType< org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask > {
89
112
dependsOn(" :ts-model-api:npm_run_build" )
90
113
}
114
+ val docsDir = buildDir.resolve(" dokka" )
115
+
116
+ tasks.dokkaHtmlMultiModule {
117
+ outputDirectory.set(docsDir.resolve(" $version " ))
118
+ pluginConfiguration<DokkaBase , DokkaBaseConfiguration > {
119
+ customAssets + = file(projectDir.resolve(" dokka/logo-dark.svg" ))
120
+ customStyleSheets + = file(projectDir.resolve(" dokka/logo-styles.css" ))
121
+ footerMessage = createFooterMessage()
122
+ }
123
+ doLast {
124
+ val index = file(docsDir.resolve(" index.html" ))
125
+ index.writeText(createDocsIndexPage(), Charsets .ISO_8859_1 )
126
+ }
127
+ }
128
+
129
+ fun createFooterMessage (): String {
130
+ return createHTML().span {
131
+ createFooter()
132
+ }
133
+ }
134
+
135
+ fun FlowContent.createFooter () {
136
+ p {
137
+ + " For more information visit "
138
+ a(" https://modelix.org" ) { + " modelix.org" }
139
+ + " , for further documentation visit "
140
+ a(" https://docs.modelix.org" ) { + " docs.modelix.org" }
141
+ + " ."
142
+ }
143
+ p {
144
+ + " Copyright \u00A9 2021-present by the "
145
+ a(" https://modelix.org" ) { + " modelix open source project" }
146
+ + " and the individual contributors. All Rights reserved."
147
+ }
148
+ p {
149
+ + " Except where otherwise noted, "
150
+ a(" https://api.modelix.org" ) {+ " api.modelix.org" }
151
+ + " , modelix, and the modelix framework, are licensed under the "
152
+ a(" https://www.apache.org/licenses/LICENSE-2.0.html" ) { + " Apache-2.0 license" }
153
+ + " ."
154
+ }
155
+ }
156
+
157
+ fun createDocsIndexPage (): String {
158
+ return createHTML().html {
159
+ head {
160
+ link(href = " ./$version /styles/style.css" , rel = " Stylesheet" )
161
+ link(href = " ./$version /styles/logo-styles.css" , rel = " Stylesheet" )
162
+ title(" modelix.core API Reference" )
163
+ style {
164
+ unsafe {
165
+ + """
166
+ .library-name {
167
+ padding-top: 6px;
168
+ padding-bottom: 6px;
169
+ }
170
+ """ .trimIndent()
171
+ }
172
+ }
173
+ }
174
+ body {
175
+ div(" navigation-wrapper" ) {
176
+ id = " navigation-wrapper"
177
+ div(" library-name" ) {
178
+ a { + " modelix.core API Reference" }
179
+ }
180
+ }
181
+ div(" wrapper" ) {
182
+ id = " container"
183
+ div {
184
+ id = " leftColumn"
185
+ }
186
+ div {
187
+ id = " main"
188
+ div(" main-content" ) {
189
+ id = " content"
190
+ div(" breadcrumbs" )
191
+ div(" cover" ) {
192
+ h2 { + " Available versions:" }
193
+ div(" table" ) {
194
+ val versionDirs = docsDir.listFiles()
195
+ ?.filter { it.isDirectory }
196
+ ?.sortedByDescending { it.name }
197
+ if (versionDirs != null ) {
198
+ for (versionDir in versionDirs) {
199
+ val versionIndex = versionDir.resolve(" index.html" )
200
+ if (versionIndex.exists()) {
201
+ div(" table-row" ) {
202
+ div(" main-subrow" ) {
203
+ div(" w-100" ) {
204
+ span(" inline-flex" ) {
205
+ a( href = versionIndex.relativeTo(docsDir).path) {
206
+ + " modelix.core ${versionDir.name} "
207
+ }
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
215
+ }
216
+ }
217
+ }
218
+ div(" footer" ) {
219
+ span(" go-to-top-icon" ) {
220
+ a(" #content" ) {
221
+ id = " go-to-top-link"
222
+ }
223
+ }
224
+ span {
225
+ createFooter()
226
+ }
227
+ }
228
+ }
229
+ }
230
+ }
231
+ }
232
+ }
0 commit comments