Skip to content

feat: build the SDK and Truffle API references with elide-dev/doclet - #36

Open
Sam Gammon (sgammon) wants to merge 1 commit into
mainfrom
feat/apidocs
Open

Sam Gammon (sgammon) wants to merge 1 commit into
mainfrom
feat/apidocs

Conversation

@sgammon

@sgammon Sam Gammon (sgammon) commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Part of #22. The publish workflow is elide-dev/graal#259.

What this adds

//graal/apidocs:sdk and //graal/apidocs:truffle render the GraalVM SDK and Truffle Java API references with elide-dev/doclet, through rules_elide's elide_apidocs (elide-dev/rules_elide#137).

bazelisk test --config=apidocs //graal/apidocs:apidocs_test
bazelisk build --config=apidocs --//graal/apidocs:version=25.6.0-elide.1 --//graal/apidocs:source_ref=$SHA //graal/apidocs:sdk //graal/apidocs:truffle
Reference Packages HTML pages Files Site .tar.gz
SDK 16 268 547 18.6 MB 2.2 MB
Truffle 40 877 1,765 73.5 MB 8.5 MB
  • Package sets: the same as mx sdk javadoc (the six org.graalvm.* roots that Generate SDK and Truffle API references with elide-dev/doclet #22 lists) and mx truffle javadoc (its project list). Like mx, only packages with a package-info.java are documented, so *.impl, strings.provider and similar packages are left out. apidocs_test checks both sets, the JDK links and that each archive matches its site.
  • Classpath: javadoc runs once per reference in unnamed-module -sourcepath mode, over the source jars of the Bazel-built projects. Their compile classpath supplies the classes that Truffle's processors generate. No mx is involved.
  • JDK: --config=apidocs selects Labs JDK 25 for the doclet and javadoc. The targets are manual, so //... on JDK 21 skips them. JDK types link to the JDK 25 reference through a checked-in element-list.
  • Release settings: --//graal/apidocs:version sets 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_ref passes --source-ref.
  • Theme: the fork's name, header and footer links to elide-dev/graal, the UPL notice and GraalVM-like accent colors. It has no logo.

Why the targets live here, not in @graal

The @graal BUILD files are generated overlays (tools/generate-graal --check gates 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 that graal.source() selects. The elide-dev/graal workflow uses that to regenerate the overlays for a release commit and build these targets.

Pins

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:

  • 86 external {@snippet file=...} examples (DynamicObject, Source, TruffleLanguage, Node, ...). mx resolves them through --snippet-path; the doclet does not support external snippets yet.
  • One {@link R} to a type parameter (BytecodeDescriptor) and one @see with a trailing period (StaticProperty).
  • Source links are off. The doclet's {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 one sourceLink template cannot reach it.
  • Signatures stay on one line. The doclet looks for elide on PATH to wrap them, and the action has no PATH. elide_apidocs could pass the toolchain's Elide as --signature-formatter.

Testing

  • bazelisk test --config=apidocs //graal/apidocs:apidocs_test passes locally. CI runs it in both the PR and BuildBuddy steps.
  • Built against the 25.6.0-elide.1 release tree after tools/generate-graal --archive file://... --pin, as the graal workflow does: both references build in about a minute.

//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

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment thread graal/apidocs/defs.bzl
Comment on lines +77 to +84
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"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant