Skip to content

Commit b753389

Browse files
committed
fix: improve the javadoc generation
Make all components put javadoc into a consistent root. This achieves the following - means the javadoc for the generated protobuf can be kept quiet - as we can't adjust the javadoc here - there is a single place for javadoc that could be published - the isthmus and core and protobuf projects can be interlinked - isthmus can be linked with the calcite javadoc - overview pages can be added - all under a versioned directory for easy maintence To date there isn't (AFAIK) a stightforward maintainable way to merge javadoc form multi-component projects Signed-off-by: MBWhite <whitemat@uk.ibm.com>
1 parent 9c1f3e9 commit b753389

File tree

5 files changed

+125
-2
lines changed

5 files changed

+125
-2
lines changed

core/build.gradle.kts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,69 @@ protobuf {
272272
generateProtoTasks { all().configureEach { dependsOn(submodulesUpdate) } }
273273
protoc { artifact = "com.google.protobuf:protoc:" + libs.protoc.get().getVersion() }
274274
}
275+
276+
val protoJavaDir = layout.buildDirectory.dir("generated/sources/proto/main/java")
277+
278+
// First pass: Javadoc for generated protobufs — ignore warnings.
279+
tasks.register<Javadoc>("javadocProto") {
280+
group = JavaBasePlugin.DOCUMENTATION_GROUP
281+
description = "Generate Javadoc for protobuf-generated sources (warnings suppressed)."
282+
283+
// Only the generated proto sources
284+
setSource(fileTree(protoJavaDir) { include("**/*.java") })
285+
286+
// Use the main source set classpath to resolve types referenced by the generated code
287+
classpath = sourceSets["main"].compileClasspath
288+
289+
// Destination separate from main Javadoc
290+
destinationDir = rootProject.layout.buildDirectory.dir("docs/${version}/core-proto").get().asFile
291+
292+
// Make sure protobufs are generated before Javadoc runs
293+
dependsOn("generateProto")
294+
295+
// Suppress warnings/doclint for protobuf pass
296+
(options as StandardJavadocDocletOptions).apply {
297+
// Disable doclint entirely
298+
addBooleanOption("Xdoclint:none", true)
299+
// Be quiet
300+
addBooleanOption("quiet", true)
301+
// Encoding is good practice
302+
encoding = "UTF-8"
303+
}
304+
305+
// Do not fail the build if javadoc finds issues in generated sources
306+
isFailOnError = false
307+
}
308+
309+
// Second pass: Javadoc for main code, excluding the generated protobuf sources.
310+
tasks.named<Javadoc>("javadoc") {
311+
mustRunAfter("javadocProto")
312+
description = "Generate Javadoc for main sources (excludes protobuf-generated sources)."
313+
314+
// Exclude the protobuf-generated directory from the main pass
315+
val protoDirFile = protoJavaDir.get().asFile
316+
exclude { spec -> spec.file.toPath().startsWith(protoDirFile.toPath()) }
317+
318+
// Keep normal behavior for main javadoc (warnings allowed to show/fail if you want)
319+
(options as StandardJavadocDocletOptions).apply {
320+
encoding = "UTF-8"
321+
destinationDir = rootProject.layout.buildDirectory.dir("docs/${version}/core").get().asFile
322+
323+
addStringOption("overview","${rootProject.projectDir}/overview.html")
324+
addStringOption("link", "../core-proto")
325+
}
326+
}
327+
328+
// Bundle both passes into the Javadoc JAR used for publishing.
329+
tasks.named<Jar>("javadocJar") {
330+
331+
val shared = rootProject.layout.buildDirectory.dir("docs/${version}").get().asFile
332+
if (!shared.exists()){
333+
println("Creating a dir for javadoc ${rootProject.buildDir}/docs/${version}")
334+
shared.mkdirs()
335+
}
336+
337+
// Ensure both javadoc tasks have produced outputs
338+
dependsOn(tasks.named("javadocProto"), tasks.named("javadoc"))
339+
340+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
/**
2+
* The {@code io.substrait} package provides core classes and interfaces
3+
* for working with the Substrait specification, which defines a portable
4+
* representation of query plans and expressions.
5+
*
6+
*/
17
@org.immutables.value.Value.Style(allowedClasspathAnnotations = {java.lang.Override.class})
28
package io.substrait;

examples/substrait-spark/src/main/java/io/substrait/examples/util/SubstraitStringify.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public SubstraitStringify() {
7474
/**
7575
* Explains the Sustrait plan
7676
*
77-
* @param plan Subsrait plan
7877
* @return List of strings; typically these would then be logged or sent to stdout
7978
*/
8079
public static List<String> explain(io.substrait.plan.Plan plan) {
@@ -96,7 +95,7 @@ public static List<String> explain(io.substrait.plan.Plan plan) {
9695
/**
9796
* Explains the Sustrait relation
9897
*
99-
* @param plan Subsrait relation
98+
* @param rel Subsrait relation
10099
* @return List of strings; typically these would then be logged or sent to stdout
101100
*/
102101
public static List<String> explain(io.substrait.relation.Rel rel) {

isthmus/build.gradle.kts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,33 @@ tasks {
147147
sourceSets { test { proto.srcDirs("src/test/resources/extensions") } }
148148

149149
protobuf { protoc { artifact = "com.google.protobuf:protoc:" + libs.protoc.get().getVersion() } }
150+
151+
152+
tasks.named<Javadoc>("javadoc") {
153+
description = "Generate Javadoc for main sources (excludes protobuf-generated sources)."
154+
155+
// Keep normal behavior for main javadoc (warnings allowed to show/fail if you want)
156+
(options as StandardJavadocDocletOptions).apply {
157+
encoding = "UTF-8"
158+
destinationDir = rootProject.layout.buildDirectory.dir("docs/${version}/isthmus").get().asFile
159+
160+
addStringOption("link", "../core-proto")
161+
addStringOption("link", "../core")
162+
addStringOption("link", "https://calcite.apache.org/javadocAggregate/")
163+
}
164+
}
165+
166+
// Bundle both passes into the Javadoc JAR used for publishing.
167+
tasks.named<Jar>("javadocJar") {
168+
169+
170+
val shared = rootProject.layout.buildDirectory.dir("docs/${version}").get().asFile
171+
if (!shared.exists()){
172+
println("Creating a dir for javadoc ${rootProject.buildDir}/${version}")
173+
shared.mkdirs()
174+
}
175+
176+
// Ensure javadoc tasks have produced output
177+
dependsOn(tasks.named("javadoc"))
178+
179+
}

overview.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<body>
2+
<hr />
3+
<h1>Core Substrait Java API</h1>
4+
<p>
5+
The {@code io.substrait} package provides core classes and interfaces for
6+
working with the Substrait specification, which defines a portable
7+
representation of query plans and expressions.
8+
</p>
9+
10+
<h2>Components</h2>
11+
<ul>
12+
<li><a href="./index.html">core</a> Core classes and interfaces</li>
13+
<li>
14+
<a href="../core-proto/index.html">core-protobuf</a> The ProtoBuf wrapper
15+
classes
16+
</li>
17+
<li>
18+
<a href="../isthmus/index.html">Isthmus API</a> Utility module that uses
19+
Calcite to convert SQL to/from Substrait
20+
</li>
21+
</ul>
22+
</body>

0 commit comments

Comments
 (0)