Skip to content

Migrate documentation to Astro Starlight#1686

Draft
GreenFlux wants to merge 7 commits into
developfrom
docs/astro-migration
Draft

Migrate documentation to Astro Starlight#1686
GreenFlux wants to merge 7 commits into
developfrom
docs/astro-migration

Conversation

@GreenFlux
Copy link
Copy Markdown
Contributor

Status

Draft. Asking for an early structural look — happy to split this into separate PRs if reviewers prefer:

  1. Astro/Starlight foundation (config, custom components, build pipeline wiring)
  2. Content migration (the 55 guide pages + homepage + 404 moving into src/content/docs/)
  3. Documentation governance docs (CLAUDE.md, README-EDITING.md, README-DEPLOYMENT.md)
  4. starlight-page-actions feature + the right-sidebar UI placement

Currently three logical commits, easiest to review per-commit:

  • e227a2479 — Migrate documentation from VuePress to Astro Starlight
  • ec5c7d126 — Add documentation authoring standards and editing/deployment guides
  • 510fb6d5a — Move page action buttons into the right sidebar

Summary

Replaces the VuePress 1.x docs site with Astro 6 + Starlight 0.38. The previous docs/.vuepress/ configuration stays in place for now since it's no longer wired into the build pipeline — a separate cleanup will remove it.

Site structure

  • Guides, homepage, and 404 now live at docs/src/content/docs/ and are tracked in git (no longer regenerated on every build).
  • API reference under docs/src/content/docs/api/ is the only path still processed by scripts/generate-content.mjs (it normalizes TypeDoc output).
  • Netlify _redirects map preserves the legacy /docs/guide/<slug>.html → clean URLs and is auto-generated.

Custom Starlight component overrides

  • Head (Inter font, example-runner client script), Header (two-row HT-style nav with logo + version pill, search, GitHub stars, primary nav, support dropdown), Footer (link grid + social row), ThemeSelect (sun/moon toggle), PageTitle + PageSidebar (moves the Copy Markdown / Open in ChatGPT / Open in Claude buttons into the right sidebar under "On this page", matching the HT docs layout).

Plugins

  • starlight-theme-rapide (typography + chrome) and starlight-page-actions (page-action buttons + auto-generated .md companions next to each .html).

Authoring governance

  • docs/CLAUDE.md (symlinked from docs/AGENTS.md) — Diátaxis-based authoring rules, frontmatter schema with permanent 8-char IDs, code-example conventions (licenseKey: 'gpl-v3', builder methods), Excel/Google Sheets trademark callouts, and a PR checklist.
  • docs/README-EDITING.md — practical reference for Starlight-native asides, the live-runner HTML pattern, and sidebar registration.
  • docs/README-DEPLOYMENT.md — Netlify build chain, docs:build pipeline, GitHub Actions CI verification.

Build wiring

  • netlify.toml runs npm run docs:build from the repo root and publishes docs/dist.
  • .github/workflows/build-docs.yml runs the same command on PRs and pushes to master, develop, release/**.
  • Root docs:build script chains: bundle-alltypedoc:build-apicd docs && npm ci && npm run build.

Test plan

  • Verify the Netlify deploy preview renders correctly (link will appear in the PR after Netlify builds)
  • Spot-check the homepage, a guide page with a live ::: example block (e.g. /docs/guide/basic-usage), and an API ref page (e.g. /docs/api/classes/hyperformula)
  • Click through the right-sidebar action buttons on a guide page: Copy Markdown copies the page's .md companion, Open in ChatGPT / Open in Claude prefill a prompt
  • Verify the legacy .html URL redirects in _redirects resolve (e.g. /docs/guide/basic-usage.html/docs/guide/basic-usage)
  • Smoke-test theme switching (sun/moon toggle in the header)
  • Confirm npm run docs:build from the repo root completes without errors

Known follow-ups (not in this PR)

  • Remove the now-unused docs/.vuepress/ directory
  • Audit Excel/Google Sheets pages and add the trademark callouts documented in CLAUDE.md §9
  • Wire the docs-assistant chat widget (HT has it, HF would benefit from it; lower priority)
  • Decide whether to add "Print this page" / "Ask AI" buttons to match the full HT page-actions list

GreenFlux added 3 commits May 28, 2026 11:27
Replaces the VuePress 1.x docs site with Astro 6 + Starlight 0.38. The
previous `docs/.vuepress/` configuration stays in place for now since
it's no longer wired into the build pipeline -- a separate cleanup will
remove it.

Migration highlights:

- `docs/astro.config.mjs` configures Starlight with the Rapide theme,
  Expressive Code (line numbers + collapsible sections), a sitemap,
  and `starlight-page-actions` (Copy Markdown + Open in ChatGPT /
  Claude buttons on every page).
- Guide pages, the homepage, and the 404 move from the legacy
  `docs/guide/*.md` + `docs/index.md` tree into `src/content/docs/`
  and are tracked in git. They were run through the VuePress preprocessor
  once at migration time, so they now contain Starlight-native asides
  (`:::tip[Title]`), HTML `<details>` accordions, fully resolved
  `@[code]` includes, and rewritten links with the `/docs` base prefix.
- The TypeDoc-generated API reference is the only path that still
  passes through `scripts/generate-content.mjs` -- it normalizes
  TypeDoc's link forms and badge tokens.
- The Netlify `_redirects` file (legacy `.html` URLs → clean URLs) is
  also generated by `generate-content.mjs`, now derived from the
  tracked content under `src/content/docs/guide/`.
- Custom Starlight component overrides for `Head`, `Header`, `Footer`,
  and `ThemeSelect` reproduce the Handsontable docs look-and-feel
  (two-row header, sun/moon theme toggle, spreadsheet-style footer).
- Root build orchestration (`docs:build` script chain, Netlify build
  command, GitHub Actions `build-docs.yml`) updated to invoke the
  Astro build via `npm ci && npm run build` inside `docs/`.

Legacy `docs/guide/`, `docs/index.md`, and `docs/api-ref-readme.md`
are deleted -- their content lives under `src/content/docs/` now.
Introduces four governance files under `docs/` so contributors -- and
AI coding agents -- have a clear, self-contained reference for how to
work on the docs site:

- `docs/CLAUDE.md`: authoring standards. Diátaxis page-type taxonomy
  with folder-to-type mapping, voice and style rules with a banned-word
  list, four page-structure templates (tutorial / how-to / reference /
  explanation), example-data domain conventions, code-example rules
  (language tags, `licenseKey: 'gpl-v3'`, builder methods), the
  frontmatter schema with permanent 8-char IDs and the
  `| HyperFormula` metaTitle suffix, link conventions, the Excel /
  Google Sheets trademark notice text, the sidebar registration step,
  the Starlight-native asides / live-runner HTML pattern, and a PR
  checklist.
- `docs/AGENTS.md`: symlink to `CLAUDE.md` so both naming conventions
  resolve to the same file.
- `docs/README-EDITING.md`: practical reference -- frontmatter long-form,
  Starlight aside examples, the live-runner HTML pattern with file
  layout, line highlighting in code blocks, and sidebar registration.
- `docs/README-DEPLOYMENT.md`: deployment reference -- Netlify build
  command, the `docs:build` pipeline (`bundle-all` →
  `typedoc:build-api` → `npm ci && npm run build`), GitHub Actions CI
  verification, and the auto-generated `_redirects` map.
The `starlight-page-actions` plugin defaults to rendering its action
row directly under the page heading. Match the Handsontable docs UI by
moving the actions (Copy Markdown, Open in ChatGPT, Open in Claude)
into the right-hand sidebar, below the "On this page" table of
contents.

Adds two Starlight component overrides:

- `PageTitle.astro`: renders only the default page title and drops the
  plugin's button row. The plugin's override is suppressed because user-
  configured overrides win over plugin-supplied ones in Starlight.
- `PageSidebar.astro`: renders the default TOC, then appends a flat
  action list styled to match the right-sidebar typography. The Copy
  Markdown handler reuses the plugin's `.md` companion routes and shows
  a transient checkmark on success.
@netlify
Copy link
Copy Markdown

netlify Bot commented May 28, 2026

Deploy Preview for hyperformula-dev-docs ready!

Name Link
🔨 Latest commit 720ff8a
🔍 Latest deploy log https://app.netlify.com/projects/hyperformula-dev-docs/deploys/6a18718df156410008b71145
😎 Deploy Preview https://deploy-preview-1686--hyperformula-dev-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread docs/src/plugins/vuepress-preprocessor.mjs Fixed
CI flagged two issues on PR #1686:

- The `build-docs` GitHub Actions job and the Netlify deploy preview
  both failed because Astro 6 requires Node >=22.12.0, but every Node
  pin in the docs setup specified 20. Bump `.nvmrc`, the docs
  `engines.node` constraint, the `build-docs.yml` job matrix, the
  Netlify `NODE_VERSION`, and the "Node 20" mentions in the README /
  CLAUDE.md / README-DEPLOYMENT to 22 (22.12 for the engines pin).
- CodeQL flagged `cleanTitleText()` in `vuepress-preprocessor.mjs` for
  incomplete multi-character sanitization (`js/incomplete-multi-character-sanitization`).
  A single pass of `/<[^>]+>/g` could leave a `<script>` substring
  behind for inputs like `<sc<script>ript>`. Iterate the strip to a
  fixed point so nested tags collapse fully. The downstream consumer
  (Starlight rendering a YAML `title:`) already escapes HTML, so this
  is defence-in-depth, but the warning is correct in principle.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 28, 2026

Performance comparison of head (720ff8a) vs base (c7cfc9d)

                                     testName |   base |   head |  change
-------------------------------------------------------------------------
                                      Sheet A | 499.92 | 498.25 |  -0.33%
                                      Sheet B | 158.63 | 164.52 |  +3.71%
                                      Sheet T | 138.36 | 140.85 |  +1.80%
                                Column ranges | 517.79 | 540.57 |  +4.40%
Sheet A:  change value, add/remove row/column |  15.27 |  19.62 | +28.49%
 Sheet B: change value, add/remove row/column | 139.58 | 150.84 |  +8.07%
                   Column ranges - add column | 156.63 | 170.62 |  +8.93%
                Column ranges - without batch | 484.83 | 521.59 |  +7.58%
                        Column ranges - batch |  126.1 | 135.36 |  +7.34%

GreenFlux added 3 commits May 28, 2026 12:19
The Netlify deploy preview for #1686 kept failing with
"Node.js v18.20.8 is not supported by Astro" even after setting
NODE_VERSION = "22" in netlify.toml's [build.environment]. The deploy
log showed Netlify resolving Node from the root .nvmrc ("v18") rather
than honoring the netlify.toml env var. Bump .nvmrc to 22 so both
sources agree.

The HyperFormula library is already exercised on Node 20/22/24 by
.github/workflows/build.yml, so bumping the local-dev default to 22 is
consistent with what CI already tests.
Astro builds the site with `base: '/docs'`, so generated HTML
references `/docs/_astro/*`, `/docs/guide/*`, etc. In production the
canonical URL `hyperformula.handsontable.com/docs/` is served by a
reverse proxy that strips the `/docs` prefix before forwarding to the
Netlify project, so the prefix in the HTML resolves to the right files.

Netlify deploy previews (and the netlify.app subdomain in general)
don't sit behind that proxy, so `/docs/`-prefixed paths 404 — only the
home page rendered, and even then without styles or images because
every `/docs/_astro/*` URL came back as a 404. Add a wildcard rewrite
to netlify.toml so the preview mimics the production proxy: any
`/docs/<path>` request is served from `<path>` in the publish directory.

The Astro-generated `_redirects` file is processed first (so the legacy
`.html` → clean URL redirects still match), then this catch-all
rewrites everything else.
The version pill in the docs header rendered as "v0.0.0" on the Netlify
deploy preview even though the same code returned the correct "3.3.0"
locally. The cause was the brittle `../../..` arithmetic used to find
the library root: in some build environments (apparently Astro's
build container on Netlify), `import.meta.url` resolves through a
location that's one directory deeper than expected, so three parent
hops landed inside `docs/` instead of at the repo root. That made the
fallback read `docs/package.json` (version `0.0.0`) instead of the
library's `package.json`.

Replace the path arithmetic with an upward walk that stops at the first
`package.json` whose `name` is `hyperformula`. This is robust to any
build-cache layout. While here, also fall back gracefully when the UMD
bundle exists but is missing individual fields.
@GreenFlux
Copy link
Copy Markdown
Contributor Author

@sequba @sl01k , this is still a draft, but it's getting close. Here's the latest DP if you want to have a look:
https://deploy-preview-1686--hyperformula-dev-docs.netlify.app/

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.16%. Comparing base (c7cfc9d) to head (720ff8a).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1686   +/-   ##
========================================
  Coverage    97.16%   97.16%           
========================================
  Files          176      176           
  Lines        15322    15322           
  Branches      3356     3356           
========================================
  Hits         14887    14887           
  Misses         427      427           
  Partials         8        8           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants