Skip to content

Commit ea78d5c

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 <[email protected]>
1 parent acaecb5 commit ea78d5c

File tree

5 files changed

+117
-2
lines changed

5 files changed

+117
-2
lines changed

core/build.gradle.kts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,67 @@ 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+
val shared = rootProject.layout.buildDirectory.dir("docs/${version}").get().asFile
331+
if (!shared.exists()) {
332+
println("Creating a dir for javadoc ${rootProject.buildDir}/docs/${version}")
333+
shared.mkdirs()
334+
}
335+
336+
// Ensure both javadoc tasks have produced outputs
337+
dependsOn(tasks.named("javadocProto"), tasks.named("javadoc"))
338+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
/**
2+
* The {@code io.substrait} package provides core classes and interfaces for working with the
3+
* Substrait specification, which defines a portable representation of query plans and expressions.
4+
*/
15
@org.immutables.value.Value.Style(allowedClasspathAnnotations = {java.lang.Override.class})
26
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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,29 @@ 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+
tasks.named<Javadoc>("javadoc") {
152+
description = "Generate Javadoc for main sources (excludes protobuf-generated sources)."
153+
154+
// Keep normal behavior for main javadoc (warnings allowed to show/fail if you want)
155+
(options as StandardJavadocDocletOptions).apply {
156+
encoding = "UTF-8"
157+
destinationDir = rootProject.layout.buildDirectory.dir("docs/${version}/isthmus").get().asFile
158+
159+
addStringOption("link", "../core-proto")
160+
addStringOption("link", "../core")
161+
addStringOption("link", "https://calcite.apache.org/javadocAggregate/")
162+
}
163+
}
164+
165+
// Bundle both passes into the Javadoc JAR used for publishing.
166+
tasks.named<Jar>("javadocJar") {
167+
val shared = rootProject.layout.buildDirectory.dir("docs/${version}").get().asFile
168+
if (!shared.exists()) {
169+
println("Creating a dir for javadoc ${rootProject.buildDir}/${version}")
170+
shared.mkdirs()
171+
}
172+
173+
// Ensure javadoc tasks have produced output
174+
dependsOn(tasks.named("javadoc"))
175+
}

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)