Repository navigation
feat: build the SDK and Truffle API references with elide-dev/doclet - #36
Sam Gammon (sgammon) wants to merge 1 commit into
Conversation
//graal/apidocs:sdk and //graal/apidocs:truffle render the GraalVM SDK and Truffle Java API references with elide-dev/doclet, through rules_elide's new elide_apidocs rule. The package sets match `mx sdk javadoc` and `mx truffle javadoc`: only packages with a package-info.java, so the implementation packages are left out. Javadoc runs over the source jars of the Bazel-built projects, and their compile classpath supplies the classes that Truffle's annotation processors generate. - Bump rules_elide to a4ed40d (elide_apidocs). - Build the doclet from a pinned commit: main plus the fix for malformed block tags, which crashed on the Truffle API. Move the pin to main once that merges. - --config=apidocs selects Labs JDK 25 for the doclet and javadoc. The targets are manual. - The version and source_ref build settings name the release: the library version and the canonical URL under https://static.elideusercontent.com/graalvm/javadoc/. - apidocs_test checks both package sets, the JDK links and the archives; CI runs it. Refs #22
There was a problem hiding this comment.
Devin Review found 1 potential issue.
2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| elide_apidocs( | ||
| name = name, | ||
| data = [":" + name + "_args"], | ||
| deps = deps, | ||
| doclet = "@elide_doclet//:doclet", | ||
| exclude_packages = exclude_packages, | ||
| javadoc_opts = ["@$(location :{}_args)".format(name)], | ||
| jvm_flags = ["-Xmx4g"], |
There was a problem hiding this comment.
🟡 API reference builds leak temporary files
On macOS, elide_apidocs leaves its unpacked source jars in the host’s temporary directory. The launcher never removes them, so each build that reruns the action leaves another copy behind.
Learn more
Both the SDK and Truffle reference targets use elide_apidocs from the pinned rules_elide override. In that pin, ApiDocs.main creates an elide-apidocs-sources* directory with Files.createTempDirectory, unpacks the source jars there and runs Javadoc against it. The launcher never deletes the directory, even on success. Labs JDK uses the per-user temporary directory on macOS, and Bazel's macOS sandbox lets actions write there without making it private to the action. Bazel therefore does not remove these directories when it cleans up the sandbox.
Example: Build both references on macOS, change the Graal source pin and build again. Each uncached build of both references leaves two new directories containing about 11 MB of handwritten Java sources combined, before counting generated sources.
Recommended fix: Update the pinned launcher to delete its unpacked source tree in a finally block. Make the launcher propagate errors without calling System.exit inside that block, so cleanup runs on unsuccessful builds as well.
Was this helpful? React with 👍 or 👎 to provide feedback.
Part of #22. The publish workflow is elide-dev/graal#259.
What this adds
//graal/apidocs:sdkand//graal/apidocs:trufflerender the GraalVM SDK and Truffle Java API references with elide-dev/doclet, through rules_elide'selide_apidocs(elide-dev/rules_elide#137)..tar.gzmx sdk javadoc(the sixorg.graalvm.*roots that Generate SDK and Truffle API references with elide-dev/doclet #22 lists) andmx truffle javadoc(its project list). Like mx, only packages with apackage-info.javaare documented, so*.impl,strings.providerand similar packages are left out.apidocs_testchecks both sets, the JDK links and that each archive matches its site.-sourcepathmode, over the source jars of the Bazel-built projects. Their compile classpath supplies the classes that Truffle's processors generate. No mx is involved.--config=apidocsselects Labs JDK 25 for the doclet and javadoc. The targets aremanual, so//...on JDK 21 skips them. JDK types link to the JDK 25 reference through a checked-inelement-list.--//graal/apidocs:versionsets the library version and the canonical base URL,https://static.elideusercontent.com/graalvm/javadoc/<sdk|truffle>/<version>/, which also gives a sitemap.--//graal/apidocs:source_refpasses--source-ref.Why the targets live here, not in
@graalThe
@graalBUILD files are generated overlays (tools/generate-graal --checkgates them). Adding hand-written targets there would mean teaching the generator about them. A rules_mx package that depends on@graal//sdk:*and@graal//truffle:*labels works with any source thatgraal.source()selects. The elide-dev/graal workflow uses that to regenerate the overlays for a release commit and build these targets.Pins
a4ed40d092d21f8f4aaafa2eecba60398bbaf817(main, withelide_apidocs).9e1c00741d087297dd9339518cca3d9d9d200edb: main (5af2ecb, which has Run upstream SimpleLanguage, TCK and compiler regression suites under Bazel #8 to Package all Truffle distributions and expand Bazel coverage #12) plus fix(doclet): report a malformed block tag instead of crashing doclet#14. That fix stops the doclet crashing on a malformed@seein the Truffle API. Move the pin to doclet main once Build all GraalVM Tools projects and distributions #14 merges.Known gaps (doclet)
The Truffle reference uses
--problems error,malformed=warning,reference=warning,snippet=warning. The SDK needs no exceptions. The affected parts are left out:{@snippet file=...}examples (DynamicObject, Source, TruffleLanguage, Node, ...). mx resolves them through--snippet-path; the doclet does not support external snippets yet.{@link R}to a type parameter (BytecodeDescriptor) and one@seewith a trailing period (StaticProperty).{path}is the package-relative path (org/graalvm/polyglot/Context.java). In the Graal tree, the file is under the project directory (sdk/src/org.graalvm.polyglot/src/...), so onesourceLinktemplate cannot reach it.elideonPATHto wrap them, and the action has noPATH.elide_apidocscould pass the toolchain's Elide as--signature-formatter.Testing
bazelisk test --config=apidocs //graal/apidocs:apidocs_testpasses locally. CI runs it in both the PR and BuildBuddy steps.tools/generate-graal --archive file://... --pin, as the graal workflow does: both references build in about a minute.