22
33import java .text .Normalizer ;
44import java .time .Duration ;
5+ import java .util .Arrays ;
6+ import java .util .List ;
7+ import java .util .Map .Entry ;
58import java .util .Optional ;
69import java .util .stream .Collectors ;
710
1619import io .quarkus .annotation .processor .documentation .config .util .Types ;
1720import io .quarkus .maven .config .doc .GenerateConfigDocMojo .Context ;
1821import io .quarkus .maven .config .doc .generator .GenerationReport .ConfigPropertyGenerationViolation ;
22+ import io .smallrye .config .common .utils .StringUtil ;
1923
2024abstract class AbstractFormatter implements Formatter {
2125
@@ -112,23 +116,14 @@ public String formatDefaultValue(ConfigProperty configProperty) {
112116 return null ;
113117 }
114118
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 );
129124 }
130125
131- return "`" + defaultValue + "`" ;
126+ return defaultValues . stream (). map ( v -> formatSingleDefaultValue ( configProperty , v )). collect ( Collectors . joining ( ", " )) ;
132127 }
133128
134129 @ Override
@@ -240,6 +235,26 @@ public String formatName(Extension extension) {
240235 return extension .name ();
241236 }
242237
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+
243258 private static String trimFinalDot (String javadoc ) {
244259 if (javadoc == null || javadoc .isBlank ()) {
245260 return null ;
@@ -262,4 +277,6 @@ private static String trimFinalDot(String javadoc) {
262277 protected abstract String link (String href , String description );
263278
264279 protected abstract String tooltip (String value , String javadocDescription );
280+
281+ protected abstract String escapeDefaultValue (String defaultValue );
265282}
0 commit comments