Skip to content

Commit 2db5b2d

Browse files
committed
Add Gradle tasks to check and update documentation
1 parent 6ec8141 commit 2db5b2d

File tree

16 files changed

+205
-40
lines changed

16 files changed

+205
-40
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ fun updateBuildConfig() {
167167

168168
gradle.projectsEvaluated {
169169
tasks["preBuild"].apply {
170+
dependsOn(":checkDocumentation")
170171
dependsOn(":checkNotice")
171172
dependsOn(tasks["updateAppChangelog"])
172173
}

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ plugins {
2424
id("release")
2525
id("netlify")
2626
id("check-notice")
27+
id("documentation")
2728
}
2829

2930
dependencies {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.gradle
14+
15+
import com.orange.ouds.theme.OudsVersion
16+
import org.gradle.api.Project
17+
18+
enum class Component {
19+
Badge,
20+
Button,
21+
Checkbox,
22+
Chip,
23+
Divider,
24+
Link,
25+
RadioButton,
26+
Switch;
27+
28+
val version: String
29+
get() = with(OudsVersion.Component) {
30+
when (this@Component) {
31+
Component.Badge -> Badge
32+
Component.Button -> Button
33+
Component.Checkbox -> Checkbox
34+
Component.Chip -> Chip
35+
Component.Divider -> Divider
36+
Component.Link -> Link
37+
Component.RadioButton -> RadioButton
38+
Component.Switch -> Switch
39+
}
40+
}
41+
42+
fun getSourceFilePaths(project: Project): List<String> {
43+
val filenames = when (this) {
44+
Component.Badge -> listOf("OudsBadge")
45+
Component.Button -> listOf("OudsButton")
46+
Component.Checkbox -> listOf("OudsCheckbox", "OudsCheckboxItem")
47+
Component.Chip -> listOf("OudsFilterChip", "OudsSuggestionChip")
48+
Component.Divider -> listOf("OudsDivider")
49+
Component.Link -> listOf("OudsLink")
50+
Component.RadioButton -> listOf("OudsRadioButton", "OudsRadioButtonItem")
51+
Component.Switch -> listOf("OudsSwitch", "OudsSwitchItem")
52+
}
53+
54+
return filenames.map { "${project.rootProject.projectDir}/core/src/main/java/com/orange/ouds/core/component/$it.kt" }
55+
}
56+
}

buildSrc/src/main/kotlin/documentation.gradle.kts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111
*/
1212

1313
import com.github.mustachejava.DefaultMustacheFactory
14+
import com.orange.ouds.gradle.Component
1415
import com.orange.ouds.theme.OudsVersion
1516
import java.io.FileOutputStream
1617
import java.io.PrintWriter
1718
import kotlin.reflect.full.declaredMemberProperties
1819

1920
tasks.register<DefaultTask>("prepareDocumentation") {
21+
dependsOn(tasks["checkDocumentation"])
22+
2023
doLast {
2124
val mustacheFactory = DefaultMustacheFactory()
2225

@@ -54,3 +57,40 @@ tasks.register<DefaultTask>("prepareDocumentation") {
5457
}
5558
}
5659
}
60+
61+
tasks.register<DefaultTask>("checkDocumentation") {
62+
doLast {
63+
val componentVersionRegex = "Design version: (.*)$".toRegex()
64+
Component.values().forEach { component ->
65+
component.getSourceFilePaths(project).forEach { sourceFilePath ->
66+
val versionByLineIndex = File(sourceFilePath).readLines()
67+
.mapIndexedNotNull { index, line ->
68+
componentVersionRegex.find(line)
69+
?.groupValues
70+
?.getOrNull(1)
71+
?.let { version ->
72+
index to version
73+
}
74+
}
75+
versionByLineIndex.forEach { (lineIndex, version) ->
76+
if (version != component.version) {
77+
throw GradleException("Component version at line ${lineIndex + 1} in $sourceFilePath is not up to date. Please launch updateDocumentation Gradle task.")
78+
}
79+
}
80+
}
81+
}
82+
}
83+
}
84+
85+
tasks.register<DefaultTask>("updateDocumentation") {
86+
doLast {
87+
val componentVersionRegex = "(Design version: ).*".toRegex()
88+
Component.values().forEach { component ->
89+
component.getSourceFilePaths(project).forEach { sourceFilePath ->
90+
File(sourceFilePath).replace(componentVersionRegex) { matchResult ->
91+
"${matchResult.groupValues[1]}${component.version}"
92+
}
93+
}
94+
}
95+
}
96+
}

core/src/main/java/com/orange/ouds/core/component/OudsBadge.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import com.orange.ouds.core.utilities.PreviewEnumEntries
5656
import com.orange.ouds.foundation.utilities.BasicPreviewParameterProvider
5757

5858

59-
// TODO: Add documentation URL once it is available
59+
// TODO: Update documentation URL once it is available
6060
/**
6161
* The badge is a small UI element used to highlight status, notifications, or categorization within an interface.
6262
* It is often displayed as a label or indicator with a distinct background color and text.
@@ -71,6 +71,10 @@ import com.orange.ouds.foundation.utilities.BasicPreviewParameterProvider
7171
* See [BadgedBox] for a top level layout that will properly place the badge relative to content
7272
* such as text or an icon.
7373
*
74+
* > Design guidelines: [unified-design-system.orange.com](https://unified-design-system.orange.com)
75+
*
76+
* > Design version: 1.1.0
77+
*
7478
* @param modifier The [Modifier] to be applied to this badge.
7579
* @param status The status of this badge. The background color of the badge is based on this status.
7680
* @param size The size of this badge.
@@ -92,7 +96,7 @@ fun OudsBadge(
9296
)
9397
}
9498

95-
// TODO: Add documentation URL once it is available
99+
// TODO: Update documentation URL once it is available
96100
/**
97101
* The badge is a small UI element used to highlight status, notifications, or categorization within an interface.
98102
* It is often displayed as a label or indicator with a distinct background color and text.
@@ -105,6 +109,10 @@ fun OudsBadge(
105109
* See [BadgedBox] for a top level layout that will properly place the badge relative to content
106110
* such as text or an icon.
107111
*
112+
* > Design guidelines: [unified-design-system.orange.com](https://unified-design-system.orange.com)
113+
*
114+
* > Design version: 1.1.0
115+
*
108116
* @param count The number displayed in the badge. Minimum and maximum values are 0 and 99 respectively.
109117
* Values greater than 99 are displayed as "+99".
110118
* @param modifier The [Modifier] to be applied to this badge.
@@ -131,7 +139,7 @@ fun OudsBadge(
131139
)
132140
}
133141

134-
// TODO: Add documentation URL once it is available
142+
// TODO: Update documentation URL once it is available
135143
/**
136144
* The badge is a small UI element used to highlight status, notifications, or categorization within an interface.
137145
* It is often displayed as a label or indicator with a distinct background color and text.
@@ -144,6 +152,10 @@ fun OudsBadge(
144152
* See [BadgedBox] for a top level layout that will properly place the badge relative to content
145153
* such as text or an icon.
146154
*
155+
* > Design guidelines: [unified-design-system.orange.com](https://unified-design-system.orange.com)
156+
*
157+
* > Design version: 1.1.0
158+
*
147159
* @param icon The icon displayed in the badge.
148160
* @param modifier The [Modifier] to be applied to this badge.
149161
* @param status The status of this badge. The background color of the badge and the icon color are based on this status.

core/src/main/java/com/orange/ouds/core/component/OudsButton.kt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,10 @@ import com.orange.ouds.core.utilities.getPreviewEnumEntry
7272
import com.orange.ouds.foundation.extensions.ifNotNull
7373
import com.orange.ouds.foundation.extensions.orElse
7474
import com.orange.ouds.foundation.utilities.BasicPreviewParameterProvider
75+
import com.orange.ouds.theme.tokens.components.OudsButtonMonoTokens
7576
import kotlinx.parcelize.Parcelize
7677

7778
/**
78-
* <a href="https://unified-design-system.orange.com/472794e18/p/48a788-button" class="external" target="_blank">**OUDS Button design guidelines**</a>
79-
*
8079
* Buttons are interactive elements designed to trigger specific actions or events when tapped by a user.
8180
*
8281
* This version of the button uses the *text only* layout which is the most used layout.
@@ -85,6 +84,10 @@ import kotlinx.parcelize.Parcelize
8584
* Note that in the case it is placed in an [OudsColoredBox], its monochrome variant is automatically displayed.
8685
* The tokens associated with these specific colors can be customized by overriding [OudsButtonMonoTokens].
8786
*
87+
* > Design guidelines: [unified-design-system.orange.com](https://unified-design-system.orange.com/472794e18/p/48a788-button)
88+
*
89+
* > Design version: 2.1.0
90+
*
8891
* @param label Label displayed in the button which describes the button action. Use action verbs or phrases to tell the user what will happen next.
8992
* @param onClick Callback invoked when the button is clicked.
9093
* @param modifier [Modifier] applied to the button.
@@ -125,8 +128,6 @@ fun OudsButton(
125128
}
126129

127130
/**
128-
* <a href="https://unified-design-system.orange.com/472794e18/p/48a788-button" class="external" target="_blank">**OUDS Button design guidelines**</a>
129-
*
130131
* Buttons are interactive elements designed to trigger specific actions or events when tapped by a user.
131132
*
132133
* This version of the button uses the *icon only* layout which is typically used in business or back-office interfaces, it is rarely used alone (usually part of a group of elements).
@@ -135,6 +136,10 @@ fun OudsButton(
135136
* Note that in the case it is placed in an [OudsColoredBox], its monochrome variant is automatically displayed.
136137
* The tokens associated with these specific colors can be customized by overriding [OudsButtonMonoTokens].
137138
*
139+
* > Design guidelines: [unified-design-system.orange.com](https://unified-design-system.orange.com/472794e18/p/48a788-button)
140+
*
141+
* > Design version: 2.1.0
142+
*
138143
* @param icon Icon displayed in the button. Use an icon to add additional affordance where the icon has a clear and well-established meaning.
139144
* @param onClick Callback invoked when the button is clicked.
140145
* @param modifier [Modifier] applied to the button.
@@ -175,8 +180,6 @@ fun OudsButton(
175180
}
176181

177182
/**
178-
* <a href="https://unified-design-system.orange.com/472794e18/p/48a788-button" class="external" target="_blank">**OUDS Button design guidelines**</a>
179-
*
180183
* Buttons are interactive elements designed to trigger specific actions or events when tapped by a user.
181184
*
182185
* This version of the button uses the *text + icon* layout which should remain specific to some clearly identified contexts (e.g. the use of an icon with a
@@ -186,6 +189,10 @@ fun OudsButton(
186189
* Note that in the case it is placed in an [OudsColoredBox], its monochrome variant is automatically displayed.
187190
* The tokens associated with these specific colors can be customized by overriding [OudsButtonMonoTokens].
188191
*
192+
* > Design guidelines: [unified-design-system.orange.com](https://unified-design-system.orange.com/472794e18/p/48a788-button)
193+
*
194+
* > Design version: 2.1.0
195+
*
189196
* @param icon Icon displayed in the button. Use an icon to add additional affordance where the icon has a clear and well-established meaning.
190197
* @param label Label displayed in the button which describes the button action. Use action verbs or phrases to tell the user what will happen next.
191198
* @param onClick Callback invoked when the button is clicked.

core/src/main/java/com/orange/ouds/core/component/OudsCheckbox.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ import com.orange.ouds.core.utilities.getPreviewEnumEntry
5050
import com.orange.ouds.foundation.utilities.BasicPreviewParameterProvider
5151

5252
/**
53-
* <a href="https://unified-design-system.orange.com/472794e18/p/23f1c1-checkbox" class="external" target="_blank">**OUDS Checkbox design guidelines**</a>
54-
*
5553
* Checkboxes are input controls that allow users to select one or more options from a number of choices.
5654
*
5755
* The **standalone checkbox variant** is used when the checkbox input is nested within another component and an alternative label is provided. For example,
5856
* a checkbox can be used in a data table where its purpose is clear from its position or its connection to other items in the same row or column.
5957
*
58+
* > Design guidelines: [unified-design-system.orange.com](https://unified-design-system.orange.com/472794e18/p/23f1c1-checkbox)
59+
*
60+
* > Design version: 2.1.0
61+
*
6062
* @see [OudsTriStateCheckbox] If you require support for an indeterminate state.
6163
* @see [OudsCheckboxItem] If you want to use a checkbox with an associated label and other optional elements.
6264
*
@@ -93,9 +95,6 @@ fun OudsCheckbox(
9395
}
9496

9597
/**
96-
*
97-
* <a href="https://unified-design-system.orange.com/472794e18/p/23f1c1-checkbox" class="external" target="_blank">**OUDS Checkbox design guidelines**</a>
98-
*
9998
* Checkboxes are input controls that allow users to select one or more options from a number of choices.
10099
*
101100
* This checkbox supports the indeterminate state: Checkboxes can have a parent-child relationship with other checkboxes. When the parent checkbox is checked,
@@ -105,6 +104,10 @@ fun OudsCheckbox(
105104
* The **indeterminate standalone checkbox variant** allows to manage a checkbox with an indeterminate state that can be used when the checkbox input is nested
106105
* within another component and an alternative label is provided.
107106
*
107+
* > Design guidelines: [unified-design-system.orange.com](https://unified-design-system.orange.com/472794e18/p/23f1c1-checkbox)
108+
*
109+
* > Design version: 2.1.0
110+
*
108111
* @see [OudsCheckbox] If you need a simple component that represents [Boolean] state.
109112
* @see [OudsTriStateCheckboxItem] If you want to use an indeterminate checkbox with an associated label and other optional elements.
110113
*

core/src/main/java/com/orange/ouds/core/component/OudsCheckboxItem.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ import com.orange.ouds.core.utilities.OudsPreview
3535
import com.orange.ouds.core.utilities.PreviewEnumEntries
3636

3737
/**
38-
* <a href="https://unified-design-system.orange.com/472794e18/p/23f1c1-checkbox" class="external" target="_blank">**OUDS Checkbox design guidelines**</a>
39-
*
4038
* Checkboxes are input controls that allow users to select one or more options from a number of choices.
4139
*
4240
* The **checkbox item variant** can function as a simple input with a label, or it can be combined with optional elements such as helper text, a divider, or an icon,
@@ -47,6 +45,10 @@ import com.orange.ouds.core.utilities.PreviewEnumEntries
4745
* In most cases, OUDS checkbox items span the entire width of the screen. Thus an horizontal padding of `OudsTheme.grids.margin` is applied to the content.
4846
* This behaviour can be disabled by calling [com.orange.ouds.core.utilities.edgeToEdgePadding] modifier with `enabled` parameter set to `false`.
4947
*
48+
* > Design guidelines: [unified-design-system.orange.com](https://unified-design-system.orange.com/472794e18/p/23f1c1-checkbox)
49+
*
50+
* > Design version: 2.1.0
51+
*
5052
* @see [OudsTriStateCheckboxItem] If you need an indeterminate state for the item's checkbox.
5153
* @see [OudsCheckbox] If you want to use a standalone checkbox without any other element.
5254
*
@@ -103,8 +105,6 @@ fun OudsCheckboxItem(
103105
}
104106

105107
/**
106-
* <a href="https://unified-design-system.orange.com/472794e18/p/23f1c1-checkbox" class="external" target="_blank">**OUDS Checkbox design guidelines**</a>
107-
*
108108
* Checkboxes are input controls that allow users to select one or more options from a number of choices.
109109
*
110110
* This checkbox item supports the indeterminate state: Checkboxes can have a parent-child relationship with other checkboxes. When the parent checkbox is
@@ -120,6 +120,10 @@ fun OudsCheckboxItem(
120120
* In most cases, OUDS checkbox items span the entire width of the screen. Thus an horizontal padding of `OudsTheme.grids.margin` is applied to the content.
121121
* This behaviour can be disabled by calling [com.orange.ouds.core.utilities.edgeToEdgePadding] modifier with `enabled` parameter set to `false`.
122122
*
123+
* > Design guidelines: [unified-design-system.orange.com](https://unified-design-system.orange.com/472794e18/p/23f1c1-checkbox)
124+
*
125+
* > Design version: 2.1.0
126+
*
123127
* @see [OudsCheckboxItem] If you need a simple item's checkbox that represents [Boolean] state.
124128
* @see [OudsTriStateCheckbox] If you only need an indeterminate standalone parent checkbox without any other element.
125129
*

core/src/main/java/com/orange/ouds/core/component/OudsDivider.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ import com.orange.ouds.core.theme.value
2828
import com.orange.ouds.core.utilities.OudsPreview
2929
import com.orange.ouds.foundation.utilities.EnumPreviewParameterProvider
3030

31-
//TODO Add DSM link when available
32-
// <a href="https://unified-design-system.orange.com/" class="external" target="_blank">**OUDS Divider design guidelines**</a>
3331
/**
3432
* Dividers are used to visually structure an interface by clearly separating content sections. It helps to improve readability and content organization
3533
* without introducing a strong hierarchy like a heading or a container would.
@@ -39,6 +37,10 @@ import com.orange.ouds.foundation.utilities.EnumPreviewParameterProvider
3937
* The color of the divider can be specified using the [OudsDivider.Color] enum, and the thickness is defined by the current theme's divider border width.
4038
* Note that a divider border width token set to 0 dp will produce a single pixel divider regardless of screen density.
4139
*
40+
* > Design guidelines: [unified-design-system.orange.com](https://unified-design-system.orange.com/472794e18/p/629e1b-divider)
41+
*
42+
* > Design version: 1.0.0
43+
*
4244
* @param modifier [Modifier] applied to the divider.
4345
* @param color The color of the divider, chosen from the [OudsDivider.Color] enum. Default value set to `OudsDivider.Color.Default`.
4446
*
@@ -52,8 +54,6 @@ fun OudsHorizontalDivider(
5254
HorizontalDivider(modifier = modifier, color = color.value, thickness = OudsTheme.componentsTokens.divider.borderWidth.value)
5355
}
5456

55-
//TODO Add DSM link when available
56-
// <a href="https://unified-design-system.orange.com/" class="external" target="_blank">**OUDS Divider design guidelines**</a>
5757
/**
5858
* Dividers are used to visually structure an interface by clearly separating content sections. It helps to improve readability and content organization
5959
* without introducing a strong hierarchy like a heading or a container would.
@@ -63,6 +63,10 @@ fun OudsHorizontalDivider(
6363
* The color of the divider can be specified using the [OudsDivider.Color] enum, and the thickness is defined by the current theme's divider border width.
6464
* Note that a divider border width token set to 0 dp will produce a single pixel divider regardless of screen density.
6565
*
66+
* > Design guidelines: [unified-design-system.orange.com](https://unified-design-system.orange.com/472794e18/p/629e1b-divider)
67+
*
68+
* > Design version: 1.0.0
69+
*
6670
* @param modifier [Modifier] applied to the divider.
6771
* @param color The color of the divider, chosen from the [OudsDivider.Color] enum. Default value set to `OudsDivider.Color.Default`.
6872
*

0 commit comments

Comments
 (0)