Use current alias for current Javadoc/Reference doc links.

Closes #197
This commit is contained in:
Mark Paluch
2021-11-24 14:03:02 +01:00
parent 4af3751fb9
commit 3034be3845
5 changed files with 67 additions and 25 deletions

View File

@@ -556,7 +556,7 @@ public class GitHub extends GitHubSupport implements IssueTracker {
List<GitHubReadIssue> gitHubIssues = findGitHubIssues(module, ticketIds); List<GitHubReadIssue> gitHubIssues = findGitHubIssues(module, ticketIds);
ArtifactVersion version = ArtifactVersion.of(module); ArtifactVersion version = ArtifactVersion.of(module);
DocumentationMetadata documentation = DocumentationMetadata.of(module.getProject(), version); DocumentationMetadata documentation = DocumentationMetadata.of(module.getProject(), version, false);
ChangelogGenerator generator = new ChangelogGenerator(); ChangelogGenerator generator = new ChangelogGenerator();
generator.getExcludeContributors().addAll(properties.getTeam()); generator.getExcludeContributors().addAll(properties.getTeam());
@@ -598,14 +598,18 @@ public class GitHub extends GitHubSupport implements IssueTracker {
private String getDocumentationLinks(ModuleIteration module, DocumentationMetadata documentation) { private String getDocumentationLinks(ModuleIteration module, DocumentationMetadata documentation) {
String referenceDocUrl = documentation.getReferenceDocUrl(module.getTrain()); if (module.getProject() == Projects.BUILD || module.getProject() == Projects.BOM) {
String apiDocUrl = documentation.getApiDocUrl(module.getTrain()); return "";
}
String referenceDocUrl = documentation.getReferenceDocUrl();
String apiDocUrl = documentation.getApiDocUrl();
String reference = String.format("* [%s %s Reference documentation](%s)", module.getProject().getFullName(), String reference = String.format("* [%s %s Reference documentation](%s)", module.getProject().getFullName(),
documentation.getVersion(module.getTrain()), referenceDocUrl); module.getVersion().toString(), referenceDocUrl);
String apidoc = String.format("* [%s %s Javadoc](%s)", module.getProject().getFullName(), String apidoc = String.format("* [%s %s Javadoc](%s)", module.getProject().getFullName(),
documentation.getVersion(module.getTrain()), apiDocUrl); module.getVersion().toString(), apiDocUrl);
return String.format("%s%n%s%n", reference, apidoc); return String.format("%s%n%s%n", reference, apidoc);
} }

View File

@@ -33,23 +33,24 @@ public class DocumentationMetadata {
Project project; Project project;
ArtifactVersion version; ArtifactVersion version;
boolean isCurrent;
/** /**
* Returns the JavaDoc URL for non-snapshot versions and not the build project. * Returns the JavaDoc URL for non-snapshot versions and not the build project.
* *
* @return * @return
*/ */
public String getApiDocUrl(Train train) { public String getApiDocUrl() {
if (version.isSnapshotVersion()) { if (version.isSnapshotVersion()) {
return ""; return "";
} }
if (Projects.BUILD.equals(project)) { // Report Commons Docs for Spring Data Build if (Projects.BUILD.equals(project)) { // Report Commons Docs for Spring Data Build
return String.format(JAVADOC, Projects.COMMONS.getName().toLowerCase(Locale.US), version.toString()); return String.format(JAVADOC, Projects.COMMONS.getName().toLowerCase(Locale.US), getDocumentationVersion());
} }
return String.format(JAVADOC, project.getName().toLowerCase(Locale.US), getVersion(train)); return String.format(JAVADOC, project.getName().toLowerCase(Locale.US), getDocumentationVersion());
} }
/** /**
@@ -57,20 +58,20 @@ public class DocumentationMetadata {
* *
* @return * @return
*/ */
public String getReferenceDocUrl(Train train) { public String getReferenceDocUrl() {
if (version.isSnapshotVersion()) { if (version.isSnapshotVersion()) {
return ""; return "";
} }
if (Projects.BUILD.equals(project)) { // Report Commons Docs for Spring Data Build if (Projects.BUILD.equals(project)) { // Report Commons Docs for Spring Data Build
return String.format(DOCS, Projects.COMMONS.getName().toLowerCase(Locale.US), version.toString()); return String.format(DOCS, Projects.COMMONS.getName().toLowerCase(Locale.US), getDocumentationVersion());
} }
return String.format(DOCS, project.getName().toLowerCase(Locale.US), getVersion(train)); return String.format(DOCS, project.getName().toLowerCase(Locale.US), getDocumentationVersion());
} }
public String getVersion(Train train) { public String getVersionOrTrainName(Train train) {
if (Projects.BUILD.equals(project)) { if (Projects.BUILD.equals(project)) {
@@ -92,4 +93,8 @@ public class DocumentationMetadata {
return version.toString(); return version.toString();
} }
public String getDocumentationVersion() {
return isCurrent ? "current" : version.toString();
}
} }

View File

@@ -29,7 +29,7 @@ public class ReleaseTrains {
public static final List<Train> TRAINS; public static final List<Train> TRAINS;
public static final Train CODD, DIJKSTRA, EVANS, FOWLER, GOSLING, HOPPER, INGALLS, KAY, LOVELACE, MOORE, NEUMANN, public static final Train CODD, DIJKSTRA, EVANS, FOWLER, GOSLING, HOPPER, INGALLS, KAY, LOVELACE, MOORE, NEUMANN,
OCKHAM, PASCAL, Q, R, TURING; OCKHAM, PASCAL, Q, RAJ, TURING;
static { static {
@@ -70,7 +70,7 @@ public class ReleaseTrains {
.withCalver("2021.1") // .withCalver("2021.1") //
.withIterations(new Train.Iterations(M1, M2, M3, M4, M5, RC1, RC2, GA, SR1, SR2, SR3, SR4, SR5)); .withIterations(new Train.Iterations(M1, M2, M3, M4, M5, RC1, RC2, GA, SR1, SR2, SR3, SR4, SR5));
R = Q.next("R", Transition.MINOR) // RAJ = Q.next("Raj", Transition.MINOR) //
.withCalver("2022.0") // .withCalver("2022.0") //
.withIterations(new Train.Iterations(M1, M2, M3, M4, M5, RC1, RC2, GA, SR1, SR2, SR3, SR4, SR5)); .withIterations(new Train.Iterations(M1, M2, M3, M4, M5, RC1, RC2, GA, SR1, SR2, SR3, SR4, SR5));
@@ -83,7 +83,7 @@ public class ReleaseTrains {
// Trains // Trains
TRAINS = Arrays.asList(CODD, DIJKSTRA, EVANS, FOWLER, GOSLING, HOPPER, INGALLS, KAY, LOVELACE, MOORE, NEUMANN, TRAINS = Arrays.asList(CODD, DIJKSTRA, EVANS, FOWLER, GOSLING, HOPPER, INGALLS, KAY, LOVELACE, MOORE, NEUMANN,
OCKHAM, PASCAL, Q, R, TURING); OCKHAM, PASCAL, Q, RAJ, TURING);
} }
private static Train codd() { private static Train codd() {

View File

@@ -47,7 +47,8 @@ class ProjectMetadata {
this.version = version; this.version = version;
this.versions = versions; this.versions = versions;
this.documentation = DocumentationMetadata.of(version.getProject(), version.getVersion()); this.documentation = DocumentationMetadata.of(version.getProject(), version.getVersion(),
versions.isMainVersion(version));
} }
/** /**
@@ -56,7 +57,7 @@ class ProjectMetadata {
* @return * @return
*/ */
public String getReferenceDocUrl() { public String getReferenceDocUrl() {
return documentation.getReferenceDocUrl(version.getTrain()); return documentation.getReferenceDocUrl();
} }
/** /**
@@ -75,7 +76,7 @@ class ProjectMetadata {
* @return * @return
*/ */
public String getApiDocUrl() { public String getApiDocUrl() {
return documentation.getApiDocUrl(version.getTrain()); return documentation.getApiDocUrl();
} }
/** /**
@@ -85,6 +86,6 @@ class ProjectMetadata {
* @return * @return
*/ */
public String getVersion() { public String getVersion() {
return documentation.getVersion(version.getTrain()); return documentation.getVersionOrTrainName(version.getTrain());
} }
} }

View File

@@ -29,22 +29,54 @@ class DocumentationMetadataUnitTests {
@Test // gh-167 @Test // gh-167
void shouldReportCorrectDocumentationUrls() { void shouldReportCorrectDocumentationUrls() {
DocumentationMetadata metadata = DocumentationMetadata.of(Projects.MONGO_DB, ArtifactVersion.of("3.1.0")); DocumentationMetadata metadata = DocumentationMetadata.of(Projects.MONGO_DB, ArtifactVersion.of("3.1.0"), false);
assertThat(metadata.getApiDocUrl(ReleaseTrains.OCKHAM)) assertThat(metadata.getApiDocUrl())
.isEqualTo("https://docs.spring.io/spring-data/mongodb/docs/3.1.0/api/"); .isEqualTo("https://docs.spring.io/spring-data/mongodb/docs/3.1.0/api/");
assertThat(metadata.getReferenceDocUrl(ReleaseTrains.OCKHAM)) assertThat(metadata.getReferenceDocUrl())
.isEqualTo("https://docs.spring.io/spring-data/mongodb/docs/3.1.0/reference/html/"); .isEqualTo("https://docs.spring.io/spring-data/mongodb/docs/3.1.0/reference/html/");
} }
@Test // gh-197
void shouldReportCorrectCurrentDocumentationUrls() {
DocumentationMetadata metadata = DocumentationMetadata.of(Projects.MONGO_DB, ArtifactVersion.of("3.1.0"), true);
assertThat(metadata.getApiDocUrl()).isEqualTo("https://docs.spring.io/spring-data/mongodb/docs/current/api/");
assertThat(metadata.getReferenceDocUrl())
.isEqualTo("https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/");
}
@Test // gh-167 @Test // gh-167
void shouldReportCorrectCommonsDocumentationUrlsForBuildProject() { void shouldReportCorrectCommonsDocumentationUrlsForBuildProject() {
DocumentationMetadata metadata = DocumentationMetadata.of(Projects.BUILD, ArtifactVersion.of("3.1.0")); DocumentationMetadata metadata = DocumentationMetadata.of(Projects.BUILD, ArtifactVersion.of("3.1.0"), false);
assertThat(metadata.getApiDocUrl(ReleaseTrains.OCKHAM)) assertThat(metadata.getApiDocUrl())
.isEqualTo("https://docs.spring.io/spring-data/commons/docs/3.1.0/api/"); .isEqualTo("https://docs.spring.io/spring-data/commons/docs/3.1.0/api/");
assertThat(metadata.getReferenceDocUrl(ReleaseTrains.OCKHAM)) assertThat(metadata.getReferenceDocUrl())
.isEqualTo("https://docs.spring.io/spring-data/commons/docs/3.1.0/reference/html/"); .isEqualTo("https://docs.spring.io/spring-data/commons/docs/3.1.0/reference/html/");
} }
@Test // gh-197
void shouldReportCorrectCurrentCommonsDocumentationUrlsForBuildProject() {
DocumentationMetadata metadata = DocumentationMetadata.of(Projects.BUILD, ArtifactVersion.of("3.1.0"), true);
assertThat(metadata.getApiDocUrl()).isEqualTo("https://docs.spring.io/spring-data/commons/docs/current/api/");
assertThat(metadata.getReferenceDocUrl())
.isEqualTo("https://docs.spring.io/spring-data/commons/docs/current/reference/html/");
}
@Test // gh-197
void shouldReportVersionLabels() {
DocumentationMetadata metadata = DocumentationMetadata.of(Projects.BUILD, ArtifactVersion.of("3.1.0"), true);
assertThat(metadata.getVersionOrTrainName(ReleaseTrains.OCKHAM)).isEqualTo("2020.0.0");
metadata = DocumentationMetadata.of(Projects.COMMONS, ArtifactVersion.of("3.1.0"), true);
assertThat(metadata.getVersionOrTrainName(ReleaseTrains.OCKHAM)).isEqualTo("3.1.0");
}
} }