Make it possible to link to individual configuration properties
Closes gh-16267
This commit is contained in:
@@ -43,8 +43,9 @@ class CompoundConfigurationTableEntry extends ConfigurationTableEntry {
|
||||
|
||||
@Override
|
||||
void write(AsciidocBuilder builder) {
|
||||
builder.append("|");
|
||||
builder.append("|[[" + this.key + "]]<<" + this.key + ",");
|
||||
this.configurationKeys.forEach(builder::appendKey);
|
||||
builder.appendln(">>");
|
||||
builder.newLine().appendln("|").appendln("|+++", this.description, "+++");
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,11 @@ class SingleConfigurationTableEntry extends ConfigurationTableEntry {
|
||||
|
||||
private final String defaultValue;
|
||||
|
||||
private final String anchor;
|
||||
|
||||
SingleConfigurationTableEntry(ConfigurationProperty property) {
|
||||
this.key = property.getName();
|
||||
this.anchor = this.key;
|
||||
if (property.getType() != null && property.getType().startsWith("java.util.Map")) {
|
||||
this.key += ".*";
|
||||
}
|
||||
@@ -52,7 +55,7 @@ class SingleConfigurationTableEntry extends ConfigurationTableEntry {
|
||||
|
||||
@Override
|
||||
void write(AsciidocBuilder builder) {
|
||||
builder.appendln("|`+", this.key, "+`");
|
||||
builder.appendln("|[[" + this.anchor + "]]<<" + this.anchor + ",`+", this.key, "+`>>");
|
||||
writeDefaultValue(builder);
|
||||
writeDescription(builder);
|
||||
builder.appendln();
|
||||
|
||||
@@ -39,9 +39,9 @@ public class CompoundConfigurationTableEntryTests {
|
||||
entry.addConfigurationKeys(firstProp, secondProp, thirdProp);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo(
|
||||
"|`+spring.test.first+` +" + NEWLINE + "`+spring.test.second+` +" + NEWLINE + "`+spring.test.third+` +"
|
||||
+ NEWLINE + NEWLINE + "|" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
assertThat(builder.toString()).isEqualTo("|[[spring.test]]<<spring.test,`+spring.test.first+` +" + NEWLINE
|
||||
+ "`+spring.test.second+` +" + NEWLINE + "`+spring.test.third+` +" + NEWLINE + ">>" + NEWLINE + NEWLINE
|
||||
+ "|" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,10 +39,11 @@ public class ConfigurationTableTests {
|
||||
table.addEntry(new SingleConfigurationTableEntry(first));
|
||||
table.addEntry(new SingleConfigurationTableEntry(second));
|
||||
assertThat(table.toAsciidocTable()).isEqualTo("[cols=\"1,1,2\", options=\"header\"]" + NEWLINE + "|==="
|
||||
+ NEWLINE + "|Key|Default Value|Description" + NEWLINE + NEWLINE + "|`+spring.test.other+`" + NEWLINE
|
||||
+ "|`+other value+`" + NEWLINE + "|+++This is another description.+++" + NEWLINE + NEWLINE
|
||||
+ "|`+spring.test.prop+`" + NEWLINE + "|`+something+`" + NEWLINE + "|+++This is a description.+++"
|
||||
+ NEWLINE + NEWLINE + "|===" + NEWLINE);
|
||||
+ NEWLINE + "|Key|Default Value|Description" + NEWLINE + NEWLINE
|
||||
+ "|[[spring.test.other]]<<spring.test.other,`+spring.test.other+`>>" + NEWLINE + "|`+other value+`"
|
||||
+ NEWLINE + "|+++This is another description.+++" + NEWLINE + NEWLINE
|
||||
+ "|[[spring.test.prop]]<<spring.test.prop,`+spring.test.prop+`>>" + NEWLINE + "|`+something+`"
|
||||
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + NEWLINE + "|===" + NEWLINE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ public class SingleConfigurationTableEntryTests {
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|`+something+`" + NEWLINE
|
||||
+ "|+++This is a description.+++" + NEWLINE);
|
||||
assertThat(builder.toString()).isEqualTo("|[[spring.test.prop]]<<spring.test.prop,`+spring.test.prop+`>>"
|
||||
+ NEWLINE + "|`+something+`" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -47,8 +47,8 @@ public class SingleConfigurationTableEntryTests {
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo(
|
||||
"|`+spring.test.prop+`" + NEWLINE + "|" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
assertThat(builder.toString()).isEqualTo("|[[spring.test.prop]]<<spring.test.prop,`+spring.test.prop+`>>"
|
||||
+ NEWLINE + "|" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,8 +58,8 @@ public class SingleConfigurationTableEntryTests {
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|`+first\\|second+`" + NEWLINE
|
||||
+ "|+++This is a description.+++" + NEWLINE);
|
||||
assertThat(builder.toString()).isEqualTo("|[[spring.test.prop]]<<spring.test.prop,`+spring.test.prop+`>>"
|
||||
+ NEWLINE + "|`+first\\|second+`" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,8 +69,8 @@ public class SingleConfigurationTableEntryTests {
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|`+first\\\\second+`" + NEWLINE
|
||||
+ "|+++This is a description.+++" + NEWLINE);
|
||||
assertThat(builder.toString()).isEqualTo("|[[spring.test.prop]]<<spring.test.prop,`+spring.test.prop+`>>"
|
||||
+ NEWLINE + "|`+first\\\\second+`" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,8 +80,8 @@ public class SingleConfigurationTableEntryTests {
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|" + NEWLINE
|
||||
+ "|+++This is a description with a \\| pipe.+++" + NEWLINE);
|
||||
assertThat(builder.toString()).isEqualTo("|[[spring.test.prop]]<<spring.test.prop,`+spring.test.prop+`>>"
|
||||
+ NEWLINE + "|" + NEWLINE + "|+++This is a description with a \\| pipe.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,8 +91,8 @@ public class SingleConfigurationTableEntryTests {
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo(
|
||||
"|`+spring.test.prop.*+`" + NEWLINE + "|" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
assertThat(builder.toString()).isEqualTo("|[[spring.test.prop]]<<spring.test.prop,`+spring.test.prop.*+`>>"
|
||||
+ NEWLINE + "|" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -103,8 +103,9 @@ public class SingleConfigurationTableEntryTests {
|
||||
SingleConfigurationTableEntry entry = new SingleConfigurationTableEntry(property);
|
||||
AsciidocBuilder builder = new AsciidocBuilder();
|
||||
entry.write(builder);
|
||||
assertThat(builder.toString()).isEqualTo("|`+spring.test.prop+`" + NEWLINE + "|`+first," + NEWLINE + "second,"
|
||||
+ NEWLINE + "third+`" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
assertThat(builder.toString()).isEqualTo(
|
||||
"|[[spring.test.prop]]<<spring.test.prop,`+spring.test.prop+`>>" + NEWLINE + "|`+first," + NEWLINE
|
||||
+ "second," + NEWLINE + "third+`" + NEWLINE + "|+++This is a description.+++" + NEWLINE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user