2
2
3
3
import java .text .Normalizer ;
4
4
import java .time .Duration ;
5
+ import java .util .Arrays ;
6
+ import java .util .List ;
7
+ import java .util .Map .Entry ;
5
8
import java .util .Optional ;
6
9
import java .util .stream .Collectors ;
7
10
16
19
import io .quarkus .annotation .processor .documentation .config .util .Types ;
17
20
import io .quarkus .maven .config .doc .GenerateConfigDocMojo .Context ;
18
21
import io .quarkus .maven .config .doc .generator .GenerationReport .ConfigPropertyGenerationViolation ;
22
+ import io .smallrye .config .common .utils .StringUtil ;
19
23
20
24
abstract class AbstractFormatter implements Formatter {
21
25
@@ -112,23 +116,14 @@ public String formatDefaultValue(ConfigProperty configProperty) {
112
116
return null ;
113
117
}
114
118
115
- if (configProperty .isEnum () && enableEnumTooltips ) {
116
- Optional <String > enumConstant = configProperty .getEnumAcceptedValues ().values ().entrySet ().stream ()
117
- .filter (e -> e .getValue ().configValue ().equals (defaultValue ))
118
- .map (e -> e .getKey ())
119
- .findFirst ();
120
-
121
- if (enumConstant .isPresent ()) {
122
- Optional <JavadocElement > javadocElement = javadocRepository .getElement (configProperty .getType (),
123
- enumConstant .get ());
124
-
125
- if (javadocElement .isPresent ()) {
126
- return tooltip (defaultValue , javadocElement .get ().description ());
127
- }
128
- }
119
+ List <String > defaultValues ;
120
+ if (configProperty .isList ()) {
121
+ defaultValues = Arrays .asList (StringUtil .split (defaultValue ));
122
+ } else {
123
+ defaultValues = List .of (defaultValue );
129
124
}
130
125
131
- return "`" + defaultValue + "`" ;
126
+ return defaultValues . stream (). map ( v -> formatSingleDefaultValue ( configProperty , v )). collect ( Collectors . joining ( ", " )) ;
132
127
}
133
128
134
129
@ Override
@@ -240,6 +235,26 @@ public String formatName(Extension extension) {
240
235
return extension .name ();
241
236
}
242
237
238
+ private String formatSingleDefaultValue (ConfigProperty configProperty , String defaultValue ) {
239
+ if (configProperty .isEnum () && enableEnumTooltips ) {
240
+ Optional <String > enumConstant = configProperty .getEnumAcceptedValues ().values ().entrySet ().stream ()
241
+ .filter (e -> e .getValue ().configValue ().equals (defaultValue ))
242
+ .map (Entry ::getKey )
243
+ .findFirst ();
244
+
245
+ if (enumConstant .isPresent ()) {
246
+ Optional <JavadocElement > javadocElement = javadocRepository .getElement (configProperty .getType (),
247
+ enumConstant .get ());
248
+
249
+ if (javadocElement .isPresent ()) {
250
+ return tooltip (defaultValue , javadocElement .get ().description ());
251
+ }
252
+ }
253
+ }
254
+
255
+ return escapeDefaultValue (defaultValue );
256
+ }
257
+
243
258
private static String trimFinalDot (String javadoc ) {
244
259
if (javadoc == null || javadoc .isBlank ()) {
245
260
return null ;
@@ -262,4 +277,6 @@ private static String trimFinalDot(String javadoc) {
262
277
protected abstract String link (String href , String description );
263
278
264
279
protected abstract String tooltip (String value , String javadocDescription );
280
+
281
+ protected abstract String escapeDefaultValue (String defaultValue );
265
282
}
0 commit comments