Skip to content
elide-devPublic

About

📚 beautiful javadoc + dokka

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Elide Doclet

Generate a static API reference for a Java library through Javadoc, Gradle, or Maven. Every build extracts the library’s public API into api.json and renders HTML and Markdown from that model. Open index.html directly or publish the output directory. Pages, styles, search, and navigation work offline.

Run Javadoc with JDK 25. The build also needs Node.js or Bun on PATH to execute the renderer bundled in the JAR. Readers only need a browser. The documentation JDK can be newer than the library’s Java target.

Standalone Javadoc

javadoc -doclet dev.elide.doclet.ElideDoclet -docletpath tools/elide-doclet.jar \
  -d build/docs --module-name catalogue --module-version 1.0 \
  -sourcepath src/main/java -subpackages com.example

The name and version are optional. A named Java module supplies the default title. Gradle and Maven supply the project’s name and version.

Besides the HTML pages, a site has a Markdown twin of every page, llms.txt and llms-full.txt for AI agents, and api.json, the model. Leave any of them out with --no-markdown, --no-llms, or --no-model; the pages then link only to the files the site has. In Gradle, add them to the Javadoc task with options.addBooleanOption("-no-markdown", true).

Each HTML page advertises its Markdown twin with one rel="alternate" type="text/markdown" link. Clients can also discover the alphabetical index, llms.txt, and the declaration contracts from the HTML head without running scripts.

In a type’s Markdown page, each member is one line under its heading: its anchor, signature, version and deprecation notes, full description, parameters, result, exceptions, and the address to cite. A text search of the page for a name or for any word of the documentation returns the whole declaration. A parameter or result without documentation is left to the signature. Example code and tables follow the line as blocks. Links to other pages of the reference are reduced to their labels on these lines; index-all.md and the HTML pages keep the links.

The output is shaped for rg and grep as well as for browsers. HTML pages end a line inside each block element’s opening tag, so a match returns one short line instead of a whole page and rendering is unchanged. A page’s head lists no member names, and a member’s own link is a fragment, so a search for a member or for the type’s name matches the declarations and not the page furniture. A .ignore file at the root keeps recursive ripgrep, ag and fd searches out of the bundled copies (api.json, llms-full.txt, contracts.ndjson, assets) and, when Markdown is generated, out of the HTML pages, so each declaration is listed and matched once; naming a file still searches it. For a module with more than 32 types, the landing page lists each package’s types by name, as links in HTML, and leaves signatures and summaries to the package pages.

Search index-all.md for a name such as BuildPlan.defaults or for words describing the behavior you need. Each member row shows its declaring type, parameter types, and documented summary when available. Follow the matching overload for the full declaration.

For structured lookups, API modules publish contracts.ndjson alongside llms.txt. Each JSON line has a qualified symbol, the declaration’s signature and canonical HTML href, plus its documented summary, parameters, return value, exceptions and deprecation details.

jq -c 'select(.symbol | contains("BuildStep.prepare(")) | {symbol, href, signature}' contracts.ndjson
jq -c 'select(.symbol == "example.runtime.BuildPlan.defaults(String)")' contracts.ndjson

Lookup symbols use compact parameter types. Two overloads can share a display spelling when parameter types come from different packages. The canonical href identifies each overload and carries the same fragment as its Markdown twin. When a record has detailsOmitted: true, open that fragment for the full prose. --no-llms disables the declaration index along with the other agent outputs.

From this checkout, use the same links to look up a declaration from a generated site. The reader reports a matching answer with its supporting clause when available, plus the selected declaration and excerpt.

python3 scripts/query_docs.py https://elide-dev.github.io/doclet/graalvm/ 'What compiler arguments does BuildPlan.defaults use?'
python3 scripts/query_docs.py build/docs 'What does Client.connect return?' --html-entry

A local HTML file also works. Use --site-root for an entry below the documentation root. The generated-site reader expects Markdown or a declaration contract index. To query standard Javadoc, pass --format html. For an ambiguous lookup, --candidates 3 returns up to three citable declarations sharing the same excerpt budget.

Every page holds only its own path through the navigation tree: its package, that package’s types, and the current type’s nested types. The whole tree is loaded once from assets/nav.js, which works from file:// too, so a page’s size follows its own content rather than the size of the library.

For a standalone model export, use --model-only. It writes api.json into the output directory and skips the JavaScript runtime. Use an empty directory for a model-only build.

Gradle

For a released version, add the public Elide Maven repository to the top-level pluginManagement block in settings.gradle.kts.

pluginManagement {
    repositories {
        maven {
            url = uri("https://maven.elide.dev")
        }
        gradlePluginPortal()
    }
}

Apply the plugin in build.gradle.kts and run ./gradlew javadoc. The plugin configures existing and future Javadoc tasks, including their doclet path.

plugins {
    java
    id("dev.elide.doclet") version "0.4.0" // x-release-please-version
}

Maven

Add the repository and plugin to the consuming POM, then run mvn elide-doclet:javadoc. To generate docs during mvn package, add an execution for the javadoc goal. Its default phase is prepare-package.

<pluginRepositories>
  <pluginRepository>
    <id>elide-doclet</id>
    <url>https://maven.elide.dev</url>
  </pluginRepository>
</pluginRepositories>
<build>
  <plugins>
    <plugin>
      <groupId>dev.elide</groupId>
      <artifactId>elide-doclet-maven-plugin</artifactId>
      <version>0.4.0</version><!-- x-release-please-version -->
    </plugin>
  </plugins>
</build>

Guides and signature layout

Pass a directory of Markdown files to publish narrative pages with the API. For example, docs/guides/lookup.md generates guides/lookup.html and its Markdown twin.

# Look up a book

Use [the catalog](api/example.Example) to [find a title](api/example.Example#find(java.lang.String)).

Start each file with a level-one title. The first paragraph supplies the summary for listings and search. Use lowercase letters, digits, and hyphens for file and directory names. An optional root index.md supplies the module overview. An api/ link uses the exact type or member ID from api.json, including $ for nested types. The linked type lists the guide under See also. A missing API target fails the build and names the guide to fix.

Entry point Guide directory Signature formatter
Javadoc --guides docs/guides --signature-formatter <executable-or-none>
Gradle properties elideDoclet.guides=docs/guides elideDoclet.signatureFormatter=none
Maven plugin configuration <guides>docs/guides</guides> <signatureFormatter>none</signatureFormatter>

By default the generator looks for elide on PATH and uses it to wrap long declarations while preserving type links. If Elide is unavailable, or you select none, declarations keep their single-line layout. Formatting and guide references are part of the shared API model, so HTML and Markdown use the same declarations and links.

Kotlin and Dokka

Add dev.elide:elide-doclet-dokka-plugin:<version> from the public Elide Maven repository to Dokka's plugins classpath alongside dokka-base and analysis-kotlin-symbols 2.3.0. Include its transitive core dependency. The plugin reads a JVM source set and renders the same reference from Kotlin declarations and KDoc. Set its JSON configuration under dev.elide.apidocs.dokka.ApiDocsPlugin. Options include theme, moduleVersion, signatureFormatter, and modelOnly. See the runnable Dokka consumer.

Multiple modules and releases

Build each module's standalone site with its model and search index. List the sites in a JSON manifest, newest version first. Module paths are relative to the manifest.

{
  "title": "Library documentation",
  "latest": "v2",
  "versions": [
    {"id": "v2", "modules": {"core": "build/v2/core", "sdk": "build/v2/sdk"},
     "suites": {"handbook": {"title": "Developer handbook", "directory": "docs/handbook"}}},
    {"id": "v1", "modules": {"core": "build/v1/core"}}
  ]
}
java -cp elide-doclet.jar dev.elide.apidocs.render.Catalog build catalog.json build/reference
java -cp elide-doclet.jar dev.elide.apidocs.render.Catalog serve build/reference 8080

Build into a new output directory, then publish its contents to any static host. The catalog offers version and module navigation, cross-module guide and API search, a latest/ copy of the selected release, and API changes against each older release. Version links preserve the current page when it exists. The optional loopback HTTP server serves standalone sites too. Request an HTML URL with Accept: text/markdown to receive its Markdown twin, or use the explicit .md URL on GitHub Pages.

A guide suite is a directory of Markdown files using the same title and first-paragraph summary format as module guides. In a suite, write links as [label](api/<module>/<declaration-id>). Kotlin types also accept their qualified name. The catalog validates links against that version’s Java and Kotlin models, adds backlinks on the declaration pages, and makes all suites and modules searchable from the reference search box. Keep drafts under a drafts/ directory. Set "includeDrafts": true on a preview version to include them. Shared Java and Kotlin sample

Release quality checks

CI builds the shared catalog from real Javadoc and Dokka output. Mobile Lighthouse checks the guide and both linked API pages for performance (90), accessibility (100), best practices (95), SEO (95), and layout shift (at most 0.05). Stylelint checks authored gallery, theme and catalog CSS against selected Good CSS practices for logical properties, focus outlines and transitions.

AFDocs scans a specific Java type, Kotlin type, and cross-module guide before release. Each must pass index validity, Markdown availability, HTML/Markdown content parity, and HTTP negotiation checks. The build also resolves relative index links and checks guide backlinks, member anchors, JSON-LD, and the API model. After deployment, Pages repeats the content checks and reports how the host handles Markdown negotiation. GitHub Pages serves HTML for that header, so clients can follow the explicit Markdown link. CI saves candidate reports in the quality-reports artifact.

Evaluating documentation for agents

Run the benchmark locally with JDK 25 on PATH after scripts/build-samples and scripts/build-shared-sample. The offline run needs no model account. CI continues to enforce AFDocs and the generated-site checks.

python3 scripts/eval-docs.py --chars 600
python3 scripts/eval-docs.py --account codex --model gpt-6-luna --effort low --chars 600 --output .dev/luna.json

Routine comparisons use GPT-6 Luna at low effort through the locally signed-in Codex CLI. Reserve GPT-6.2 Astra at ultra effort for a separate, explicitly selected full verification round. Each question gets a fresh CLI process in a temporary directory with the question and one retrieved document excerpt. Paired mode alternates which format runs first across ten questions (20 calls). Use --all-variants for the full three-index by two-format ablation (60 calls).

The JDK builds standard Javadoc from the same Java sources. Each variant uses the same lexical retriever and maximum reading budget. Reports include the chosen page, evidence and answer checks, and per-question elapsed time. Timing includes local retrieval, CLI startup, and the hosted turn; it excludes building the two sites. Account runs record provider input, cached input, cache writes, and output tokens. Cached counts are subsets of input; the local lexical index is read by Python and never sent to the model. Timing varies with provider load and cache state.

The offline run measures page and evidence retrieval across all six variants. Account runs also check the answer against the fixture's expected pattern and require the expected evidence in the retrieved page. Inspect the recorded answers when comparing models. To use a different reader, pass --reader './your-wrapper' and --reader-label 'model and settings'; the wrapper reads a prompt on stdin and writes an answer to stdout. The default report is .dev/quality/doc-evals.json.

Branding

The default theme uses the library name. Supply a JSON theme to change the header, light and dark colors, logos, navigation, footer, and source links. For example, save this as docs/theme.json:

{
  "productName": "Field Guide SDK",
  "brand": "Field Guide",
  "tokens": {
    "light": { "accent": "#345b84" },
    "dark": { "accent": "#99c4ed" }
  },
  "footer": "Field Guide developer documentation"
}
Entry point Theme configuration
Javadoc Add --theme docs/theme.json to the command
Gradle Set elideDoclet.theme=docs/theme.json in gradle.properties
Maven Add <configuration><theme>${project.basedir}/docs/theme.json</theme></configuration> to the plugin

For a logo, set logo.light and logo.dark to SVG markup and logo.alt to its accessible name. Set baseUrl to generate canonical URLs and a sitemap. The renderer accepts the complete theme definition.

Standard doclet options

The doclet accepts the standard doclet's common options, so an existing Javadoc configuration keeps working:

  • -link <url> and -linkoffline <url> <dir-or-url> read another Javadoc site's element-list (or package-list). Types, members and packages from that site link to its pages in signatures and in {@link}. Modular sites get a directory per module. For example, -linkoffline https://docs.oracle.com/en/java/javase/25/docs/api/ <dir with the JDK's element-list> links JDK types. If a list cannot be read, javadoc prints a warning and the run continues.
  • -tag <name>:<locations>:<header> defines a custom block tag. Its content follows the description under the header. A tag whose locations include X is left out.
  • -windowtitle, -doctitle, -notimestamp and -quiet work as before.
  • Javadoc accepts these options and prints a warning that they have no effect: -header, -bottom, -footer, -top, -use, -author, -version, -splitindex, -nonavbar, -nodeprecated, -nodeprecatedlist, -nohelp, -noindex, -nosince, -notree, -linksource, -stylesheetfile, -overview, -group, -charset, -docencoding and similar presentation options. To change branding and the footer, use a theme.

Comment problems

By default, any comment the API model cannot represent stops the run with an error, so the reference never silently loses content. Examples are an unknown inline tag, a reference that does not resolve, or {@inheritDoc} with nothing to inherit. Each error ends with its category, such as [reference].

To publish while you fix comments, report problems as warnings instead. The affected parts are simplified or left out. --problems takes error or warning and accepts per-category overrides. Later entries win.

--problems warning                           # every problem is a warning
--problems error,inline-tag=warning          # only unknown inline tags are warnings
--problems warning,reference=error           # everything but unresolved references is a warning

Categories: inheritdoc, block-tag, inline-tag, snippet, reference, html, url, value, param, malformed, unsupported.

Entry point Problem severity
Javadoc Add --problems warning to the command
Gradle Set elideDoclet.problems=warning in gradle.properties
Maven Add <configuration><problems>warning</problems></configuration> to the plugin, or pass -DelideDoclet.problems=warning

Build and verify

mise trust
mise install
mise exec -- hk install
elide build
(cd doclet && elide test --coverage --reporter=junit)
scripts/smoke-test
scripts/build-samples && scripts/check-size .dev/pages/signal
elide publish --dry-run
scripts/smoke-test-plugins

The standalone test loads the published JAR through Javadoc. scripts/check-size holds every sample theme’s site to a size budget: each page’s navigator, shell, and inline SVG, the HTML per page, and the site’s text files. The plugin tests build one example API with each tool, verify its model, HTML, Markdown, and search assets, then render it again with a custom theme. Run one consumer with scripts/smoke-test-plugins gradle or scripts/smoke-test-plugins maven.

The shared model and DocumentationSite.write have no Javadoc dependencies. Another frontend can produce an Api.Model and use the same renderer. The renderer distribution is checked in so building the doclet or using it offline requires no frontend dependency installation. To refresh it from a components checkout, run scripts/update-renderer /path/to/components.

To try the plugins before a release, run elide publish from the workspace root. Maven uses the local repository automatically. In Gradle, add mavenLocal() to pluginManagement.repositories. The standalone core remains available as dev.elide:elide-doclet:<version> for direct use with javadoc -doclet dev.elide.doclet.ElideDoclet -docletpath <jar>.

Releases

Release Please updates the workspace members together from Conventional Commits on main. On release, CI publishes the tested JARs and POMs with checksums to the public Elide Maven repository on R2 and attaches them to the GitHub release.

Theme gallery

Browse the sample gallery or edit the sample themes. Run scripts/build-samples and open .dev/pages/index.html to compare the module overview, package, guides, and Java declarations across all seven themes. The gallery links to each rendered reference and its complete JSON configuration. The GraalVM sample uses artwork from the official brand resources. The Micronaut and Google samples embed the Micronaut wordmark and Google wordmark.

For an interactive preview, serve the generated folder with python3 -m http.server 8787 --bind 127.0.0.1 --directory .dev/pages and open http://127.0.0.1:8787/preview.html. Rerun scripts/build-samples after editing a theme and reload the preview.

About

📚 beautiful javadoc + dokka

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages