Skip to content

Commit e4bca3c

Browse files
authored
Dokka (#357)
1 parent 7cce139 commit e4bca3c

File tree

25 files changed

+474
-4
lines changed

25 files changed

+474
-4
lines changed

.github/workflows/docs.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,40 @@ jobs:
7272
needs: [ build, test ]
7373
runs-on: ubuntu-latest
7474
steps:
75+
- name: Checkout repository
76+
uses: actions/checkout@v4
77+
with:
78+
fetch-depth: 0
79+
80+
- name: Setup Gradle
81+
uses: gradle/actions/setup-gradle@v3
82+
83+
- name: Run Dokka
84+
run: ./gradlew dokkaGenerate
85+
86+
- name: Move API docs to the publication directory
87+
run:
88+
mkdir __docs_publication_dir
89+
cp -r docs/pages/api __docs_publication_dir/api
90+
7591
- name: Download artifacts
7692
uses: actions/download-artifact@v4
7793
with:
7894
name: kotlinx-rpc
7995

8096
- name: Unzip artifact
81-
run: unzip -O UTF-8 -qq '${{ env.ARTIFACT }}' -d dir
97+
run: unzip -O UTF-8 -qq '${{ env.ARTIFACT }}' -d __docs_publication_dir
98+
99+
- name: Update sitemap.xml
100+
run: chmod +x updateSitemap.sh && ./updateSitemap.sh __docs_publication_dir/sitemap.xml __docs_publication_dir/api
82101

83102
- name: Setup Pages
84103
uses: actions/configure-pages@v5
85104

86105
- name: Package and upload Pages artifact
87106
uses: actions/upload-pages-artifact@v3
88107
with:
89-
path: dir
108+
path: __docs_publication_dir
90109

91110
- name: Deploy to GitHub Pages
92111
id: deployment

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ lib-kotlin
1919
!.idea/icon.svg
2020
!.idea/detekt.xml
2121
!.idea/kotlinTestDataPluginTestDataPaths.xml
22+
!.idea/kotlinx-rpc.iml
2223

2324
samples/**/.idea/*
2425

.idea/kotlinx-rpc.iml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle.kts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,80 @@
33
*/
44

55
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
6+
import util.asDokkaVersion
67
import util.configureApiValidation
78
import util.configureNpm
89
import util.configureProjectReport
910
import util.registerDumpPlatformTableTask
1011
import util.libs
1112
import util.registerVerifyPlatformTableTask
13+
import java.time.Year
1214

1315
plugins {
1416
alias(libs.plugins.serialization) apply false
1517
alias(libs.plugins.kotlinx.rpc) apply false
1618
alias(libs.plugins.conventions.kover)
1719
alias(libs.plugins.conventions.gradle.doctor)
20+
alias(libs.plugins.dokka)
1821
alias(libs.plugins.atomicfu)
1922
id("build-util")
2023
}
2124

25+
dokka {
26+
val libDokkaVersion = libs.versions.kotlinx.rpc.get().asDokkaVersion()
27+
28+
moduleVersion.set(libDokkaVersion)
29+
30+
val pagesDirectory = layout.projectDirectory
31+
.dir("docs")
32+
.dir("pages")
33+
34+
val dokkaVersionsDirectory = pagesDirectory
35+
.dir("api")
36+
.asFile
37+
38+
val templatesDirectory = pagesDirectory
39+
.dir("templates")
40+
41+
pluginsConfiguration {
42+
html {
43+
customAssets.from(
44+
"docs/pages/assets/logo-icon.svg",
45+
"docs/pages/assets/homepage.svg", // Doesn't work due to https://github.com/Kotlin/dokka/issues/4007
46+
)
47+
48+
footerMessage = "© ${Year.now()} JetBrains s.r.o and contributors. Apache License 2.0"
49+
homepageLink = "https://kotlin.github.io/kotlinx-rpc/get-started.html"
50+
51+
// replace with homepage.svg once the mentioned issue is resolved
52+
templatesDir.set(templatesDirectory)
53+
}
54+
55+
// enable versioning for stable
56+
// versioning {
57+
// version = libDokkaVersion
58+
// olderVersionsDir = dokkaVersionsDirectory
59+
// }
60+
}
61+
62+
dokkaPublications.html {
63+
outputDirectory = dokkaVersionsDirectory
64+
}
65+
66+
tasks.clean {
67+
delete(dokkaVersionsDirectory)
68+
}
69+
70+
dokkaGeneratorIsolation = ProcessIsolation {
71+
// Configures heap size, use if start to fail with OOM on CI
72+
// maxHeapSize = "4g"
73+
}
74+
}
75+
76+
dependencies {
77+
dokkaPlugin(libs.dokka.rpc.plugin)
78+
}
79+
2280
configureProjectReport()
2381
configureNpm()
2482
configureApiValidation()

docs/pages/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
api/**

docs/pages/assets/homepage.svg

Lines changed: 20 additions & 0 deletions
Loading

docs/pages/assets/logo-icon.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/pages/kotlinx-rpc/cfg/buildprofiles.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<versions-switcher>%docs-raw-path%/help-versions.json</versions-switcher>
2424

25-
<generate-sitemap-url-prefix>https://www.jetbrains.com/help/</generate-sitemap-url-prefix>
25+
<generate-sitemap-url-prefix>%host%</generate-sitemap-url-prefix>
2626

2727
<algolia-id>MMA5Z3JT91</algolia-id>
2828
<algolia-index>prod_kotlin_rpc</algolia-index>
@@ -37,8 +37,9 @@
3737

3838
<sitemap priority="0.35" change-frequency="monthly"/>
3939
<footer>
40-
<copyright>2000-2024 JetBrains s.r.o.</copyright>
40+
<copyright>2000-2025 JetBrains s.r.o.</copyright>
4141
<link href="https://github.com/Kotlin/kotlinx-rpc/blob/main/CONTRIBUTING.md">Contribute to kotlinx.rpc</link>
4242
<link href="https://kotlinlang.slack.com/archives/C072YJ3Q91V">Slack Community</link>
43+
<link href="%host%/api/">API Reference</link>
4344
</footer>
4445
</buildprofiles>

docs/pages/kotlinx-rpc/rpc.tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@
4949
<toc-element topic="0-2-4.topic"/>
5050
<toc-element topic="0-2-1.topic"/>
5151
</toc-element>
52+
<toc-element toc-title="API Reference" href="%host%/api/"/>
5253
</instance-profile>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<#import "source_set_selector.ftl" as source_set_selector>
2+
<#macro display>
3+
<header class="navigation theme-dark" id="navigation-wrapper" role="banner">
4+
<@template_cmd name="pathToRoot">
5+
<a class="library-name--link" href="${pathToRoot}index.html" tabindex="1">
6+
<@template_cmd name="projectName">
7+
${projectName}
8+
</@template_cmd>
9+
</a>
10+
</@template_cmd>
11+
<button class="navigation-controls--btn navigation-controls--btn_toc ui-kit_mobile-only" id="toc-toggle"
12+
type="button">Toggle table of contents
13+
</button>
14+
<div class="navigation-controls--break ui-kit_mobile-only"></div>
15+
<div class="library-version" id="library-version">
16+
<#-- This can be handled by the versioning plugin -->
17+
<@version/>
18+
</div>
19+
<div class="navigation-controls">
20+
<@source_set_selector.display/>
21+
<#if homepageLink?has_content>
22+
<a class="navigation-controls--btn" id="homepage-link" href="${homepageLink}"
23+
style="width: fit-content; padding-left: 10px;">
24+
<p style="color: var(--color-text-dt); font: var(--font-text-m); ">Back to docs</p>
25+
<div class="navigation-controls--btn_homepage"
26+
style="
27+
height: 40px;
28+
width: 40px;
29+
background-color: transparent;
30+
background-repeat: no-repeat;
31+
background-position: 50% 50%;
32+
background-size: 24px 24px;
33+
">
34+
</div>
35+
</a>
36+
</#if>
37+
<button class="navigation-controls--btn navigation-controls--btn_theme" id="theme-toggle-button"
38+
type="button">Switch theme
39+
</button>
40+
<div class="navigation-controls--btn navigation-controls--btn_search" id="searchBar" role="button">Search in
41+
API
42+
</div>
43+
</div>
44+
</header>
45+
</#macro>

0 commit comments

Comments
 (0)