Skip to content

Commit ce5909c

Browse files
committed
feat(docs-website): add docusaurus and update docs workflow
1 parent ff364db commit ce5909c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+19741
-185
lines changed

.github/workflows/docs-generate.yaml

Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ on:
2828
publish:
2929
description: 'Publish documentation to docs repository'
3030
required: false
31-
default: 'true'
31+
default: true
3232
type: boolean
3333

3434
env:
@@ -74,19 +74,30 @@ jobs:
7474
# Organize documentation
7575
- name: Organize Documentation Output
7676
run: |
77-
mkdir -p docs-output
78-
77+
mkdir -p docs-website/static/api
7978
# Copy Dokka documentation
8079
if [ -d "build/dokka" ]; then
8180
echo "Copying Dokka documentation..."
82-
cp -r build/dokka/* docs-output/
81+
cp -r build/dokka/* docs-website/static/api/
8382
fi
84-
8583
# Create .nojekyll for GitHub Pages
86-
touch docs-output/.nojekyll
87-
84+
touch docs-website/static/api/.nojekyll
8885
echo "Documentation organized successfully!"
89-
ls -la docs-output/
86+
ls -la docs-website/static/api/
87+
88+
# Commit and push Dokka docs to docs-website on dev branch
89+
- name: Commit and Push Dokka Docs to docs-website
90+
if: github.ref == 'refs/heads/dev' && github.event_name == 'push'
91+
run: |
92+
git config --global user.name "github-actions[bot]"
93+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
94+
git add docs-website/static/api
95+
if git diff --staged --quiet; then
96+
echo "No documentation changes to commit."
97+
else
98+
git commit -m "docs: update Dokka API docs [skip ci]"
99+
git push origin dev
100+
fi
90101
91102
# Upload documentation as artifact
92103
- name: Upload Documentation Artifact
@@ -96,63 +107,22 @@ jobs:
96107
path: docs-output/
97108
retention-days: 30
98109

99-
# Publish to GitHub Pages or docs repository
100-
- name: Publish to Documentation Repository
101-
if: |
102-
github.event_name == 'push' &&
103-
github.ref == 'refs/heads/main' &&
104-
(github.event.inputs.publish != 'false')
105-
env:
106-
DOCS_DEPLOY_TOKEN: ${{ secrets.DOCS_DEPLOY_TOKEN }}
107-
run: |
108-
if [ -z "$DOCS_DEPLOY_TOKEN" ]; then
109-
echo "⚠️ DOCS_DEPLOY_TOKEN not set. Skipping documentation publishing."
110-
echo "To enable publishing, add DOCS_DEPLOY_TOKEN to repository secrets."
111-
exit 0
112-
fi
113-
114-
# Configure git
115-
git config --global user.name "github-actions[bot]"
116-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
117-
118-
# Clone docs repository
119-
git clone "https://x-access-token:${DOCS_DEPLOY_TOKEN}@github.com/${DOCS_REPO}.git" docs-repo
120-
cd docs-repo
121-
git checkout "${DOCS_BRANCH}" || git checkout -b "${DOCS_BRANCH}"
122-
123-
# Clear existing docs and copy new ones
124-
rm -rf *
125-
cp -r ../docs-output/* .
126-
127-
# Create .nojekyll for GitHub Pages
128-
touch .nojekyll
129-
130-
# Commit and push
131-
git add .
132-
if git diff --staged --quiet; then
133-
echo "No documentation changes to publish"
134-
else
135-
git commit -m "📚 Update documentation from ${GITHUB_REPOSITORY}@${GITHUB_SHA::7}"
136-
git push origin "${DOCS_BRANCH}"
137-
echo "✅ Documentation published successfully!"
138-
fi
139-
140110
# Summary
141111
- name: Generate Summary
142112
if: always()
143113
run: |
144-
echo "### 📚 Documentation Generation Summary" >> $GITHUB_STEP_SUMMARY
114+
echo "### Documentation Generation Summary" >> $GITHUB_STEP_SUMMARY
145115
echo "" >> $GITHUB_STEP_SUMMARY
146116
echo "| Component | Status |" >> $GITHUB_STEP_SUMMARY
147117
echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY
148-
echo "| Dokka (Kotlin API Docs) | Generated |" >> $GITHUB_STEP_SUMMARY
118+
echo "| Dokka (Kotlin API Docs) | Generated |" >> $GITHUB_STEP_SUMMARY
149119
echo "" >> $GITHUB_STEP_SUMMARY
150120
echo "**Commit:** \`${GITHUB_SHA::7}\`" >> $GITHUB_STEP_SUMMARY
151121
echo "**Branch:** \`${GITHUB_REF_NAME}\`" >> $GITHUB_STEP_SUMMARY
152122
153123
if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then
154124
echo "" >> $GITHUB_STEP_SUMMARY
155-
echo "📦 Documentation artifact uploaded and available for 30 days" >> $GITHUB_STEP_SUMMARY
125+
echo "Documentation artifact uploaded and available for 30 days" >> $GITHUB_STEP_SUMMARY
156126
fi
157127
158128
# Optional: Validate documentation links
@@ -172,13 +142,13 @@ jobs:
172142
- name: Check Documentation Size
173143
run: |
174144
SIZE=$(du -sh docs-output/ | cut -f1)
175-
echo "📊 Documentation size: $SIZE"
145+
echo "Documentation size: $SIZE"
176146
echo "### Documentation Validation" >> $GITHUB_STEP_SUMMARY
177147
echo "Documentation size: **$SIZE**" >> $GITHUB_STEP_SUMMARY
178148
179149
- name: List Generated Files
180150
run: |
181-
echo "### 📁 Generated Files" >> $GITHUB_STEP_SUMMARY
151+
echo "### Generated Files" >> $GITHUB_STEP_SUMMARY
182152
echo '```' >> $GITHUB_STEP_SUMMARY
183153
find docs-output/ -type f | head -20 >> $GITHUB_STEP_SUMMARY
184154
echo '```' >> $GITHUB_STEP_SUMMARY

build.gradle.kts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,97 @@ plugins {
4545
alias(libs.plugins.ktrofit) apply false
4646

4747
alias(libs.plugins.room) apply false
48+
alias(libs.plugins.dokka)
49+
}
50+
51+
// Apply Dokka to subprojects
52+
subprojects {
53+
apply(plugin = "org.jetbrains.dokka")
54+
}
55+
56+
// Dokka Configuration
57+
tasks.withType<org.jetbrains.dokka.gradle.DokkaMultiModuleTask>().configureEach {
58+
moduleName.set("KMP Project Documentation")
59+
60+
outputDirectory.set(layout.buildDirectory.dir("docs/html"))
61+
62+
val readmeFile = rootProject.file("README.md")
63+
if (readmeFile.exists()) {
64+
includes.from(readmeFile)
65+
}
66+
}
67+
68+
subprojects {
69+
tasks.withType<org.jetbrains.dokka.gradle.DokkaTaskPartial>().configureEach {
70+
moduleName.set(project.name)
71+
72+
moduleVersion.set(project.version.toString())
73+
74+
dokkaSourceSets.configureEach {
75+
suppress.set(false)
76+
77+
displayName.set(name)
78+
79+
val readmeFile = project.file("README.md")
80+
if (readmeFile.exists()) {
81+
includes.from(readmeFile)
82+
}
83+
84+
sourceLink {
85+
localDirectory.set(projectDir.resolve("src"))
86+
remoteUrl.set(
87+
java.net.URI(
88+
"https://github.com/YOUR_USERNAME/YOUR_REPO/tree/main/${project.path.replace(":", "/")}/src"
89+
).toURL()
90+
)
91+
remoteLineSuffix.set("#L")
92+
}
93+
94+
externalDocumentationLink {
95+
url.set(java.net.URI("https://kotlinlang.org/api/kotlinx.coroutines/").toURL())
96+
packageListUrl.set(
97+
java.net.URI("https://kotlinlang.org/api/kotlinx.coroutines/package-list").toURL()
98+
)
99+
}
100+
101+
externalDocumentationLink {
102+
url.set(java.net.URI("https://kotlinlang.org/api/kotlinx-serialization/").toURL())
103+
}
104+
105+
externalDocumentationLink {
106+
url.set(java.net.URI("https://api.ktor.io/").toURL())
107+
}
108+
109+
platform.set(
110+
when {
111+
name.contains("android", ignoreCase = true) ->
112+
org.jetbrains.dokka.Platform.jvm
113+
name.contains("jvm", ignoreCase = true) ->
114+
org.jetbrains.dokka.Platform.jvm
115+
name.contains("js", ignoreCase = true) ->
116+
org.jetbrains.dokka.Platform.js
117+
name.contains("native", ignoreCase = true) ||
118+
name.contains("ios", ignoreCase = true) ->
119+
org.jetbrains.dokka.Platform.native
120+
name.contains("common", ignoreCase = true) ->
121+
org.jetbrains.dokka.Platform.common
122+
else -> org.jetbrains.dokka.Platform.common
123+
}
124+
)
125+
126+
suppressInheritedMembers.set(false)
127+
suppressObviousFunctions.set(true)
128+
skipEmptyPackages.set(true)
129+
reportUndocumented.set(false)
130+
skipDeprecated.set(false)
131+
jdkVersion.set(17)
132+
133+
perPackageOption {
134+
matchingRegex.set(".*\\.internal.*")
135+
suppress.set(true)
136+
}
137+
}
138+
}
48139
}
49140

50141
object DynamicVersion {

0 commit comments

Comments
 (0)