Share Dokka HTML docs

Dokka's HTML output is the nicest-looking API reference in the JVM world, and it has a specific failure that catches everyone once: double-clicking index.html gives you a page with an empty navigation pane and a search box that finds nothing.

That is not a broken build. The site loads its navigation and search index as separate resources, and browsers refuse those requests from a file:// origin. Dokka's output needs to be served over HTTP.

Generate

Dokka 2:

./gradlew dokkaGenerate         # → build/dokka/html/

Dokka 1:

./gradlew dokkaHtml             # → build/dokka/html/
./gradlew dokkaHtmlMultiModule  # multi-module: one site with a module index

Publish the folder

Drag build/dokka/html/ (or a zip of it) into the app:

  • index.html becomes the report body.
  • navigation.html, the search index, scripts/, styles/, images/ and every package and class page upload as assets, and their references are rewritten to the uploaded copies.
  • Scripts run inside a sandboxed iframe (allow-scripts, no allow-same-origin), so the nav tree expands and search returns results.

The requests that fail at file:// succeed over HTTP. That is the entire fix, and it is also why "just zip it and send it" never works for Dokka.

From CI

./gradlew dokkaGenerate

curl -fsS -X PATCH "https://commareports.com/api/v1/reports/$REPORT_ID" \
  -H "Authorization: Bearer $COMMA_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --rawfile html build/dokka/html/index.html \
        --arg title "API docs — $VERSION" '{title: $title, html: $html}')"

PATCH one report id per library and the link stays valid across releases, with each release kept as a revision. See the API docs for the asset endpoint.

What review adds

  • Anchored threads on a class or function — missing @throws, a stale sample, a nullable return nobody documented. See commenting on HTML.
  • Access per report — private while the API is unstable, public at release. See the sharing model.

Limits

  • Entry HTML: 5 MB. Assets: 25 MB per file, 250 MB and 500 files total. A large multi-module project is the case that approaches the file cap — publish per module if it does.
  • 60 requests/minute per token.

Try it

Comma is free — unlimited reports, unlimited commenters, unlimited revision history.

Publish generated docs →

Related