Skip to content

Commit 408b23a

Browse files
authored
Merge pull request #860 from modelix/ci/api-ref-only-latest
MODELIX-929 API Reference: Only publish latest version
2 parents 088c278 + 38fc42c commit 408b23a

File tree

3 files changed

+15
-158
lines changed

3 files changed

+15
-158
lines changed

.github/workflows/docs.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,9 @@ jobs:
2323
ref: gh-pages
2424
path: build/dokka
2525
- name: Generate Docs with Dokka
26-
run: ./gradlew dokkaHtmlMultiModule
27-
- name: Create symlink to latest version
28-
run: |
29-
cd build/dokka
30-
latestVersion=$(for n in *; do printf '%s\n' "$n"; done | sort -V | grep -E "^[0-9]+\.[0-9]+" | tail -n1)
31-
if [[ -n "${latestVersion}" ]]; then
32-
ln -sf ${latestVersion} latest
33-
fi
26+
run: ./gradlew :dokkaHtmlMultiModule
3427
- name: Publish to GitHub Pages
3528
uses: peaceiris/actions-gh-pages@v4
3629
with:
3730
github_token: ${{ secrets.GITHUB_TOKEN }}
3831
publish_dir: build/dokka
39-
keep_files: true

build.gradle.kts

Lines changed: 13 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,7 @@
1+
12
import com.github.gradle.node.NodeExtension
23
import com.github.gradle.node.NodePlugin
34
import io.gitlab.arturbosch.detekt.Detekt
4-
import kotlinx.html.FlowContent
5-
import kotlinx.html.a
6-
import kotlinx.html.body
7-
import kotlinx.html.div
8-
import kotlinx.html.h2
9-
import kotlinx.html.head
10-
import kotlinx.html.html
11-
import kotlinx.html.id
12-
import kotlinx.html.link
13-
import kotlinx.html.meta
14-
import kotlinx.html.p
15-
import kotlinx.html.span
16-
import kotlinx.html.stream.createHTML
17-
import kotlinx.html.style
18-
import kotlinx.html.title
19-
import kotlinx.html.unsafe
205
import org.jetbrains.dokka.base.DokkaBase
216
import org.jetbrains.dokka.base.DokkaBaseConfiguration
227
import org.jetbrains.dokka.gradle.DokkaTaskPartial
@@ -25,12 +10,10 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
2510
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
2611
import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper
2712
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin
28-
import org.semver.Version
2913

3014
buildscript {
3115
dependencies {
32-
classpath(libs.dokka.versioning)
33-
classpath(libs.semver)
16+
classpath(libs.dokka.base)
3417
}
3518
}
3619

@@ -68,8 +51,6 @@ fun computeVersion(): Any {
6851
}
6952

7053
dependencies {
71-
dokkaPlugin(libs.dokka.versioning)
72-
7354
// Generate a combined coverage report
7455
project.subprojects.forEach {
7556
kover(it)
@@ -89,7 +70,7 @@ subprojects {
8970

9071
tasks.withType<DokkaTaskPartial>().configureEach {
9172
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
92-
footerMessage = createFooterMessage()
73+
footerMessage = dokkaFooterMessage
9374
}
9475
}
9576

@@ -246,141 +227,25 @@ fun MavenPublication.setMetadata() {
246227
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask> {
247228
dependsOn(":ts-model-api:npm_run_build")
248229
}
249-
val docsDir = project.layout.buildDirectory.dir("dokka").get().asFile
250230

251231
tasks.dokkaHtmlMultiModule {
252-
outputDirectory.set(docsDir.resolve("$version"))
232+
val docsDir = project.layout.buildDirectory.dir("dokka").get().asFile
233+
outputDirectory.set(docsDir)
253234
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
254235
customAssets += file(projectDir.resolve("dokka/logo-dark.svg"))
255236
customAssets += file(projectDir.resolve("dokka/logo-icon.svg"))
256237
customStyleSheets += file(projectDir.resolve("dokka/logo-styles.css"))
257-
footerMessage = createFooterMessage()
258-
}
259-
doLast {
260-
val index = file(docsDir.resolve("index.html"))
261-
index.writeText(createDocsIndexPage())
238+
footerMessage = dokkaFooterMessage
262239
}
263240
}
264241

265-
fun createFooterMessage(): String {
266-
return createHTML().span {
267-
createFooter()
268-
}
269-
}
270-
271-
fun FlowContent.createFooter() {
272-
p {
273-
+"For more information visit "
274-
a("https://modelix.org") { +"modelix.org" }
275-
+", for further documentation visit "
276-
a("https://docs.modelix.org") { +"docs.modelix.org" }
277-
+"."
278-
}
279-
p {
280-
+"Copyright \u00A9 2021-present by the "
281-
a("https://modelix.org") { +"modelix open source project" }
282-
+" and the individual contributors. All Rights reserved."
283-
}
284-
p {
285-
+"Except where otherwise noted, "
286-
a("https://api.modelix.org") { +"api.modelix.org" }
287-
+", modelix, and the modelix framework, are licensed under the "
288-
a("https://www.apache.org/licenses/LICENSE-2.0.html") { +"Apache-2.0 license" }
289-
+"."
290-
}
291-
}
292-
293-
fun createDocsIndexPage(): String {
294-
return createHTML().html {
295-
head {
296-
meta(charset = "utf-8")
297-
link(href = "./$version/styles/style.css", rel = "Stylesheet")
298-
link(href = "./$version/styles/logo-styles.css", rel = "Stylesheet")
299-
link(href = "./$version/images/logo-icon.svg", rel = "icon")
300-
title("modelix.core API Reference")
301-
style {
302-
unsafe {
303-
+"""
304-
.library-name {
305-
padding-top: 6px;
306-
padding-bottom: 6px;
307-
}
308-
""".trimIndent()
309-
}
310-
}
311-
}
312-
body {
313-
div("navigation-wrapper") {
314-
id = "navigation-wrapper"
315-
div("library-name") {
316-
a { +"modelix.core API Reference" }
317-
}
318-
}
319-
div("wrapper") {
320-
id = "container"
321-
div {
322-
id = "leftColumn"
323-
}
324-
div {
325-
id = "main"
326-
div("main-content") {
327-
id = "content"
328-
div("breadcrumbs")
329-
div("cover") {
330-
h2 { +"Available versions:" }
331-
div("table") {
332-
val versionDirs = docsDir.listFiles()
333-
?.filter {
334-
it.isDirectory && !it.name.startsWith('.') && it.name != "latest"
335-
}
336-
?.sortedByDescending { Version.parse(it.name) }
337-
if (versionDirs != null) {
338-
div("table-row") {
339-
div("main-subrow") {
340-
div("w-100") {
341-
span("inline-flex") {
342-
a(href = "/latest") {
343-
+"modelix.core LATEST"
344-
}
345-
}
346-
}
347-
}
348-
}
349-
for (versionDir in versionDirs) {
350-
val versionIndex = versionDir.resolve("index.html")
351-
if (versionIndex.exists()) {
352-
div("table-row") {
353-
div("main-subrow") {
354-
div("w-100") {
355-
span("inline-flex") {
356-
a(href = versionIndex.relativeTo(docsDir).path) {
357-
+"modelix.core ${versionDir.name}"
358-
}
359-
}
360-
}
361-
}
362-
}
363-
}
364-
}
365-
}
366-
}
367-
}
368-
}
369-
div("footer") {
370-
span("go-to-top-icon") {
371-
a("#content") {
372-
id = "go-to-top-link"
373-
}
374-
}
375-
span {
376-
createFooter()
377-
}
378-
}
379-
}
380-
}
381-
}
382-
}
383-
}
242+
val dokkaFooterMessage = """
243+
<span>
244+
<p>For more information visit <a href="https://modelix.org">modelix.org</a>, for further documentation visit <a href="https://docs.modelix.org">docs.modelix.org</a>.</p>
245+
<p>Copyright ${"\u00A9"} 2021-present by the <a href="https://modelix.org">modelix open source project</a> and the individual contributors. All Rights reserved.</p>
246+
<p>Except where otherwise noted, <a href="https://api.modelix.org">api.modelix.org</a>, modelix, and the modelix framework, are licensed under the <a href="https://www.apache.org/licenses/LICENSE-2.0.html">Apache-2.0 license</a>.</p>
247+
</span>
248+
""".trimIndent()
384249

385250
catalog {
386251
versionCatalog {

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ apache-cxf-sse = { group = "org.apache.cxf", name = "cxf-rt-rs-sse", version.ref
113113
apache-cxf-client = { group = "org.apache.cxf", name = "cxf-rt-rs-client", version.ref = "apacheCxf" }
114114

115115
semver = { group = "org.semver", name = "api", version = "0.9.33"}
116-
dokka-versioning = { group = "org.jetbrains.dokka", name = "versioning-plugin", version.ref="dokka"}
116+
dokka-base = { group = "org.jetbrains.dokka", name = "dokka-base", version.ref="dokka"}
117117

118118
modelix-buildtools-gradle = { group = "org.modelix.mps", name = "build-tools-gradle", version.ref = "modelixBuildtools"}
119119
modelix-buildtools-lib = { group = "org.modelix.mps", name = "build-tools-lib", version.ref = "modelixBuildtools"}

0 commit comments

Comments
 (0)