Share Scaladoc

sbt doc is a command nobody runs on purpose. It runs as part of publish, writes an API site into target/, and that site is uploaded to a repository or it is discarded. There is no middle option — which is unfortunate, because the middle is where most Scala code lives: internal libraries, a shared core module, a client's platform.

So the API documentation for the module everybody depends on exists as a directory under target/ that gets deleted by the next sbt clean.

Build it

sbt doc
# Scala 3 → target/scala-3.3.1/api/
# Scala 2 → target/scala-2.13/api/

For a multi-project build, the one people want is usually a specific module:

sbt core/doc
api/
├── index.html
├── com/acme/core/        # one page per package, class, trait, object
├── scripts/              # search index + navigation
└── styles/  images/

Opened from the filesystem the pages render, but search does not — the index is fetched over XHR, which a browser blocks from a file:// origin. That is the usual reason a zipped copy of API docs feels broken when it arrives by email.

Drop the folder in

Drag the api/ directory (or a zip of it) into Comma:

  • index.html becomes the report body.
  • Every package and class page plus scripts/ and styles/ upload alongside it, with relative references rewritten to the uploaded copies — which is what makes search and the member filter work again.
  • Scripts run inside a sandboxed iframe (allow-scripts, no allow-same-origin).

No artifactory path, no static bucket, no Pages branch.

From the release job

sbt core/doc

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 target/scala-3.3.1/api/index.html \
        --arg t "core — $VERSION" '{title: $t, html: $html}')"

Supporting pages go up through POST /api/v1/reports/$REPORT_ID/assets as base64. See the API reference and publishing from CI.

The case for commenting on a signature

Scala signatures are where the design is. A comment on def traverse[F[_]: Applicative, A, B](...) — "the implicit here means callers in the http module can't use this" — is a real design objection, and it is nearly impossible to raise usefully in a channel. Anchored to the rendered member page, it stays with the member across doc rebuilds. See commenting on HTML.

Limits

  • Entry HTML: 5 MB. Assets: 25 MB per file, 250 MB and 500 files total. A wide API surface can exceed 500 pages — publish one module per report, which is also how people read it.
  • Scripts run, sandboxed — no same-origin access.
  • 60 requests/minute per token.

Try it

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

Publish Scaladoc →

Related