Skip to content

Commit d138192

Browse files
authored
Merge pull request #51098 from wjglerum/config-doc-default-ascii-doc-attribute
Allow to set default value for config options with AsciiDoc attributes
2 parents adbf1ed + b014c8a commit d138192

File tree

68 files changed

+224
-135
lines changed

Some content is hidden

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

68 files changed

+224
-135
lines changed

build-parent/pom.xml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@
8585
<junit-pioneer.version>2.2.0</junit-pioneer.version>
8686

8787
<!-- Database images for JDBC/Reactive/Hibernate tests and devservices -->
88-
<postgres.image>docker.io/postgres:17</postgres.image>
89-
<mariadb.image>docker.io/mariadb:10.11</mariadb.image>
88+
<postgres.image>docker.io/library/postgres:17</postgres.image>
89+
<mariadb.image>docker.io/library/mariadb:10.11</mariadb.image>
9090
<db2.image>icr.io/db2_community/db2:12.1.0.0</db2.image>
9191
<mssql.image>mcr.microsoft.com/mssql/server:2022-latest</mssql.image>
92-
<mysql.image>docker.io/mysql:8.4</mysql.image>
92+
<mysql.image>docker.io/library/mysql:8.4</mysql.image>
9393
<oracle.image>docker.io/gvenzl/oracle-free:23-slim-faststart</oracle.image>
94-
<mongo.image>docker.io/mongo:7.0</mongo.image>
94+
<mongo.image>docker.io/library/mongo:7.0</mongo.image>
9595

9696
<!-- Align various dependencies that are not really part of the bom-->
9797
<junit4.version>4.13.2</junit4.version>
@@ -110,6 +110,16 @@
110110
<!-- Artemis test dependencies -->
111111
<artemis.version>2.44.0</artemis.version>
112112

113+
<!-- Dev Services Images -->
114+
<!-- TODO switch to apache/activemq-artemis to match the artemis version-->
115+
<amqp.image>quay.io/artemiscloud/activemq-artemis-broker:1.0.25</amqp.image>
116+
<apicurio-registry.image>quay.io/apicurio/apicurio-registry-mem:2.6.13.Final</apicurio-registry.image>
117+
<narayana-lra.image>quay.io/jbosstm/lra-coordinator:latest</narayana-lra.image>
118+
<rabbitmq.image>docker.io/library/rabbitmq:3.12-management</rabbitmq.image>
119+
<pulsar.image>docker.io/apachepulsar/pulsar:3.2.4</pulsar.image>
120+
<redis.image>docker.io/library/redis:7</redis.image>
121+
<infinispan.image>quay.io/infinispan/server:latest</infinispan.image>
122+
113123
<!-- Code Coverage Properties-->
114124
<jacoco.agent.argLine></jacoco.agent.argLine>
115125

core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/discovery/DiscoveryConfigProperty.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class DiscoveryConfigProperty {
1313
private final SourceElementType sourceElementType;
1414
private final String defaultValue;
1515
private final String defaultValueForDoc;
16+
private final boolean escapeDefaultValueForDoc;
1617
private final Deprecation deprecation;
1718
private final String mapKey;
1819
private final boolean unnamedMapKey;
@@ -24,8 +25,8 @@ public class DiscoveryConfigProperty {
2425

2526
public DiscoveryConfigProperty(String path, String sourceType, String sourceElementName,
2627
SourceElementType sourceElementType,
27-
String defaultValue,
28-
String defaultValueForDoc, Deprecation deprecation, String mapKey, boolean unnamedMapKey,
28+
String defaultValue, String defaultValueForDoc, boolean escapeDefaultValueForDoc,
29+
Deprecation deprecation, String mapKey, boolean unnamedMapKey,
2930
ResolvedType type, boolean converted, boolean enforceHyphenateEnumValue,
3031
boolean section, boolean sectionGenerated) {
3132
this.path = path;
@@ -34,6 +35,7 @@ public DiscoveryConfigProperty(String path, String sourceType, String sourceElem
3435
this.sourceElementType = sourceElementType;
3536
this.defaultValue = defaultValue;
3637
this.defaultValueForDoc = defaultValueForDoc;
38+
this.escapeDefaultValueForDoc = escapeDefaultValueForDoc;
3739
this.deprecation = deprecation;
3840
this.mapKey = mapKey;
3941
this.unnamedMapKey = unnamedMapKey;
@@ -68,6 +70,10 @@ public String getDefaultValueForDoc() {
6870
return defaultValueForDoc;
6971
}
7072

73+
public boolean isEscapeDefaultValueForDoc() {
74+
return escapeDefaultValueForDoc;
75+
}
76+
7177
public Deprecation getDeprecation() {
7278
return deprecation;
7379
}
@@ -150,6 +156,7 @@ public static class Builder {
150156
private final ResolvedType type;
151157
private String defaultValue;
152158
private String defaultValueForDoc;
159+
private boolean escapeDefaultValueForDoc = true;
153160
private Deprecation deprecation;
154161
private String mapKey;
155162
private boolean unnamedMapKey = false;
@@ -180,6 +187,11 @@ public Builder defaultValueForDoc(String defaultValueForDoc) {
180187
return this;
181188
}
182189

190+
public Builder escapeDefaultValueForDoc(boolean escapeDefaultValueForDoc) {
191+
this.escapeDefaultValueForDoc = escapeDefaultValueForDoc;
192+
return this;
193+
}
194+
183195
public Builder deprecated(String since, String replacement, String reason) {
184196
this.deprecation = new Deprecation(since, replacement);
185197
return this;
@@ -220,7 +232,7 @@ public DiscoveryConfigProperty build() {
220232
}
221233

222234
return new DiscoveryConfigProperty(name, sourceType, sourceElementName, sourceElementType, defaultValue,
223-
defaultValueForDoc,
235+
defaultValueForDoc, escapeDefaultValueForDoc,
224236
deprecation, mapKey, unnamedMapKey, type, converted, enforceHyphenateEnumValue, section, sectionGenerated);
225237
}
226238
}

core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/model/ConfigProperty.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public final class ConfigProperty extends AbstractConfigItem {
2727
private final EnumAcceptedValues enumAcceptedValues;
2828

2929
private final String defaultValue;
30+
private final boolean escapeDefaultValue;
3031

3132
private final String javadocSiteLink;
3233

@@ -35,7 +36,7 @@ public ConfigProperty(ConfigPhase phase, String sourceType, String sourceElement
3536
boolean list, boolean optional, boolean secret,
3637
String mapKey, boolean unnamedMapKey, boolean withinMap, boolean converted, @JsonProperty("enum") boolean isEnum,
3738
EnumAcceptedValues enumAcceptedValues,
38-
String defaultValue, String javadocSiteLink,
39+
String defaultValue, boolean escapeDefaultValue, String javadocSiteLink,
3940
Deprecation deprecation) {
4041
super(sourceType, sourceElementName, sourceElementType, path, type, deprecation);
4142
this.phase = phase;
@@ -52,6 +53,7 @@ public ConfigProperty(ConfigPhase phase, String sourceType, String sourceElement
5253
this.isEnum = isEnum;
5354
this.enumAcceptedValues = enumAcceptedValues;
5455
this.defaultValue = defaultValue;
56+
this.escapeDefaultValue = escapeDefaultValue;
5557
this.javadocSiteLink = javadocSiteLink;
5658
}
5759

@@ -121,6 +123,10 @@ public String getDefaultValue() {
121123
return defaultValue;
122124
}
123125

126+
public boolean isEscapeDefaultValue() {
127+
return escapeDefaultValue;
128+
}
129+
124130
public String getJavadocSiteLink() {
125131
return javadocSiteLink;
126132
}

core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/resolver/ConfigResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private void resolveProperty(ConfigRoot configRoot, Map<String, ConfigSection> e
213213
discoveryConfigProperty.isUnnamedMapKey(), context.isWithinMap(),
214214
discoveryConfigProperty.isConverted(),
215215
discoveryConfigProperty.getType().isEnum(),
216-
enumAcceptedValues, defaultValue,
216+
enumAcceptedValues, defaultValue, discoveryConfigProperty.isEscapeDefaultValueForDoc(),
217217
JavadocUtil.getJavadocSiteLink(typeBinaryName),
218218
deprecation);
219219
context.getItemCollection().addItem(configProperty);

core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/scanner/ConfigMappingListener.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,12 @@ public void onEnclosedMethod(DiscoveryRootElement discoveryRootElement, TypeElem
152152

153153
AnnotationMirror configDocDefaultAnnotation = methodAnnotations.get(Types.ANNOTATION_CONFIG_DOC_DEFAULT);
154154
if (configDocDefaultAnnotation != null) {
155-
builder.defaultValueForDoc(
156-
configDocDefaultAnnotation.getElementValues().values().iterator().next().getValue().toString());
155+
String value = (String) utils.element().getAnnotationValues(configDocDefaultAnnotation).get("value");
156+
builder.defaultValueForDoc(value);
157+
Boolean escape = (Boolean) utils.element().getAnnotationValues(configDocDefaultAnnotation).get("escape");
158+
if (escape != null) {
159+
builder.escapeDefaultValueForDoc(escape);
160+
}
157161
}
158162

159163
if (resolvedType.isMap()) {

core/runtime/src/main/java/io/quarkus/runtime/annotations/ConfigDocDefault.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@
2222
public @interface ConfigDocDefault {
2323

2424
String value();
25+
26+
boolean escape() default true;
2527
}

devtools/config-doc-maven-plugin/src/main/java/io/quarkus/maven/config/doc/generator/AbstractFormatter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,11 @@ private String formatSingleDefaultValue(ConfigProperty configProperty, String de
274274
}
275275
}
276276

277-
return escapeDefaultValue(defaultValue);
277+
if (configProperty.isEscapeDefaultValue()) {
278+
return escapeDefaultValue(defaultValue);
279+
} else {
280+
return defaultValue;
281+
}
278282
}
279283

280284
private static String trimFinalDot(String javadoc) {

docs/src/main/asciidoc/_attributes.adoc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,27 @@
1111
:mandrel-flavor: ${mandrel.image-tag-for-documentation}
1212
:surefire-version: ${version.surefire.plugin}
1313
:gradle-version: ${gradle-wrapper.version}
14+
:db2-image: ${db2.image}
15+
:mariadb-image: ${mariadb.image}
16+
:mssql-image: ${mssql.image}
17+
:oracle-image: ${oracle.image}
18+
:postgres-image: ${postgres.image}
1419
:elasticsearch-version: ${elasticsearch-server.version}
1520
:elasticsearch-image: ${elasticsearch.image}
1621
:opensearch-image: ${opensearch.image}
1722
:infinispan-version: ${infinispan.version}
1823
:infinispan-protostream-version: ${infinispan.protostream.version}
1924
:logstash-image: ${logstash.image}
2025
:kibana-image: ${kibana.image}
21-
:keycloak-docker-image: ${keycloak.docker.image}
26+
:keycloak-image: ${keycloak.docker.image}
27+
:amqp-image: ${amqp.image}
28+
:apicurio-registry-image: ${apicurio-registry.image}
29+
:narayana-lra-image: ${narayana-lra.image}
30+
:mongo-image: ${mongo.image}
31+
:rabbitmq-image: ${rabbitmq.image}
32+
:pulsar-image: ${pulsar.image}
33+
:redis-image: ${redis.image}
34+
:infinispan-image: ${infinispan.image}
2235
:jandex-version: ${jandex.version}
2336
:jandex-gradle-plugin-version: ${jandex-gradle-plugin.version}
2437
:kotlin-version: ${kotlin.version}

docs/src/main/asciidoc/amqp-dev-services.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ You can set the port by configuring the `quarkus.amqp.devservices.port` property
5050
Dev Services for AMQP uses https://quay.io/repository/artemiscloud/activemq-artemis-broker[activemq-artemis-broker] images.
5151
You can configure the image and version using the `quarkus.amqp.devservices.image-name` property:
5252

53-
[source, properties]
53+
[source, properties, subs=attributes+]
5454
----
55-
quarkus.amqp.devservices.image-name=quay.io/artemiscloud/activemq-artemis-broker:latest
55+
quarkus.amqp.devservices.image-name={amqp-image}
5656
----
5757

5858
IMPORTANT: The configured image must be _compatible_ with the `activemq-artemis-broker` one.
@@ -65,12 +65,12 @@ The ports 5672 and 8161 (web console) are exposed.
6565
Dev Services for AMQP supports xref:compose-dev-services.adoc[Compose Dev Services].
6666
It relies on a `compose-devservices.yml`, such as:
6767

68-
[source,yaml]
68+
[source,yaml,subs=attributes+]
6969
----
7070
name: <application name>
7171
services:
7272
artemis:
73-
image: quay.io/artemiscloud/activemq-artemis-broker:1.0.28
73+
image: {amqp-image}
7474
ports:
7575
- "5672"
7676
- "8161"

docs/src/main/asciidoc/amqp.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,14 @@ Open `http://localhost:8080/quotes.html` in your browser and request some quotes
366366
When not running in dev or test mode, you will need to start your AMQP broker.
367367
You can follow the instructions from the https://activemq.apache.org/components/artemis/documentation/latest/using-server.html[Apache ActiveMQ Artemis website] or create a `docker-compose.yaml` file with the following content:
368368

369-
[source, yaml]
369+
[source, yaml ,subs=attributes+]
370370
----
371371
version: '2'
372372
373373
services:
374374
375375
artemis:
376-
image: quay.io/artemiscloud/activemq-artemis-broker:1.0.25
376+
image: {amqp-image}
377377
ports:
378378
- "8161:8161"
379379
- "61616:61616"

0 commit comments

Comments
 (0)