Skip to content

Commit 605967d

Browse files
committed
Add Dokka API docs, GitHub Pages landing + /docs and /demo
- Add Dokka v2 to root and theme modules; output to build/site/docs - Add KDoc to public API (theme-prefs, theme-material, theme-material3) - Add landing page .github/pages-assets/index.html (links to docs + demo) - Update gh-pages.yml: build demo + Dokka, assemble single site artifact, deploy - Trigger workflow on branch dokka Made-with: Cursor
1 parent 319949b commit 605967d

20 files changed

Lines changed: 251 additions & 6 deletions

File tree

.github/pages-assets/index.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>MaterialThemePrefs</title>
7+
<style>
8+
body { font-family: system-ui, sans-serif; max-width: 640px; margin: 2rem auto; padding: 0 1rem; line-height: 1.5; }
9+
h1 { font-size: 1.5rem; }
10+
p { color: #444; }
11+
ul { list-style: none; padding: 0; }
12+
li { margin: 0.75rem 0; }
13+
a { color: #0969da; text-decoration: none; }
14+
a:hover { text-decoration: underline; }
15+
</style>
16+
</head>
17+
<body>
18+
<h1>MaterialThemePrefs</h1>
19+
<p>Kotlin Multiplatform library for persistent light/dark/system theme preference with Compose Multiplatform (Material and Material 3).</p>
20+
<ul>
21+
<li><a href="./docs/">API Documentation</a></li>
22+
<li><a href="./demo/">Web Demo</a></li>
23+
</ul>
24+
</body>
25+
</html>

.github/workflows/gh-pages.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build & Deploy CI/CD
22

33
on:
44
push:
5-
branches: ["master", "dev"]
5+
branches: ["master", "dev", "dokka"]
66

77
# Allows you to run this workflow manually from the Actions tab
88
workflow_dispatch:
@@ -37,12 +37,19 @@ jobs:
3737
cache-overwrite-existing: true
3838
- name: "Build WasmJS App"
3939
run: gradle --no-configure-on-demand :sample:web:wasmJsBrowserDistribution
40+
- name: "Build Dokka"
41+
run: gradle --no-configure-on-demand :dokkaGenerate
42+
- name: "Assemble site"
43+
run: |
44+
mkdir -p build/site/demo
45+
cp .github/pages-assets/index.html build/site/index.html
46+
cp -r sample/web/build/dist/wasmJs/productionExecutable/* build/site/demo/
4047
- name: Setup Pages
4148
uses: actions/configure-pages@v5
4249
- name: Upload artifact
4350
uses: actions/upload-pages-artifact@v3
4451
with:
45-
path: ./sample/web/build/dist/wasmJs/productionExecutable
52+
path: ./build/site
4653

4754
deploy:
4855
environment:

build.gradle.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,17 @@ plugins {
55
alias(libs.plugins.android.application) apply false
66
alias(libs.plugins.android.kotlin.multiplatform.library) apply false
77
alias(libs.plugins.compose.multiplatform) apply false
8+
alias(libs.plugins.dokka)
9+
}
10+
11+
dependencies {
12+
dokka(project(":theme:theme-prefs"))
13+
dokka(project(":theme:theme-material"))
14+
dokka(project(":theme:theme-material3"))
15+
}
16+
17+
dokka {
18+
dokkaPublications.html {
19+
outputDirectory.set(layout.buildDirectory.dir("site/docs"))
20+
}
821
}

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ androidx-navigation = "2.9.2"
1313
androidx-activity-compose = "1.12.4"
1414
kotlinx-serialization-json = "1.10.0"
1515
vanniktech = "0.36.0"
16+
dokka = "2.1.0"
1617

1718
[libraries]
1819
androidx-navigation-compose = { module = "org.jetbrains.androidx.navigation:navigation-compose", version.ref = "androidx-navigation" }
@@ -40,3 +41,4 @@ android-application = { id = "com.android.application", version.ref = "agp" }
4041
android-kotlin-multiplatform-library = { id = "com.android.kotlin.multiplatform.library", version.ref = "agp" }
4142
compose-multiplatform = { id = "org.jetbrains.compose", version.ref = "compose" }
4243
vanniktech-maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech" }
44+
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }

theme/theme-material/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ plugins {
88
alias(libs.plugins.kotlin.compose.compiler)
99
alias(libs.plugins.compose.multiplatform)
1010
alias(libs.plugins.android.kotlin.multiplatform.library)
11+
alias(libs.plugins.dokka)
1112
id("convention.publication")
1213
}
1314

theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/MaterialThemePrefs.kt

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,23 @@ import com.softartdev.theme.pref.ThemeEnum
1212
import com.softartdev.theme.pref.ThemePrefs
1313
import com.softartdev.theme.pref.rememberPreferenceHelper
1414

15+
/**
16+
* [ThemePrefs] implementation for Material (v1) theming.
17+
* Provides [colors] that switch based on [ThemeEnum] (light/dark/system).
18+
*
19+
* @param preferenceHelper Backing storage for the selected theme.
20+
* @param darkColorPalette Colors used when dark theme is active. Defaults to [darkColors].
21+
* @param lightColorPalette Colors used when light theme is active. Defaults to [lightColors].
22+
*/
1523
public class MaterialThemePrefs(
1624
preferenceHelper: PreferenceHelper,
1725
private val darkColorPalette: Colors = darkColors(),
1826
private val lightColorPalette: Colors = lightColors()
1927
) : ThemePrefs(preferenceHelper) {
2028

29+
/**
30+
* Current [Colors] based on [ThemeEnum]. For [ThemeEnum.SystemDefault], follows system dark/light.
31+
*/
2132
public val colors: Colors
2233
@Composable
2334
@ReadOnlyComposable
@@ -28,20 +39,34 @@ public class MaterialThemePrefs(
2839
}
2940
}
3041

42+
/**
43+
* Returns [Colors] when this [ThemePrefs] is a [MaterialThemePrefs]; use inside Material theme scope.
44+
*/
3145
public val ThemePrefs.colors: Colors
3246
@Composable
3347
@ReadOnlyComposable
3448
get() {
3549
val materialThemePrefs = this as MaterialThemePrefs
36-
return materialThemePrefs.colors
37-
}
50+
return materialThemePrefs.colors
51+
}
3852

53+
/**
54+
* Returns a [MaterialThemePrefs] remembered across recompositions using default [rememberPreferenceHelper].
55+
*/
3956
@Composable
4057
public fun rememberThemePrefs(): MaterialThemePrefs {
4158
val preferenceHelper = rememberPreferenceHelper()
4259
return remember { MaterialThemePrefs(preferenceHelper) }
4360
}
4461

62+
/**
63+
* Returns a [MaterialThemePrefs] with the given [PreferenceHelper] and color palettes.
64+
*
65+
* @param preferHelper Backing storage for theme preference.
66+
* @param darkColorPalette Colors for dark theme.
67+
* @param lightColorPalette Colors for light theme.
68+
* @return Remembered [MaterialThemePrefs] instance.
69+
*/
4570
@Composable
4671
public fun rememberThemePrefs(
4772
preferHelper: PreferenceHelper = rememberPreferenceHelper(),

theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/MenuPreference.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,21 @@ import io.github.softartdev.theme_prefs.generated.resources.choose_theme
2222
import io.github.softartdev.theme_prefs.generated.resources.theme
2323
import org.jetbrains.compose.resources.stringResource
2424

25+
/**
26+
* List item used as a category header for the "Theme" section in preference screens.
27+
*/
2528
@Composable
2629
public fun ThemePreferencesCategory(): Unit = PreferenceCategory(
2730
title = stringResource(Res.string.theme),
2831
vector = Icons.Filled.Brightness4
2932
)
3033

34+
/**
35+
* List item that opens the theme picker when clicked. Shows current theme in secondary text.
36+
*
37+
* @param themePrefs [ThemePrefs] to read current theme from; defaults to [LocalThemePrefs.current].
38+
* @param onClick Called when the row is clicked (e.g. to show theme dialog).
39+
*/
3140
@Composable
3241
public fun ThemePreferenceItem(
3342
themePrefs: ThemePrefs = LocalThemePrefs.current,
@@ -39,6 +48,12 @@ public fun ThemePreferenceItem(
3948
onClick = onClick
4049
)
4150

51+
/**
52+
* Non-clickable list item used as a section header (icon + title in secondary style).
53+
*
54+
* @param title Section title.
55+
* @param vector Icon for the section.
56+
*/
4257
@Composable
4358
public fun PreferenceCategory(title: String, vector: ImageVector): Unit = ListItem(
4459
icon = { Icon(imageVector = vector, contentDescription = title) },
@@ -49,6 +64,15 @@ public fun PreferenceCategory(title: String, vector: ImageVector): Unit = ListIt
4964
}
5065
)
5166

67+
/**
68+
* Clickable list row for a preference: icon, title, optional secondary/trailing content.
69+
*
70+
* @param title Primary text.
71+
* @param vector Icon for the row.
72+
* @param onClick Called when the row is clicked.
73+
* @param secondaryText Optional secondary text or composable.
74+
* @param trailing Optional trailing composable.
75+
*/
5276
@Composable
5377
public fun PreferenceItem(
5478
title: String,

theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/PreferableMaterialTheme.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ import com.softartdev.theme.pref.PreferableMaterialTheme
1111
import com.softartdev.theme.pref.PreferenceHelper
1212
import com.softartdev.theme.pref.rememberPreferenceHelper
1313

14+
/**
15+
* Material (v1) theme that respects stored light/dark preference and provides [ThemePrefs] via [LocalThemePrefs].
16+
*
17+
* @param preferHelper Backing storage for theme; defaults to [rememberPreferenceHelper].
18+
* @param darkColorPalette Colors when dark theme is active.
19+
* @param lightColorPalette Colors when light theme is active.
20+
* @param content Composable content with access to [PreferableMaterialTheme.themePrefs].
21+
*/
1422
@Composable
1523
public fun PreferableMaterialTheme(
1624
preferHelper: PreferenceHelper = rememberPreferenceHelper(),

theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/RadioDialogContent.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ import androidx.compose.ui.unit.dp
2121
import com.softartdev.theme.pref.ThemeEnum
2222
import org.jetbrains.compose.resources.stringResource
2323

24+
/**
25+
* Radio group for selecting a [ThemeEnum] (Light, Dark, System default). Use inside theme dialogs.
26+
*
27+
* @param darkThemeState State holding the current selection; updates on option click.
28+
*/
2429
@Composable
2530
public fun RadioDialogContent(darkThemeState: MutableState<ThemeEnum>) {
2631
Column(modifier = Modifier.selectableGroup()) {

theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/SettingsScaffold.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ import io.github.softartdev.theme_prefs.generated.resources.Res
1818
import io.github.softartdev.theme_prefs.generated.resources.settings
1919
import org.jetbrains.compose.resources.stringResource
2020

21+
/**
22+
* Scaffold with a top app bar suitable for settings screens (back navigation + optional actions).
23+
*
24+
* @param onBackClick Called when the back button is clicked.
25+
* @param actions Optional trailing actions in the top bar.
26+
* @param content Main content with [PaddingValues] for the scaffold insets.
27+
*/
2128
@Composable
2229
public fun SettingsScaffold(
2330
onBackClick: () -> Unit = {},
@@ -28,6 +35,14 @@ public fun SettingsScaffold(
2835
content = content
2936
)
3037

38+
/**
39+
* Top app bar with back button and title for settings screens.
40+
*
41+
* @param onBackClick Called when the back icon is clicked.
42+
* @param actions Optional trailing actions.
43+
* @param localizedText Title text; defaults to "Settings" string resource.
44+
* @param backVector Icon for the back button; defaults to ArrowBack.
45+
*/
3146
@Composable
3247
public fun SettingsTopAppBar(
3348
onBackClick: () -> Unit = {},

0 commit comments

Comments
 (0)