Skip to content

feat: add Java API reference (javadoc) - #70

Open
chinaux wants to merge 3 commits into
zvec-ai:mainfrom
chinaux:feat/java-api-reference
Open

chinaux wants to merge 3 commits into
zvec-ai:mainfrom
chinaux:feat/java-api-reference

Conversation

@chinaux

@chinaux chinaux commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

What

Add the Java API reference, following the same pattern as the Python (mkdocs) and Node.js (typedoc) references: a standalone source project under api-reference/java-api/ that builds static HTML into public/api-reference/java/.

  • api-reference/java-api/build.sh — resolves the latest org.zvec:zvec-java release from Maven metadata (ZVEC_JAVA_VERSION pins it), downloads the -sources.jar, drops org.zvec.binding.examples (guides, not API surface), runs javadoc, then injects the site favicon and styles/extra.css for light branding
  • app/[lang]/(home)/api-reference/page.tsx — Java card (en/zh) linking to /api-reference/java/
  • app/llms.txt/route.ts — mentions the Java reference
  • both website workflows — set up Java and run the java-api build
  • .gitignore — generated output plus the local build dir

Output: 182 HTML pages covering org.zvec.binding (74 types) and org.zvec.binding.presets, 4.6 MB, gitignored and built in CI like the other two references.

Notes on the javadoc invocation

  • JavaCPP on the classpath: the JNI bindings are annotated with org.bytedeco.javacpp types. Javadoc 9+ reports unresolved symbols as errors, so without that dependency the build fails with 100 errors on any modern JDK. The script reads javacpp.version from the zvec-java POM and downloads the matching jar (1.5.11 for 0.7.0); warnings drop from 100 to 8, all pre-existing doc-comment nits in the SDK sources.
  • English output regardless of host locale: -J-Duser.language=en -J-Duser.country=US. Building on a machine with a non-English locale otherwise yields a localized javadoc UI (e.g. Chinese navigation labels). -locale was not an option here because JDK 8 requires it to be the first argument.
  • JDK pinned to 17+, preferring 21: javadoc 11 removed frame-based output, so JDK 8 and JDK 17+ produce completely different sites. CI builds with temurin 21 and the script selects the same major locally ($JAVADOC → 21 → 17+ → PATH), erroring out below 17 so local output matches what gets deployed.

Tested locally

  • ./build.sh exits 0 on JDK 21; no generated file contains CJK characters; index.html is the HTML5 overview page (no frameset)
  • next dev serves /api-reference/java/index.html, class pages and zvec-extra.css with 200, and the Java card renders on both /en/api-reference/ and /zh/api-reference/
  • the static export served over python3 -m http.server resolves the directory route /api-reference/java/ (next dev does not do directory-index routing for public/, same as the existing python/nodejs references)

Adds api-reference/java-api, a standalone project that generates the Javadoc
site for the official Java SDK (org.zvec:zvec-java) into
public/api-reference/java/, mirroring how the Python (mkdocs) and Node.js
(typedoc) references are built.

- build.sh resolves the latest release from Maven metadata, downloads the
  -sources.jar, drops the examples package and runs javadoc.
- The org.bytedeco:javacpp artifact the JNI bindings are annotated with is put
  on the classpath: javadoc 9+ reports unresolved symbols as errors.
- Output is pinned to English via -J-Duser.language/-J-Duser.country so host
  locale cannot leak into the generated UI.
- Javadoc 11 dropped frame-based output, so the script requires JDK 17+ and
  prefers 21 to match CI (setup-java temurin 21).
- Adds the Java card to /api-reference (en/zh), mentions Java in llms.txt and
  builds the reference in both website workflows.
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

☁️ Cloudflare Pages preview: https://9abb3233.zvec-web.pages.dev

Doc comments that contain raw angle brackets (the JNI bindings mention C++
types such as std::shared_ptr<zvec::Collection>*) are not valid HTML, so
javadoc replaces the offending character with a marker span and renders it in
the page: "Internally maps to std::shared_ptr invalid input: '<' zvec::Collection>*".

Replace the marker with the character javadoc reported. The surrounding text is
already escaped correctly, so the comment reads as intended again. Logs how many
markers were restored and warns if any invalid-tag markup survives, so a future
change to the marker format cannot fail silently.
JavaCPP copies the Doxygen comments of zvec/c_api.h verbatim into the
generated bindings, and javadoc renders whatever it cannot parse:

- a raw '<' that cannot start an HTML tag (std::shared_ptr<zvec::Collection>*)
  makes javadoc emit "invalid input: '<'" and print that marker in the page;
- commands javadoc does not know (\brief, \note) are printed literally, which
  leaked "\brief" into the generated pages.

Fix both at the source instead of patching the output:
scripts/clean_doc_comments.py rewrites the doc comments of the downloaded
sources before javadoc runs. It only touches /** ... */ comments, skips string
and char literals (the sources contain a "\u2014" message), and leaves
{@code ...} / {@link ...} spans alone because javadoc already escapes their
content.

javadoc warnings for zvec-java 0.7.0 drop from 6 "invalid input" to 0, and the
marker repair from the previous commit now reports "Restored 0" and stays as a
fallback. The two remaining "@PARAM ... is not a parameter name" warnings are
upstream: c_api.h documents a deleted_count parameter that
zvec_collection_delete_by_filter does not take, and JavaCPP renames the capacity
parameter of zvec_byte_array_create to _capacity.

This branch has not been deployed

No deployments
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