Skip to content

Multiple Versions: Support for docs for multiple stdlib versions #101

@duaneatat

Description

@duaneatat

Users need to view documentation for specific stdlib versions (e.g., v0.2.0, v0.1.0) to match the version they're using in their projects. Currently, we only show docs for "latest" (the develop branch), and the 7.7GB of generated HTML is committed to git. Supporting 10 versions would add 77GB+ to the repository, making this approach unsustainable.

Proposed Solution

Store documentation on Cloudflare R2 (S3-compatible object storage) and serve via CDN, rather than committing to git. Simple environment-based routing: development serves local builds only, production proxies all requests to R2. A dropdown is shown in the UI based on environment. In local development it's based on the contents of the file system (public/docs/api/) and when serving docs from R2 (e.g. prod), it is based on the contents of the R2 bucket.

Implementation sketch

1. Make build system version-aware

Make build scripts respect STDLIB_VERSION environment variable and output to version-specific directories (e.g., public/docs/api/v0.2.0/). When building, always clone stdlib into node_modules/@stdlib/stdlib - defaulting to develop branch for latest, or the specified version/tag otherwise.

2. Add make target for R2 deployment

Create make push-docs-to-r2 target that uploads built docs from filesystem to R2 (requires credentials). Used by both GitHub Actions and developers with R2 access.

3. Simple server routing (dev vs prod)

  • Development (SERVE_DOCS_FROM_R2=false): Serve docs from local filesystem only
  • Production (SERVE_DOCS_FROM_R2=true): Proxy all /docs/* requests to R2
  • No fallback complexity - one code path per environment

4. Dynamic /docs/versions endpoint

Add /docs/versions endpoint that dynamically:

  • if SERVE_DOCS_FROM_R2=false: scans public/docs/api/ for available versions
  • if SERVE_DOCS_FROM_R2=true: queries R2 bucket to list available versions

5. Add version selector UI

Build dropdown component that fetches versions from /docs/versions.json and allows users to switch between documentation versions.

6. Automate builds with GitHub Actions

Create workflow that builds docs for any version and uploads directly to R2 (no git commits needed - built docs are gitignored).

7. Remove committed docs from git

Remove ~7.7GB of committed docs from git history. All docs now live exclusively on R2, or built locally in development.

Metadata

Metadata

Assignees

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions