Use xref for documentation links
Closes gh-33745
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,6 +24,7 @@ import java.util.TreeSet;
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Phillip Webb
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
class CompoundRow extends Row {
|
||||
|
||||
@@ -45,9 +46,9 @@ class CompoundRow extends Row {
|
||||
void write(Asciidoc asciidoc) {
|
||||
asciidoc.append("|");
|
||||
asciidoc.append("[[" + getAnchor() + "]]");
|
||||
asciidoc.append("<<" + getAnchor() + ",");
|
||||
asciidoc.append("xref:#" + getAnchor() + "[");
|
||||
this.propertyNames.forEach(asciidoc::appendWithHardLineBreaks);
|
||||
asciidoc.appendln(">>");
|
||||
asciidoc.appendln("]");
|
||||
asciidoc.appendln("|+++", this.description, "+++");
|
||||
asciidoc.appendln("|");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,6 +24,7 @@ import java.util.stream.Collectors;
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Phillip Webb
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
class SingleRow extends Row {
|
||||
|
||||
@@ -56,7 +57,7 @@ class SingleRow extends Row {
|
||||
void write(Asciidoc asciidoc) {
|
||||
asciidoc.append("|");
|
||||
asciidoc.append("[[" + getAnchor() + "]]");
|
||||
asciidoc.appendln("<<" + getAnchor() + ",`+", this.displayName, "+`>>");
|
||||
asciidoc.appendln("xref:#" + getAnchor() + "[`+", this.displayName, "+`]");
|
||||
writeDescription(asciidoc);
|
||||
writeDefaultValue(asciidoc);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class DocumentPluginGoals extends DefaultTask {
|
||||
writer.println();
|
||||
for (Parameter parameter : parameters) {
|
||||
String name = parameter.getName();
|
||||
writer.printf("| <<%s.%s,%s>>%n", detailsSectionId, parameterId(name), name);
|
||||
writer.printf("| xref:#%s.%s[%s]%n", detailsSectionId, parameterId(name), name);
|
||||
writer.printf("| `%s`%n", typeNameToJavadocLink(shortTypeName(parameter.getType()), parameter.getType()));
|
||||
String defaultValue = parameter.getDefaultValue();
|
||||
if (defaultValue != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -128,7 +128,7 @@ public class DocumentStarters extends DefaultTask {
|
||||
}
|
||||
|
||||
private String addStarterCrossLinks(String input) {
|
||||
return input.replaceAll("(spring-boot-starter[A-Za-z-]*)", "<<$1,`$1`>>");
|
||||
return input.replaceAll("(spring-boot-starter[A-Za-z-]*)", "xref:#$1[`$1`]");
|
||||
}
|
||||
|
||||
private static final class Starter implements Comparable<Starter> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* Tests for {@link CompoundRow}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
class CompoundRowTests {
|
||||
|
||||
@@ -39,8 +40,8 @@ class CompoundRowTests {
|
||||
row.addProperty(new ConfigurationProperty("spring.test.third", "java.lang.String"));
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test]]<<my.spring.test,`+spring.test.first+` +" + NEWLINE
|
||||
+ "`+spring.test.second+` +" + NEWLINE + "`+spring.test.third+` +" + NEWLINE + ">>" + NEWLINE
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test]]xref:#my.spring.test[`+spring.test.first+` +" + NEWLINE
|
||||
+ "`+spring.test.second+` +" + NEWLINE + "`+spring.test.third+` +" + NEWLINE + "]" + NEWLINE
|
||||
+ "|+++This is a description.+++" + NEWLINE + "|" + NEWLINE);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* Tests for {@link SingleRow}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
class SingleRowTests {
|
||||
|
||||
@@ -38,7 +39,7 @@ class SingleRowTests {
|
||||
SingleRow row = new SingleRow(SNIPPET, property);
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]xref:#my.spring.test.prop[`+spring.test.prop+`]"
|
||||
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+something+`" + NEWLINE);
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ class SingleRowTests {
|
||||
SingleRow row = new SingleRow(SNIPPET, property);
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]xref:#my.spring.test.prop[`+spring.test.prop+`]"
|
||||
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|" + NEWLINE);
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ class SingleRowTests {
|
||||
SingleRow row = new SingleRow(SNIPPET, property);
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]xref:#my.spring.test.prop[`+spring.test.prop+`]"
|
||||
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+first\\|second+`" + NEWLINE);
|
||||
}
|
||||
|
||||
@@ -71,7 +72,7 @@ class SingleRowTests {
|
||||
SingleRow row = new SingleRow(SNIPPET, property);
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]xref:#my.spring.test.prop[`+spring.test.prop+`]"
|
||||
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+first\\\\second+`" + NEWLINE);
|
||||
}
|
||||
|
||||
@@ -82,7 +83,7 @@ class SingleRowTests {
|
||||
SingleRow row = new SingleRow(SNIPPET, property);
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]xref:#my.spring.test.prop[`+spring.test.prop+`]"
|
||||
+ NEWLINE + "|+++This is a description with a \\| pipe.+++" + NEWLINE + "|" + NEWLINE);
|
||||
}
|
||||
|
||||
@@ -93,7 +94,7 @@ class SingleRowTests {
|
||||
SingleRow row = new SingleRow(SNIPPET, property);
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop.*+`>>"
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]xref:#my.spring.test.prop[`+spring.test.prop.*+`]"
|
||||
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|" + NEWLINE);
|
||||
}
|
||||
|
||||
@@ -105,7 +106,7 @@ class SingleRowTests {
|
||||
SingleRow row = new SingleRow(SNIPPET, property);
|
||||
Asciidoc asciidoc = new Asciidoc();
|
||||
row.write(asciidoc);
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>"
|
||||
assertThat(asciidoc).hasToString("|[[my.spring.test.prop]]xref:#my.spring.test.prop[`+spring.test.prop+`]"
|
||||
+ NEWLINE + "|+++This is a description.+++" + NEWLINE + "|`+first," + NEWLINE + "second," + NEWLINE
|
||||
+ "third+`" + NEWLINE);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* Tests for {@link Table}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
class TableTests {
|
||||
|
||||
@@ -44,10 +45,10 @@ class TableTests {
|
||||
assertThat(asciidoc).hasToString("[cols=\"4,3,3\", options=\"header\"]" + NEWLINE +
|
||||
"|===" + NEWLINE +
|
||||
"|Name|Description|Default Value" + NEWLINE + NEWLINE +
|
||||
"|[[my.spring.test.other]]<<my.spring.test.other,`+spring.test.other+`>>" + NEWLINE +
|
||||
"|[[my.spring.test.other]]xref:#my.spring.test.other[`+spring.test.other+`]" + NEWLINE +
|
||||
"|+++This is another description.+++" + NEWLINE +
|
||||
"|`+other value+`" + NEWLINE + NEWLINE +
|
||||
"|[[my.spring.test.prop]]<<my.spring.test.prop,`+spring.test.prop+`>>" + NEWLINE +
|
||||
"|[[my.spring.test.prop]]xref:#my.spring.test.prop[`+spring.test.prop+`]" + NEWLINE +
|
||||
"|+++This is a description.+++" + NEWLINE +
|
||||
"|`+something+`" + NEWLINE + NEWLINE +
|
||||
"|===" + NEWLINE);
|
||||
|
||||
Reference in New Issue
Block a user