Skip to content

Commit 4707c0d

Browse files
committed
Add note about absence of annotated APIs in case there are none
1 parent a697fe7 commit 4707c0d

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

documentation/src/docs/asciidoc/user-guide/api-evolution.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ value of lower stability.
4141
[[api-evolution-experimental-apis]]
4242
=== Experimental APIs
4343

44-
The following table lists which APIs are currently designated as _experimental_ via
44+
The following tables list which APIs are currently designated as _experimental_ via
4545
`@API(status = EXPERIMENTAL)`. Caution should be taken when relying on such APIs.
4646

4747
include::{experimentalApisTableFile}[]
4848

4949
[[api-evolution-deprecated-apis]]
5050
=== Deprecated APIs
5151

52-
The following table lists which APIs are currently designated as _deprecated_ via
52+
The following tables list which APIs are currently designated as _deprecated_ via
5353
`@API(status = DEPRECATED)`. You should avoid using deprecated APIs whenever possible,
5454
since such APIs will likely be removed in an upcoming release.
5555

documentation/src/tools/java/org/junit/api/tools/AbstractApiReportWriter.java

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import java.io.PrintWriter;
1818
import java.util.List;
19+
import java.util.Map;
1920
import java.util.Set;
2021
import java.util.TreeMap;
2122

@@ -52,22 +53,27 @@ public void printDeclarationInfo(PrintWriter out, Set<Status> statuses) {
5253
protected void printDeclarationSection(Set<Status> statuses, Status status, List<Declaration> declarations,
5354
PrintWriter out) {
5455
printDeclarationSectionHeader(statuses, status, declarations, out);
55-
declarations.stream() //
56-
.collect(groupingBy(Declaration::moduleName, TreeMap::new, toList())) //
57-
.forEach((moduleName, moduleDeclarations) -> {
58-
out.println(h4("Module " + moduleName));
59-
out.println();
60-
moduleDeclarations.stream() //
61-
.collect(groupingBy(Declaration::packageName, TreeMap::new, toList())) //
62-
.forEach((packageName, packageDeclarations) -> {
63-
out.println(h5("Package " + packageName));
64-
out.println();
65-
printDeclarationTableHeader(out);
66-
packageDeclarations.forEach(it -> printDeclarationTableRow(it, out));
67-
printDeclarationTableFooter(out);
68-
out.println();
69-
});
70-
});
56+
Map<String, List<Declaration>> declarationsByModule = declarations.stream() //
57+
.collect(groupingBy(Declaration::moduleName, TreeMap::new, toList()));
58+
if (declarationsByModule.isEmpty()) {
59+
out.println(paragraph("NOTE: There are currently no APIs annotated with %s.".formatted(
60+
code("@API(status = %s)".formatted(status.name())))));
61+
return;
62+
}
63+
declarationsByModule.forEach((moduleName, moduleDeclarations) -> {
64+
out.println(h4("Module " + moduleName));
65+
out.println();
66+
moduleDeclarations.stream() //
67+
.collect(groupingBy(Declaration::packageName, TreeMap::new, toList())) //
68+
.forEach((packageName, packageDeclarations) -> {
69+
out.println(h5("Package " + packageName));
70+
out.println();
71+
printDeclarationTableHeader(out);
72+
packageDeclarations.forEach(it -> printDeclarationTableRow(it, out));
73+
printDeclarationTableFooter(out);
74+
out.println();
75+
});
76+
});
7177
}
7278

7379
protected void printDeclarationSectionHeader(Set<Status> statuses, Status status, List<Declaration> declarations,

0 commit comments

Comments
 (0)