Skip to content

Commit 16fca97

Browse files
committed
Add KDoc for annotated string related classes
1 parent 33c1634 commit 16fca97

7 files changed

Lines changed: 613 additions & 2 deletions

File tree

core/src/main/java/com/orange/ouds/core/component/common/text/OudsAnnotatedAlertMessageBulletListLabel.kt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,63 @@ package com.orange.ouds.core.component.common.text
1414

1515
import androidx.compose.ui.text.AnnotatedString
1616

17+
/**
18+
* An annotated string for bullet list items within alert messages.
19+
*
20+
* This class supports both strong (bold/emphasized) text and clickable links to create
21+
* rich, interactive bullet points in alert messages. It is used by [com.orange.ouds.core.component.OudsAlertMessage] component.
22+
*
23+
* Use [buildOudsAnnotatedAlertMessageBulletListLabel] to create instances:
24+
* ```
25+
* val bulletList = listOf(
26+
* buildOudsAnnotatedAlertMessageBulletListLabel {
27+
* withStrong { append("Data security:") }
28+
* append(" Your information will be encrypted")
29+
* },
30+
* buildOudsAnnotatedAlertMessageBulletListLabel {
31+
* append("For more information, visit our ")
32+
* withLink(OudsLinkAnnotation.Url("https://help.example.com")) {
33+
* append("help center")
34+
* }
35+
* }
36+
* )
37+
*
38+
* OudsAlertMessage(
39+
* label = "Important information",
40+
* bulletList = bulletList
41+
* )
42+
* ```
43+
*/
1744
class OudsAnnotatedAlertMessageBulletListLabel internal constructor(annotatedString: AnnotatedString) :
1845
OudsAnnotatedString<OudsAnnotatedAlertMessageBulletListLabel>(annotatedString) {
1946

47+
/**
48+
* Builder for creating [OudsAnnotatedAlertMessageBulletListLabel] with strong text and link formatting.
49+
*
50+
* Supports both strong text and link annotations through [addStrong], [pushStrong],
51+
* [addLink], and [pushLink] methods, or more conveniently through the [withStrong]
52+
* and [withLink] DSL helpers.
53+
*
54+
* @param capacity Initial capacity for the underlying string builder. Defaults to 16.
55+
*/
2056
class Builder(capacity: Int = 16) :
2157
OudsAnnotatedString.Builder<OudsAnnotatedAlertMessageBulletListLabel>(capacity, OudsAnnotatedAlertMessageBulletListLabel::class.java),
2258
StrongBuilder, LinkBuilder {
2359

60+
/**
61+
* Creates a builder initialized with plain text.
62+
*
63+
* @param text The initial text content.
64+
*/
2465
constructor(text: String) : this() {
2566
append(text)
2667
}
2768

69+
/**
70+
* Creates a builder initialized with an existing annotated helper text.
71+
*
72+
* @param text The initial annotated text to copy.
73+
*/
2874
constructor(text: OudsAnnotatedHelperText) : this() {
2975
append(text)
3076
}
@@ -41,6 +87,20 @@ class OudsAnnotatedAlertMessageBulletListLabel internal constructor(annotatedStr
4187
}
4288
}
4389

90+
/**
91+
* Creates an [OudsAnnotatedAlertMessageBulletListLabel] using a builder DSL.
92+
*
93+
* Example:
94+
* ```
95+
* val bullet = buildOudsAnnotatedAlertMessageBulletListLabel {
96+
* withStrong { append("Privacy policy:") }
97+
* append(" We respect your privacy and will not share your data")
98+
* }
99+
* ```
100+
*
101+
* @param builder Lambda with receiver for building the annotated string.
102+
* @return The constructed annotated alert message bullet list label.
103+
*/
44104
fun buildOudsAnnotatedAlertMessageBulletListLabel(builder: (OudsAnnotatedAlertMessageBulletListLabel.Builder).() -> Unit): OudsAnnotatedAlertMessageBulletListLabel {
45105
return buildOudsAnnotatedString<OudsAnnotatedAlertMessageBulletListLabel, OudsAnnotatedAlertMessageBulletListLabel.Builder>(builder)
46106
}

core/src/main/java/com/orange/ouds/core/component/common/text/OudsAnnotatedAlertMessageDescription.kt

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,60 @@ package com.orange.ouds.core.component.common.text
1414

1515
import androidx.compose.ui.text.AnnotatedString
1616

17+
/**
18+
* An annotated string for alert message descriptions.
19+
*
20+
* This class supports both strong (bold/emphasized) text and clickable links to create
21+
* rich, informative alert descriptions. It is used by [com.orange.ouds.core.component.OudsAlertMessage] component.
22+
*
23+
* Use [buildOudsAnnotatedAlertMessageDescription] to create instances:
24+
* ```
25+
* val description = buildOudsAnnotatedAlertMessageDescription {
26+
* withStrong { append("Important:") }
27+
* append(" Please read the ")
28+
* withLink(OudsLinkAnnotation.Url("https://example.com/terms")) {
29+
* append("terms and conditions")
30+
* }
31+
* append(" carefully before proceeding")
32+
* }
33+
*
34+
* OudsAlertMessage(
35+
* label = "Before you continue",
36+
* description = description,
37+
* status = OudsAlertMessageStatus.Warning
38+
* )
39+
* ```
40+
*/
1741
class OudsAnnotatedAlertMessageDescription internal constructor(annotatedString: AnnotatedString) :
1842
OudsAnnotatedString<OudsAnnotatedAlertMessageDescription>(annotatedString) {
1943

44+
/**
45+
* Builder for creating [OudsAnnotatedAlertMessageDescription] with strong text and link formatting.
46+
*
47+
* Supports both strong text and link annotations through [addStrong], [pushStrong],
48+
* [addLink], and [pushLink] methods, or more conveniently through the [withStrong]
49+
* and [withLink] DSL helpers.
50+
*
51+
* @param capacity Initial capacity for the underlying string builder. Defaults to 16.
52+
*/
2053
class Builder(capacity: Int = 16) :
2154
OudsAnnotatedString.Builder<OudsAnnotatedAlertMessageDescription>(capacity, OudsAnnotatedAlertMessageDescription::class.java),
2255
StrongBuilder, LinkBuilder {
2356

57+
/**
58+
* Creates a builder initialized with plain text.
59+
*
60+
* @param text The initial text content.
61+
*/
2462
constructor(text: String) : this() {
2563
append(text)
2664
}
2765

66+
/**
67+
* Creates a builder initialized with an existing annotated helper text.
68+
*
69+
* @param text The initial annotated text to copy.
70+
*/
2871
constructor(text: OudsAnnotatedHelperText) : this() {
2972
append(text)
3073
}
@@ -41,6 +84,24 @@ class OudsAnnotatedAlertMessageDescription internal constructor(annotatedString:
4184
}
4285
}
4386

87+
/**
88+
* Creates an [OudsAnnotatedAlertMessageDescription] using a builder DSL.
89+
*
90+
* Example:
91+
* ```
92+
* val description = buildOudsAnnotatedAlertMessageDescription {
93+
* withStrong { append("Note:") }
94+
* append(" Your data will be encrypted and stored securely. ")
95+
* append("For more details, see our ")
96+
* withLink(OudsLinkAnnotation.Url("https://example.com/privacy")) {
97+
* append("privacy policy")
98+
* }
99+
* }
100+
* ```
101+
*
102+
* @param builder Lambda with receiver for building the annotated string.
103+
* @return The constructed annotated alert message description.
104+
*/
44105
fun buildOudsAnnotatedAlertMessageDescription(builder: (OudsAnnotatedAlertMessageDescription.Builder).() -> Unit): OudsAnnotatedAlertMessageDescription {
45106
return buildOudsAnnotatedString<OudsAnnotatedAlertMessageDescription, OudsAnnotatedAlertMessageDescription.Builder>(builder)
46107
}

core/src/main/java/com/orange/ouds/core/component/common/text/OudsAnnotatedBulletListLabel.kt

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,58 @@ package com.orange.ouds.core.component.common.text
1414

1515
import androidx.compose.ui.text.AnnotatedString
1616

17+
/**
18+
* An annotated string for bullet list item labels.
19+
*
20+
* This class supports both strong (bold/emphasized) text and clickable links to create
21+
* rich, interactive bullet list items. It is used by [com.orange.ouds.core.component.OudsBulletList] component.
22+
*
23+
* Use [buildOudsAnnotatedBulletListLabel] to create instances:
24+
* ```
25+
* OudsBulletList {
26+
* item(label = buildOudsAnnotatedBulletListLabel {
27+
* withStrong { append("Important:") }
28+
* append(" Read this carefully")
29+
* })
30+
* item(label = buildOudsAnnotatedBulletListLabel {
31+
* append("For more information, visit our ")
32+
* withLink(OudsLinkAnnotation.Url("https://help.example.com")) {
33+
* append("help center")
34+
* }
35+
* })
36+
* }
37+
* ```
38+
*/
1739
class OudsAnnotatedBulletListLabel internal constructor(annotatedString: AnnotatedString) :
1840
OudsAnnotatedString<OudsAnnotatedBulletListLabel>(annotatedString) {
1941

42+
/**
43+
* Builder for creating [OudsAnnotatedBulletListLabel] with strong text and link formatting.
44+
*
45+
* Supports both strong text and link annotations through [addStrong], [pushStrong],
46+
* [addLink], and [pushLink] methods, or more conveniently through the [withStrong]
47+
* and [withLink] DSL helpers.
48+
*
49+
* @param capacity Initial capacity for the underlying string builder. Defaults to 16.
50+
*/
2051
class Builder(capacity: Int = 16) :
2152
OudsAnnotatedString.Builder<OudsAnnotatedBulletListLabel>(capacity, OudsAnnotatedBulletListLabel::class.java),
2253
StrongBuilder, LinkBuilder {
2354

55+
/**
56+
* Creates a builder initialized with plain text.
57+
*
58+
* @param text The initial text content.
59+
*/
2460
constructor(text: String) : this() {
2561
append(text)
2662
}
2763

64+
/**
65+
* Creates a builder initialized with an existing annotated helper text.
66+
*
67+
* @param text The initial annotated text to copy.
68+
*/
2869
constructor(text: OudsAnnotatedHelperText) : this() {
2970
append(text)
3071
}
@@ -41,6 +82,22 @@ class OudsAnnotatedBulletListLabel internal constructor(annotatedString: Annotat
4182
}
4283
}
4384

85+
/**
86+
* Creates an [OudsAnnotatedBulletListLabel] using a builder DSL.
87+
*
88+
* Example:
89+
* ```
90+
* val label = buildOudsAnnotatedBulletListLabel {
91+
* append("Product details available on our ")
92+
* withLink(OudsLinkAnnotation.Url("https://example.com/products")) {
93+
* append("website")
94+
* }
95+
* }
96+
* ```
97+
*
98+
* @param builder Lambda with receiver for building the annotated string.
99+
* @return The constructed annotated bullet list label.
100+
*/
44101
fun buildOudsAnnotatedBulletListLabel(builder: (OudsAnnotatedBulletListLabel.Builder).() -> Unit): OudsAnnotatedBulletListLabel {
45102
return buildOudsAnnotatedString<OudsAnnotatedBulletListLabel, OudsAnnotatedBulletListLabel.Builder>(builder)
46103
}

core/src/main/java/com/orange/ouds/core/component/common/text/OudsAnnotatedErrorMessage.kt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,56 @@ package com.orange.ouds.core.component.common.text
1414

1515
import androidx.compose.ui.text.AnnotatedString
1616

17+
/**
18+
* An annotated string for error messages in OUDS components.
19+
*
20+
* This class supports strong (bold/emphasized) text formatting to highlight critical
21+
* information in error messages. It is used by components like [com.orange.ouds.core.component.OudsTextInput],
22+
* [com.orange.ouds.core.component.OudsTextArea], [com.orange.ouds.core.component.OudsPasswordInput], [com.orange.ouds.core.component.OudsPinCodeInput], [com.orange.ouds.core.component.OudsCheckboxItem],
23+
* [com.orange.ouds.core.component.OudsRadioButtonItem], and [com.orange.ouds.core.component.OudsSwitchItem] through the [com.orange.ouds.core.component.common.OudsError] class.
24+
*
25+
* Use [buildOudsAnnotatedErrorMessage] to create instances:
26+
* ```
27+
* val errorMessage = buildOudsAnnotatedErrorMessage {
28+
* append("This field ")
29+
* withStrong { append("cannot") }
30+
* append(" be empty")
31+
* }
32+
*
33+
* OudsTextInput(
34+
* textFieldState = rememberTextFieldState(),
35+
* label = "Email",
36+
* error = OudsError(annotatedMessage = errorMessage)
37+
* )
38+
* ```
39+
*/
1740
class OudsAnnotatedErrorMessage internal constructor(annotatedString: AnnotatedString) : OudsAnnotatedString<OudsAnnotatedErrorMessage>(annotatedString) {
1841

42+
/**
43+
* Builder for creating [OudsAnnotatedErrorMessage] with strong text formatting.
44+
*
45+
* Supports strong text annotation through [addStrong] and [pushStrong] methods,
46+
* or more conveniently through the [withStrong] DSL helper.
47+
*
48+
* @param capacity Initial capacity for the underlying string builder. Defaults to 16.
49+
*/
1950
class Builder(capacity: Int = 16) : OudsAnnotatedString.Builder<OudsAnnotatedErrorMessage>(capacity, OudsAnnotatedErrorMessage::class.java),
2051
StrongBuilder {
2152

53+
/**
54+
* Creates a builder initialized with plain text.
55+
*
56+
* @param text The initial text content.
57+
*/
2258
constructor(text: String) : this() {
2359
append(text)
2460
}
2561

62+
/**
63+
* Creates a builder initialized with an existing annotated error message.
64+
*
65+
* @param text The initial annotated text to copy.
66+
*/
2667
constructor(text: OudsAnnotatedErrorMessage) : this() {
2768
append(text)
2869
}
@@ -33,6 +74,20 @@ class OudsAnnotatedErrorMessage internal constructor(annotatedString: AnnotatedS
3374
}
3475
}
3576

77+
/**
78+
* Creates an [OudsAnnotatedErrorMessage] using a builder DSL.
79+
*
80+
* Example:
81+
* ```
82+
* val errorMessage = buildOudsAnnotatedErrorMessage {
83+
* append("The code you entered is ")
84+
* withStrong { append("incorrect") }
85+
* }
86+
* ```
87+
*
88+
* @param builder Lambda with receiver for building the annotated string.
89+
* @return The constructed annotated error message.
90+
*/
3691
fun buildOudsAnnotatedErrorMessage(builder: (OudsAnnotatedErrorMessage.Builder).() -> Unit): OudsAnnotatedErrorMessage {
3792
return buildOudsAnnotatedString<OudsAnnotatedErrorMessage, OudsAnnotatedErrorMessage.Builder>(builder)
3893
}

0 commit comments

Comments
 (0)