Update documentation URL references to antora-based doc sites.
Closes #58
This commit is contained in:
@@ -38,7 +38,7 @@ public class StaticResources {
|
||||
|
||||
public StaticResources(ModuleIteration module) {
|
||||
|
||||
this.metadata = DocumentationMetadata.of(module.getProject(), ArtifactVersion.of(module), false);
|
||||
this.metadata = DocumentationMetadata.of(module, ArtifactVersion.of(module), false);
|
||||
|
||||
Project project = module.getProject();
|
||||
GitProject gitProject = GitProject.of(project);
|
||||
|
||||
@@ -19,6 +19,8 @@ import lombok.Value;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.data.release.model.Train.DocumentationFormat;
|
||||
|
||||
/**
|
||||
* Value object providing documentation links.
|
||||
*
|
||||
@@ -28,13 +30,20 @@ import java.util.Locale;
|
||||
public class DocumentationMetadata {
|
||||
|
||||
private static String DOCS_BASE = "https://docs.spring.io/spring-data/%s/docs/%s";
|
||||
|
||||
private static String ANTORA_BASE = "https://docs.spring.io/spring-data/%s/reference/";
|
||||
private static String DOCS = DOCS_BASE.concat("/reference/html/");
|
||||
private static String JAVADOC = DOCS_BASE.concat("/api/");
|
||||
|
||||
DocumentationFormat documentationFormat;
|
||||
Project project;
|
||||
ArtifactVersion version;
|
||||
boolean isCurrent;
|
||||
|
||||
public static DocumentationMetadata of(ModuleIteration module, ArtifactVersion version, boolean isCurrent) {
|
||||
return of(module.getTrain().getDocumentationFormat(), module.getProject(), version, isCurrent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JavaDoc URL for non-snapshot versions and not the build project.
|
||||
*
|
||||
@@ -55,8 +64,18 @@ public class DocumentationMetadata {
|
||||
|
||||
private String getProjectName(Project project) {
|
||||
|
||||
if (project == Projects.RELATIONAL) {
|
||||
return "jdbc";
|
||||
// With Asciidoctor, JDBC had its own docs path
|
||||
if (documentationFormat == DocumentationFormat.ASCIIDOC) {
|
||||
if (project == Projects.RELATIONAL) {
|
||||
return "jdbc";
|
||||
}
|
||||
}
|
||||
|
||||
// With Antora, JDBC and R2DBC use a shared site
|
||||
if (documentationFormat == DocumentationFormat.ANTORA) {
|
||||
if (project == Projects.R2DBC || project == Projects.JDBC) {
|
||||
return "relational";
|
||||
}
|
||||
}
|
||||
|
||||
return project.getName().toLowerCase(Locale.US);
|
||||
@@ -69,15 +88,22 @@ public class DocumentationMetadata {
|
||||
*/
|
||||
public String getReferenceDocUrl() {
|
||||
|
||||
if (version.isSnapshotVersion()) {
|
||||
return "";
|
||||
if (documentationFormat == DocumentationFormat.ASCIIDOC) {
|
||||
|
||||
if (version.isSnapshotVersion()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
Project project = this.project;
|
||||
|
||||
if (Projects.BUILD.equals(project)) { // Report Commons Docs for Spring Data Build
|
||||
project = Projects.COMMONS;
|
||||
}
|
||||
|
||||
return String.format(DOCS, getProjectName(project), getDocumentationVersion());
|
||||
}
|
||||
|
||||
if (Projects.BUILD.equals(project)) { // Report Commons Docs for Spring Data Build
|
||||
return String.format(DOCS, getProjectName(Projects.COMMONS), getDocumentationVersion());
|
||||
}
|
||||
|
||||
return String.format(DOCS, getProjectName(project), getDocumentationVersion());
|
||||
return String.format(ANTORA_BASE, getProjectName(project));
|
||||
}
|
||||
|
||||
public String getVersionOrTrainName(Train train) {
|
||||
|
||||
@@ -20,6 +20,8 @@ import static org.springframework.data.release.model.Projects.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.release.model.Train.DocumentationFormat;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
@@ -82,6 +84,7 @@ public class ReleaseTrains {
|
||||
.withCalver("2023.0");
|
||||
|
||||
VAUGHAN = ULLMAN.next("Vaughan", Transition.MINOR) //
|
||||
.withDocumentationFormat(DocumentationFormat.ANTORA) //
|
||||
.withCalver("2023.1");
|
||||
|
||||
// Trains
|
||||
|
||||
@@ -55,12 +55,15 @@ public class Train implements Streamable<Module> {
|
||||
private @With boolean alwaysUseBranch;
|
||||
private JavaVersion javaVersion;
|
||||
|
||||
private @With DocumentationFormat documentationFormat;
|
||||
|
||||
public Train(String name, Module... modules) {
|
||||
this(name, Arrays.asList(modules));
|
||||
}
|
||||
|
||||
public Train(String name, Collection<Module> modules) {
|
||||
this(name, Modules.of(modules), null, Iterations.DEFAULT, false, JavaVersion.VERSION_1_8);
|
||||
this(name, Modules.of(modules), null, Iterations.DEFAULT, false, JavaVersion.VERSION_1_8,
|
||||
DocumentationFormat.ASCIIDOC);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -124,12 +127,12 @@ public class Train implements Streamable<Module> {
|
||||
(it, additionalModule) -> it.hasSameProjectAs(additionalModule) ? additionalModule : it))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
return new Train(name, Modules.of(modules), calver, iterations, false, javaVersion);
|
||||
return new Train(name, Modules.of(modules), calver, iterations, false, javaVersion, documentationFormat);
|
||||
}
|
||||
|
||||
public Train filterModules(Predicate<Module> filterPredicate) {
|
||||
return new Train(name, Modules.of(getModules().stream().filter(filterPredicate).collect(Collectors.toList())),
|
||||
calver, iterations, alwaysUseBranch, javaVersion);
|
||||
calver, iterations, alwaysUseBranch, javaVersion, documentationFormat);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,7 +193,7 @@ public class Train implements Streamable<Module> {
|
||||
|
||||
}).collect(Collectors.toSet());
|
||||
|
||||
return new Train(name, Modules.of(modules), calver, iterations, alwaysUseBranch, javaVersion);
|
||||
return new Train(name, Modules.of(modules), calver, iterations, alwaysUseBranch, javaVersion, documentationFormat);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,4 +320,8 @@ public class Train implements Streamable<Module> {
|
||||
return iterations.iterator();
|
||||
}
|
||||
}
|
||||
|
||||
public enum DocumentationFormat {
|
||||
ASCIIDOC, ANTORA;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ class ProjectMetadata {
|
||||
|
||||
this.version = version;
|
||||
this.versions = versions;
|
||||
this.documentation = DocumentationMetadata.of(version.getProject(), version.getVersion(),
|
||||
versions.isMainVersion(version));
|
||||
this.documentation = DocumentationMetadata.of(version.getTrain().getDocumentationFormat(), version.getProject(),
|
||||
version.getVersion(), versions.isMainVersion(version));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.release.model;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.release.model.Train.DocumentationFormat;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link DocumentationMetadata}.
|
||||
@@ -27,9 +28,10 @@ import org.junit.jupiter.api.Test;
|
||||
class DocumentationMetadataUnitTests {
|
||||
|
||||
@Test // gh-167
|
||||
void shouldReportCorrectDocumentationUrls() {
|
||||
void shouldReportCorrectAsciidocDocumentationUrls() {
|
||||
|
||||
DocumentationMetadata metadata = DocumentationMetadata.of(Projects.MONGO_DB, ArtifactVersion.of("3.1.0"), false);
|
||||
DocumentationMetadata metadata = DocumentationMetadata.of(DocumentationFormat.ASCIIDOC, Projects.MONGO_DB,
|
||||
ArtifactVersion.of("3.1.0"), false);
|
||||
|
||||
assertThat(metadata.getApiDocUrl())
|
||||
.isEqualTo("https://docs.spring.io/spring-data/mongodb/docs/3.1.0/api/");
|
||||
@@ -37,10 +39,21 @@ class DocumentationMetadataUnitTests {
|
||||
.isEqualTo("https://docs.spring.io/spring-data/mongodb/docs/3.1.0/reference/html/");
|
||||
}
|
||||
|
||||
@Test // gh-167
|
||||
void shouldReportCorrectAntoraDocumentationUrls() {
|
||||
|
||||
DocumentationMetadata metadata = DocumentationMetadata.of(DocumentationFormat.ANTORA, Projects.MONGO_DB,
|
||||
ArtifactVersion.of("3.1.0"), false);
|
||||
|
||||
assertThat(metadata.getApiDocUrl()).isEqualTo("https://docs.spring.io/spring-data/mongodb/docs/3.1.0/api/");
|
||||
assertThat(metadata.getReferenceDocUrl()).isEqualTo("https://docs.spring.io/spring-data/mongodb/reference/");
|
||||
}
|
||||
|
||||
@Test // gh-197
|
||||
void shouldReportCorrectCurrentDocumentationUrls() {
|
||||
|
||||
DocumentationMetadata metadata = DocumentationMetadata.of(Projects.MONGO_DB, ArtifactVersion.of("3.1.0"), true);
|
||||
DocumentationMetadata metadata = DocumentationMetadata.of(DocumentationFormat.ASCIIDOC, 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())
|
||||
@@ -50,7 +63,8 @@ class DocumentationMetadataUnitTests {
|
||||
@Test // gh-167
|
||||
void shouldReportCorrectCommonsDocumentationUrlsForBuildProject() {
|
||||
|
||||
DocumentationMetadata metadata = DocumentationMetadata.of(Projects.BUILD, ArtifactVersion.of("3.1.0"), false);
|
||||
DocumentationMetadata metadata = DocumentationMetadata.of(DocumentationFormat.ASCIIDOC, Projects.BUILD,
|
||||
ArtifactVersion.of("3.1.0"), false);
|
||||
|
||||
assertThat(metadata.getApiDocUrl())
|
||||
.isEqualTo("https://docs.spring.io/spring-data/commons/docs/3.1.0/api/");
|
||||
@@ -61,7 +75,8 @@ class DocumentationMetadataUnitTests {
|
||||
@Test // gh-197
|
||||
void shouldReportCorrectCurrentCommonsDocumentationUrlsForBuildProject() {
|
||||
|
||||
DocumentationMetadata metadata = DocumentationMetadata.of(Projects.BUILD, ArtifactVersion.of("3.1.0"), true);
|
||||
DocumentationMetadata metadata = DocumentationMetadata.of(DocumentationFormat.ASCIIDOC, 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())
|
||||
@@ -71,11 +86,13 @@ class DocumentationMetadataUnitTests {
|
||||
@Test // gh-197
|
||||
void shouldReportVersionLabels() {
|
||||
|
||||
DocumentationMetadata metadata = DocumentationMetadata.of(Projects.BUILD, ArtifactVersion.of("3.1.0"), true);
|
||||
DocumentationMetadata metadata = DocumentationMetadata.of(DocumentationFormat.ASCIIDOC, 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);
|
||||
metadata = DocumentationMetadata.of(DocumentationFormat.ASCIIDOC, Projects.COMMONS, ArtifactVersion.of("3.1.0"),
|
||||
true);
|
||||
|
||||
assertThat(metadata.getVersionOrTrainName(ReleaseTrains.OCKHAM)).isEqualTo("3.1.0");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user