Skip to content

Commit bb7c670

Browse files
chore: include design component version in dev documentation (#661)
* Add version screen in about * Add component version in demo screens * Use Mustache to add component and tokens versions in documentation * Add a Dokka plugin to display the component design version and guidelines URL in documentation * Display design guidelines and version in a table instead of two separate sections * Simplify code by removing OudsComponentTagContentProvider * Fix "Duplicate content roots detected" error * Add Gradle tasks to check and update documentation * Fix Gradle sync issue * Tokens versions are now displayed in a table * Document code related to Dokka plugin * Update CSS to always wrap composable parameters in the documentation * Review: Replace values with entries * Review: Remove useless context property in OudsComponentDocumentableTransformer * Review: Add documentation explaining the purpose of OudsDokkaPlugin --------- Co-authored-by: Pauline Auvray <[email protected]>
1 parent 4d016cd commit bb7c670

File tree

57 files changed

+918
-154
lines changed

Some content is hidden

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

57 files changed

+918
-154
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ docs/dokka/
3636

3737
# App
3838
app/src/main/res/raw/changelog.md
39+
40+
# Mustache output
41+
Module.md

app/build.gradle.kts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ tasks.register<DefaultTask>("updateAppChangelog") {
150150
}
151151

152152
fun updateBuildConfig() {
153-
val tokensVersion = findTypedProperty<String>("tokensVersion").orEmpty()
154-
155153
val gitHubWorkflow = Environment.getVariablesOrNull("GITHUB_WORKFLOW").first()
156154
val pullRequestNumber = if (gitHubWorkflow == "app-distribution-alpha") {
157155
gitHubApi {
@@ -163,15 +161,14 @@ fun updateBuildConfig() {
163161
}
164162

165163
android.defaultConfig {
166-
buildConfigField("String", "TOKENS_VERSION", "\"$tokensVersion\"")
167164
buildConfigField("String", "PULL_REQUEST_NUMBER", if (pullRequestNumber != null) "\"$pullRequestNumber\"" else "null")
168165
}
169166
}
170167

171168
gradle.projectsEvaluated {
172169
tasks["preBuild"].apply {
170+
dependsOn(":checkDocumentation")
173171
dependsOn(":checkNotice")
174-
dependsOn(":checkTokensVersion")
175172
dependsOn(tasks["updateAppChangelog"])
176173
}
177174
updateBuildConfig()

app/src/main/java/com/orange/ouds/app/ui/Screen.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,9 @@ sealed class Screen(
116116
route = AboutDestinations.MaterialComponentsRoute,
117117
title = R.string.app_about_materialComponents_label
118118
)
119+
120+
data object AboutVersions : Screen(
121+
route = AboutDestinations.VersionsRoute,
122+
title = R.string.app_about_versions_label
123+
)
119124
}

app/src/main/java/com/orange/ouds/app/ui/about/AboutNavigation.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.orange.ouds.app.ui.about.AboutNavigationKey.MenuItemIdKey
2121
object AboutDestinations {
2222
const val FileRoute = "ouds/module/about/file"
2323
const val MaterialComponentsRoute = "ouds/module/about/materialComponents"
24+
const val VersionsRoute = "ouds/module/about/versions"
2425
}
2526

2627
object AboutNavigationKey {
@@ -40,4 +41,8 @@ fun NavGraphBuilder.addAboutNavGraph() {
4041
composable(AboutDestinations.MaterialComponentsRoute) { _ ->
4142
AboutMaterialComponentsScreen()
4243
}
44+
45+
composable(AboutDestinations.VersionsRoute) { _ ->
46+
AboutVersionsScreen()
47+
}
4348
}

app/src/main/java/com/orange/ouds/app/ui/about/AboutScreen.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ private val oudsAboutMenuItems = listOf(
4747
AboutFileMenuItem(1, R.string.app_about_legalInformation_label, AboutFileMenuItem.File(R.raw.about_legal_information, AboutFileMenuItem.File.Format.Html)),
4848
AboutFileMenuItem(2, R.string.app_about_privacyPolicy_label, AboutFileMenuItem.File(R.raw.about_privacy_policy, AboutFileMenuItem.File.Format.Html)),
4949
AboutFileMenuItem(3, R.string.app_about_changelog_label, AboutFileMenuItem.File(R.raw.changelog, AboutFileMenuItem.File.Format.Markdown)),
50-
AboutRouteMenuItem(4, R.string.app_about_materialComponents_label, AboutDestinations.MaterialComponentsRoute),
51-
AboutAppSettingsItem(5, R.string.app_about_changeLanguage_label)
50+
AboutRouteMenuItem(4, R.string.app_about_versions_label, AboutDestinations.VersionsRoute),
51+
AboutRouteMenuItem(5, R.string.app_about_materialComponents_label, AboutDestinations.MaterialComponentsRoute),
52+
AboutAppSettingsItem(6, R.string.app_about_changeLanguage_label)
5253
)
5354

5455
sealed class AboutMenuItem(val id: Int, @StringRes val labelRes: Int) {
@@ -97,10 +98,6 @@ fun AboutScreen(onMenuItemClick: (id: Int) -> Unit) {
9798
}
9899
Text(text = pullRequest, style = OudsTheme.typography.body.default.medium)
99100
}
100-
Text(
101-
text = stringResource(R.string.app_about_tokensVersion_label, BuildConfig.TOKENS_VERSION),
102-
style = OudsTheme.typography.body.default.medium
103-
)
104101
}
105102
}
106103
)
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* Software Name: OUDS Android
3+
* SPDX-FileCopyrightText: Copyright (c) Orange SA
4+
* SPDX-License-Identifier: MIT
5+
*
6+
* This software is distributed under the MIT license,
7+
* the text of which is available at https://opensource.org/license/MIT/
8+
* or see the "LICENSE" file for more details.
9+
*
10+
* Software description: Android library of reusable graphical components
11+
*/
12+
13+
package com.orange.ouds.app.ui.about
14+
15+
import androidx.annotation.StringRes
16+
import androidx.compose.foundation.layout.padding
17+
import androidx.compose.foundation.lazy.LazyColumn
18+
import androidx.compose.foundation.lazy.items
19+
import androidx.compose.material3.ListItem
20+
import androidx.compose.material3.Text
21+
import androidx.compose.runtime.Composable
22+
import androidx.compose.ui.Modifier
23+
import androidx.compose.ui.res.stringResource
24+
import androidx.compose.ui.tooling.preview.PreviewLightDark
25+
import com.orange.ouds.app.R
26+
import com.orange.ouds.app.ui.utilities.composable.Screen
27+
import com.orange.ouds.app.ui.utilities.listItemHorizontalPadding
28+
import com.orange.ouds.core.theme.OudsTheme
29+
import com.orange.ouds.core.utilities.OudsPreview
30+
import com.orange.ouds.theme.OudsVersion
31+
import kotlin.reflect.full.declaredMemberProperties
32+
33+
@Composable
34+
fun AboutVersionsScreen() {
35+
Screen {
36+
LazyColumn {
37+
item {
38+
VersionsSectionTitle(titleRes = R.string.app_about_versions_tokens_label)
39+
}
40+
items(getVersions<OudsVersion.Tokens>()) { version ->
41+
Version(version = version)
42+
}
43+
item {
44+
VersionsSectionTitle(
45+
modifier = Modifier.padding(top = OudsTheme.spaces.fixed.small),
46+
titleRes = R.string.app_about_versions_components_label
47+
)
48+
}
49+
items(getVersions<OudsVersion.Component>()) { version ->
50+
Version(version = version)
51+
}
52+
}
53+
}
54+
}
55+
56+
@Composable
57+
private fun VersionsSectionTitle(@StringRes titleRes: Int, modifier: Modifier = Modifier) {
58+
ListItem(
59+
modifier = modifier.listItemHorizontalPadding(),
60+
headlineContent = {
61+
Text(
62+
text = stringResource(id = titleRes),
63+
style = OudsTheme.typography.heading.medium
64+
)
65+
}
66+
)
67+
}
68+
69+
@Composable
70+
private fun Version(version: Version) {
71+
ListItem(
72+
modifier = Modifier.listItemHorizontalPadding(),
73+
headlineContent = {
74+
Text(
75+
text = version.name,
76+
style = OudsTheme.typography.body.strong.large
77+
)
78+
},
79+
trailingContent = {
80+
Text(
81+
text = version.value,
82+
style = OudsTheme.typography.body.default.large
83+
)
84+
}
85+
)
86+
}
87+
88+
private data class Version(val name: String, val value: String)
89+
90+
private inline fun <reified T : Any> getVersions(): List<Version> {
91+
return T::class.declaredMemberProperties.map { property ->
92+
val name = property.name
93+
.split("(?=\\p{Upper})".toRegex())
94+
.filter { it.isNotEmpty() }
95+
.mapIndexed { index, word -> if (index == 0) word else word.lowercase() }
96+
.joinToString(" ")
97+
val value = property.getter.call() as String
98+
Version(name, value)
99+
}
100+
}
101+
102+
@PreviewLightDark
103+
@Composable
104+
fun PreviewVersionsScreen() = OudsPreview {
105+
AboutVersionsScreen()
106+
}

app/src/main/java/com/orange/ouds/app/ui/components/badge/BadgeDemoScreen.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import com.orange.ouds.core.component.OudsBadge
4040
import com.orange.ouds.core.theme.OudsTheme
4141
import com.orange.ouds.core.utilities.OudsPreview
4242
import com.orange.ouds.foundation.extensions.orElse
43+
import com.orange.ouds.theme.OudsVersion
4344

4445
@Composable
4546
fun BadgeDemoScreen() {
@@ -48,7 +49,8 @@ fun BadgeDemoScreen() {
4849
description = stringResource(id = Component.Badge.descriptionRes),
4950
bottomSheetContent = { BadgeDemoBottomSheetContent(state = state) },
5051
codeSnippet = { badgeDemoCodeSnippet(state = state) },
51-
demoContent = { BadgeDemoContent(state = state) }
52+
demoContent = { BadgeDemoContent(state = state) },
53+
version = OudsVersion.Component.Badge
5254
)
5355
}
5456

app/src/main/java/com/orange/ouds/app/ui/components/button/ButtonDemoScreen.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import com.orange.ouds.app.ui.utilities.composable.DemoScreen
3535
import com.orange.ouds.core.component.OudsButton
3636
import com.orange.ouds.core.theme.OudsTheme
3737
import com.orange.ouds.core.utilities.OudsPreview
38+
import com.orange.ouds.theme.OudsVersion
3839

3940
@Composable
4041
fun ButtonDemoScreen() {
@@ -44,7 +45,8 @@ fun ButtonDemoScreen() {
4445
bottomSheetContent = { ButtonDemoBottomSheetContent(state = state) },
4546
codeSnippet = { buttonDemoCodeSnippet(state = state) },
4647
demoContent = { ButtonDemoContent(state = state) },
47-
demoContentOnColoredBox = state.onColoredBox
48+
demoContentOnColoredBox = state.onColoredBox,
49+
version = OudsVersion.Component.Button
4850
)
4951
}
5052

app/src/main/java/com/orange/ouds/app/ui/components/checkbox/CheckboxDemoScreen.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import com.orange.ouds.app.ui.utilities.composable.DemoScreen
2828
import com.orange.ouds.core.component.OudsCheckbox
2929
import com.orange.ouds.core.component.OudsTriStateCheckbox
3030
import com.orange.ouds.core.utilities.OudsPreview
31+
import com.orange.ouds.theme.OudsVersion
3132

3233
@Composable
3334
fun CheckboxDemoScreen(indeterminate: Boolean = false) {
@@ -41,7 +42,8 @@ fun CheckboxDemoScreen(indeterminate: Boolean = false) {
4142
} else {
4243
CheckboxDemoContent(state = state)
4344
}
44-
}
45+
},
46+
version = OudsVersion.Component.Checkbox
4547
)
4648
}
4749

app/src/main/java/com/orange/ouds/app/ui/components/checkbox/CheckboxItemDemoScreen.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import com.orange.ouds.core.component.OudsCheckboxItem
2727
import com.orange.ouds.core.component.OudsControlItem
2828
import com.orange.ouds.core.component.OudsTriStateCheckboxItem
2929
import com.orange.ouds.core.utilities.OudsPreview
30+
import com.orange.ouds.theme.OudsVersion
3031

3132
@Composable
3233
fun CheckboxItemDemoScreen(indeterminate: Boolean = false) {
@@ -41,7 +42,8 @@ fun CheckboxItemDemoScreen(indeterminate: Boolean = false) {
4142
CheckboxItemDemoContent(state = state)
4243
}
4344
},
44-
demoContentPaddingValues = PaddingValues()
45+
demoContentPaddingValues = PaddingValues(),
46+
version = OudsVersion.Component.Checkbox
4547
)
4648
}
4749

0 commit comments

Comments
 (0)