diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 42bd21af6..4ff9284e9 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -190,7 +190,7 @@ A link the page marks for a preview card must have a card to show. The preview check hovers the C function link of a method page, then asks for the payload of every marked link on four pages. It asks only for destinations the dev build serves: one version of each port's reference, as its build target says, so the -Python reference that the other ports link to at `stable` is not asked for. What +Python reference that the other ports link to at its default version is not asked for. What it leaves out is bounded: only reference trees whose publisher owns the version tree (`publishesOwnTree`), at versions the dev build does not serve. A payload missing on a port the build does serve is reported, and the check fails if it diff --git a/.github/workflows/deploy-shell.yml b/.github/workflows/deploy-shell.yml index 6cca5f264..eb9ed6683 100644 --- a/.github/workflows/deploy-shell.yml +++ b/.github/workflows/deploy-shell.yml @@ -4,7 +4,7 @@ name: deploy-shell # and historical versions remain owned by their port publishers. # # The shell has no versioned URL space of its own (notes/research/06: root -# is always "whatever's on trunk," never /latest/ or /stable/ like a port). +# is always "whatever's on trunk," never /latest/ like a port). # A tag here is a release marker for this repo's own history; it deploys to # the same root a trunk push does, not a separate prefix. Release branches # are a per-port version concept (versions.ts VersionKind 'branch', e.g. diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 31de141d2..c40da4de6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,7 +3,7 @@ name: publish # One dispatch publishes any set of ports at a ref (scripts/publish-plan.mjs): # # ports: all ref: latest every default branch as latest -# ports: all ref: release every newest release, + alias +# ports: all ref: release every newest release, + next if prerelease # ports: rs ref: one exact ref, as the inputs name # # The plan runs everywhere and needs no credentials, so a dry run (the diff --git a/.github/workflows/reusable-deploy.yml b/.github/workflows/reusable-deploy.yml index be5000d7b..67dc102a7 100644 --- a/.github/workflows/reusable-deploy.yml +++ b/.github/workflows/reusable-deploy.yml @@ -19,7 +19,7 @@ on: inputs: path-prefix: description: > - S3 key prefix this call may write, e.g. 'py/v0.46.2', 'py/stable', + S3 key prefix this call may write, e.g. 'py/v0.46.2', 'py/next', 'pr-42'. Validated below, not just documented — this is the one thing standing between a caller and every other prefix in the bucket. @@ -57,7 +57,7 @@ on: type: string default: '' version: - description: Version slug for the manifest entry (VersionEntry.slug), e.g. 'v0.46.2', 'stable'. Required when `port` is set. + description: Version slug for the manifest entry (VersionEntry.slug), e.g. 'v0.46.2', 'next'. Required when `port` is set. required: false type: string default: '' @@ -147,7 +147,7 @@ jobs: reserved=(py ruby lua powershell julia elixir ts rs go java kotlin scala csharp fsharp cxx swift manifest _shell) for r in "${reserved[@]}"; do if [[ "$p" == "$r" ]]; then - echo "::error::path-prefix '$p' is a bare reserved top-level name — qualify it, e.g. '$r/stable'" >&2 + echo "::error::path-prefix '$p' is a bare reserved top-level name — qualify it, e.g. '$r/latest'" >&2 exit 1 fi done diff --git a/docs/ci.md b/docs/ci.md index d2bc3d5c7..f14469d55 100644 --- a/docs/ci.md +++ b/docs/ci.md @@ -49,7 +49,7 @@ caller cannot hand an immutable tag a five-minute TTL by copy-paste: | `tag` | `py/v0.46.2` | `public, max-age=31536000, immutable` | | `trunk` | `py/latest` | `public, max-age=0, s-maxage=300` | | `branch` | `py/v0.x` | `public, max-age=0, s-maxage=300` | -| `alias` | `py/stable` | `public, max-age=0, s-maxage=300` | +| `alias` | `py/next` | `public, max-age=0, s-maxage=300` | | `pr` | `ruby/pr-42` | `public, max-age=0, s-maxage=300` | No column for invalidation, because this workflow issues none. Every mutable @@ -63,28 +63,27 @@ per request, so CloudFront never caches it — it returns `x-cache: FunctionGeneratedResponse` every time — and invalidating a URL that is generated rather than stored clears nothing. -A tag push on a port repo normally calls `reusable-deploy.yml` twice — once -with `version-kind: tag` at the immutable prefix, once more with -`version-kind: alias` at `stable` if that tag becomes the new default — since -`/stable/` and `/latest/` are separate builds with their own base path and -canonical URL, never edge rewrites of the tag's bytes. The second call adds -`resolves-to` so the manifest entry carries `VersionEntry.resolvesTo`: +A tag push on a port repo calls `reusable-deploy.yml` once with +`version-kind: tag` at the immutable prefix. A final release that is newer than +every other final release tag also passes `is-default: true`, so the manifest's +`defaultVersion` names it; an older backport tag never takes the default. A +prerelease adds a second call with `version-kind: alias` at `next`, which +carries `resolves-to` so the manifest entry has `VersionEntry.resolvesTo`: ```yaml with: - path-prefix: py/stable - artifact: docs-html-stable + path-prefix: py/next + artifact: docs-html-next version-kind: alias port: py - version: stable - resolves-to: v0.46.2 - is-default: true + version: next + resolves-to: v0.47.0a1 environment: docs ``` -The prefix a caller passes is its own — `py/stable`, `py/v0.46.2` — and the +The prefix a caller passes is its own — `py/next`, `py/v0.46.2` — and the workflow prepends the locale before writing, so those objects land at -`en/py/stable` and `en/py/v0.46.2`. That is applied on this side rather than +`en/py/next` and `en/py/v0.46.2`. That is applied on this side rather than asked of the caller because the caller is each port's own repository, and moving a segment would otherwise be a coordinated edit across ten of them. A pull-request preview keeps its own shape: it owns its whole prefix and nests @@ -264,9 +263,9 @@ The events it answers (`scripts/port-docs-identity.sh`): - A pull request builds `latest` at its merge commit and publishes nothing. - A push to the default branch publishes `latest`. It is the default only - until the port's first stable release tag. -- A release tag publishes its version plus `next` (prerelease) or `stable` - (release, the default). + until the port's first final release tag. +- A release tag publishes its version, plus `next` for a prerelease. A final + release is the default only when no newer final release tag exists. - A dispatch publishes exactly what it names, at any ref. From the port's checkout: @@ -299,7 +298,7 @@ The dispatcher plans first and stops there by default: | `ports` | `ref` | Publishes | |---|---|---| | `all` or a list | `latest` | each default branch as `latest` | -| `all` or a list | `release` | each newest release tag, plus `next` or `stable` | +| `all` or a list | `release` | each newest release tag, the default when final, plus `next` when a prerelease | | one port | an exact ref | that ref, as `version` and `version-kind` name it | ```console @@ -378,7 +377,7 @@ A branch or tag containing the publisher is insufficient for role assumption. ## This repo's own deploy (`deploy-shell.yml`) The shell has no versioned URL space: the bucket root is always "whatever's -on trunk," never `/latest/` or `/stable/` the way a port's prefix is. A tag +on trunk," never `/latest/` the way a port's prefix is. A tag on this repo is a release marker for this repo's own history and deploys to the same root a trunk push does — not a second prefix. Release branches are a per-port version concept (`versions.ts`'s `'branch'` kind, e.g. `v0.x`) diff --git a/docs/superpowers/handoffs/lua-docs-site-pr.md b/docs/superpowers/handoffs/lua-docs-site-pr.md index d23313c39..04876d298 100644 --- a/docs/superpowers/handoffs/lua-docs-site-pr.md +++ b/docs/superpowers/handoffs/lua-docs-site-pr.md @@ -22,7 +22,7 @@ Docs(feat): Export versioned Lua documentation ### Documentation workflow - **Revision binding**: Verify the requested source ref resolves to the checked-out commit before generating or publishing documentation. -- **Release handling**: Publish prerelease tags under immutable version prefixes and update `next` without treating an alpha as stable. +- **Release handling**: Publish prerelease tags under immutable version prefixes and update `next` without treating an alpha as a final release. - **Credential boundaries**: Use the preview role for `pr-*` publication, the production role for release and branch trees, and a separate cleanup role for closed previews. ## Integrated version diff --git a/docs/superpowers/handoffs/ruby-docs-site-pr.md b/docs/superpowers/handoffs/ruby-docs-site-pr.md index eaccfd8ad..b6b5ddfbc 100644 --- a/docs/superpowers/handoffs/ruby-docs-site-pr.md +++ b/docs/superpowers/handoffs/ruby-docs-site-pr.md @@ -22,7 +22,7 @@ Docs(feat): Export versioned Ruby documentation ### Documentation workflow - **Revision binding**: Verify the requested source ref resolves to the checked-out commit before generating or publishing documentation. -- **Release handling**: Publish prerelease tags under immutable version prefixes and update `next` without treating an alpha as stable. +- **Release handling**: Publish prerelease tags under immutable version prefixes and update `next` without treating an alpha as a final release. - **Credential boundaries**: Use the preview role for `pr-*` publication, the production role for release and branch trees, and a separate cleanup role for closed previews. ## Integrated version diff --git a/docs/superpowers/handoffs/ruby-lua-site-pr.md b/docs/superpowers/handoffs/ruby-lua-site-pr.md index 7fcbd5371..345e40caf 100644 --- a/docs/superpowers/handoffs/ruby-lua-site-pr.md +++ b/docs/superpowers/handoffs/ruby-lua-site-pr.md @@ -29,7 +29,7 @@ Add first-class Ruby and Lua documentation ### Versioning and publication - **Revision identity**: Require the requested source ref to resolve to the checked-out commit and carry that identity through generated models and pages. -- **Release policy**: Keep prereleases out of stable defaults, protect immutable release prefixes, and distinguish trunk, maintenance branch, pull-request, tag, and alias builds. +- **Release policy**: Keep prereleases out of default versions, protect immutable release prefixes, and distinguish trunk, maintenance branch, pull-request, tag, and alias builds. - **Scoped deployment**: Publish port-owned version trees and manifests through the reusable workflow, merge them in the shell job, and remove only the closed preview's prefix. ## Integrated versions diff --git a/docs/superpowers/plans/2026-09-20-ruby-lua-docs.md b/docs/superpowers/plans/2026-09-20-ruby-lua-docs.md index ceb514491..81867df45 100644 --- a/docs/superpowers/plans/2026-09-20-ruby-lua-docs.md +++ b/docs/superpowers/plans/2026-09-20-ruby-lua-docs.md @@ -183,11 +183,11 @@ and API maturity are separate facts. - [x] Add Ruby tag parsing and Lua tag parsing to `versions.ts`. Normalize LuaRocks rock revisions separately: `0.1.0alpha1-1` installs the rock, while `v0.1.0alpha1` identifies its source. Avoid relabeling these as SemVer. -- [x] Exercise alpha.2 versus alpha.10, alpha versus stable, invalid tags, +- [x] Exercise alpha.2 versus alpha.10, alpha versus final release, invalid tags, and different rock revisions. Preserve all existing grammar tests. - [x] Keep `latest` as the initial default for these prerelease-only ports. Expose `next` or immutable release URLs only after building their exact - source; do not synthesize a `stable` release. + source; do not synthesize a final release. - [x] Replace all-port MCP assumptions with capability checks. Set Ruby's workspace command to `libtmux-workspace load`; Lua exposes status only. diff --git a/infra/README.md b/infra/README.md index 911098fec..5e7178245 100644 --- a/infra/README.md +++ b/infra/README.md @@ -87,22 +87,22 @@ distribution is out of scope for the three files above, which configure ## The bare-language-root redirect and its KeyValueStore -`/en/py` and `/en/py/` 302 to that port's current default version (normally -`/en/py/stable/`). The destination comes from one CloudFront KeyValueStore, +`/en/py` and `/en/py/` 302 to that port's current default version (the newest +final release tag, such as `/en/py/v0.46.2/`, or `latest` while the port has none). The destination comes from one CloudFront KeyValueStore, associated with `cloudfront-function.js`, holding one key per port that publishes a version prefix: ``` -py:default -> "stable" +py:default -> "v0.46.2" ruby:default -> "latest" lua:default -> "latest" -ts:default -> "stable" +ts:default -> "latest" rs:default -> "latest" go:default -> "latest" java:default -> "latest" -csharp:default -> "stable" -cxx:default -> "stable" -swift:default -> "stable" +csharp:default -> "latest" +cxx:default -> "latest" +swift:default -> "latest" ``` Every port gets a row: every port publishes a versioned prose tree, including @@ -139,7 +139,7 @@ The KVS holds **only** these bare-root pointers, never a rewrite target for an already-qualified `///...` path. DocC bakes an absolute `--hosting-base-path` into every page it renders; if the edge silently swapped the version under an already-loaded DocC page, the page's own router -would desync from `location.pathname`. `/py/v0.46.2` and `/py/stable` (note: +would desync from `location.pathname`. `/py/v0.46.2` and `/py/latest` (note: no trailing slash) are handled by the *generic* extensionless-redirect rule, not this one — see the self-check table inside `cloudfront-function.js` for the full trace, including why the bare-root check has to run before the two @@ -175,16 +175,15 @@ them and trusts the KeyValueStore lookup to miss for anything that is not one. | --- | --- | --- | | `/` | 0 (origin root) | 302 to `/en/`, the one redirect off an unprefixed path | | `/en/` | 2 (directory index) | rewrite to `/en/index.html` | -| `/en/py` | 1 (KVS, `parts[3]` undefined) | 302 to `/en/py/stable/`, or whatever `py:default` holds | -| `/en/py/` | 1 (KVS, `parts[3]` empty) | 302 to `/en/py/stable/` | +| `/en/py` | 1 (KVS, `parts[3]` undefined) | 302 to `/en/py/v0.46.2/`, or whatever `py:default` holds | +| `/en/py/` | 1 (KVS, `parts[3]` empty) | 302 to `/en/py/v0.46.2/` | | `/en/rs` | 1 (KVS) | 302 to `/en/rs/latest/`, or whatever `rs:default` holds. When the row is missing, rule 3 301s to `/en/rs/` and rule 2 serves its redirect page | -| `/en/py/stable` | 3 (extensionless) | 301 to `/en/py/stable/` | | `/en/py/latest` | 3 | 301 to `/en/py/latest/`, never the KVS default — `parts[3]` is truthy | | `/en/py/v0.46.2` | 3 (`2` is not an asset extension) | 301 to `/en/py/v0.46.2/` | -| `/en/dotnet/stable/api/libtmux.client` | documentation rename | 301 to `/en/csharp/stable/api/libtmux.client/`, preserving query parameters | -| `/en/csharp/stable/api/libtmux.client` | 3 (`client` is not an asset extension) | 301 with a trailing slash | -| `/en/py/stable/reference/objects.inv` | none (`inv` is an asset extension) | passes through — this is how an external Sphinx project resolves intersphinx into this site | -| `/en/py/stable/api/.buildinfo` | none (`buildinfo` is an asset extension) | passes through; a leading dot is a separator like any other | +| `/en/dotnet/latest/api/libtmux.client` | documentation rename | 301 to `/en/csharp/latest/api/libtmux.client/`, preserving query parameters | +| `/en/csharp/latest/api/libtmux.client` | 3 (`client` is not an asset extension) | 301 with a trailing slash | +| `/en/py/latest/reference/objects.inv` | none (`inv` is an asset extension) | passes through — this is how an external Sphinx project resolves intersphinx into this site | +| `/en/py/latest/api/.buildinfo` | none (`buildinfo` is an asset extension) | passes through; a leading dot is a separator like any other | | `/en/pagefind/pagefind.js` | none (`js` is an asset extension) | passes through | | `/en/versions.json` | none (dot excludes rule 1, `json` is an asset extension) | passes through | | `/robots.txt` | none | passes through; it sits above every locale | diff --git a/infra/cache-policy.md b/infra/cache-policy.md index 1d4d66e80..1a1b5202f 100644 --- a/infra/cache-policy.md +++ b/infra/cache-policy.md @@ -19,14 +19,14 @@ fixed-TTL policy that ignores the header outright. | --- | --- | --- | --- | --- | --- | | Immutable tag | `/en/py/v0.46.2/` | `tag` | `public, max-age=31536000, immutable` | once, at release, never rewritten | never — the bytes never change | | Rebuilt version prefix | `/en/py/v0.x/` | `branch` | `public, max-age=0, s-maxage=300` | every push to that branch | no — expires in 5 min | -| Mutable alias | `/en/py/stable/`, `/en/py/latest/` | `alias`, `trunk` | `public, max-age=0, s-maxage=300` | every release / every push to trunk | no — expires in 5 min | +| Mutable alias | `/en/py/next/`, `/en/py/latest/` | `alias`, `trunk` | `public, max-age=0, s-maxage=300` | every prerelease / every push to trunk | no — expires in 5 min | | PR preview | `/pr-123/en/` | `pr` | `public, max-age=0, s-maxage=300` | every push to the PR | no — expires in 5 min, and is deleted when the PR closes | | Version manifest | `/en/versions.json` | — | `public, max-age=0, s-maxage=60` (or `no-cache`) | every publish, any port | no — its own TTL is already a minute | | Locale landing page | `/en/`, `/ja/` | — | `public, max-age=0, s-maxage=300` | every shell push | **yes** — the one path still spent | | Origin root | `/` | — | `public, max-age=0, s-maxage=300` | never written; the edge function answers it | cannot be — generated per request, never stored | | Shell prose | `/en/concepts/…` | — | `public, max-age=0, s-maxage=300` | every shell push | no — expires in 5 min | | Error page | `/en/404.html` | — | `public, max-age=0, s-maxage=300` | every shell push | no — expires in 5 min | -| Content-hashed assets (optional 3rd pass) | `/py/stable/_astro/*.css` | — | `public, max-age=31536000, immutable` | every push that changes the hash | never (name changes instead) | +| Content-hashed assets (optional 3rd pass) | `/py/latest/_astro/*.css` | — | `public, max-age=31536000, immutable` | every push that changes the hash | never (name changes instead) | Only a `tag` prefix is immutable. A `branch` version (`v0.x`) *looks* like a version prefix the same shape as a tag, but `versions.ts` documents it as @@ -67,8 +67,8 @@ $ aws s3 sync ./dist-v0.46.2/ \ ``` ```console -$ aws s3 sync ./dist-stable/ \ - s3://libtmux-docs/py/stable/ \ +$ aws s3 sync ./dist-latest/ \ + s3://libtmux-docs/py/latest/ \ --delete \ --cache-control "public, max-age=0, s-maxage=300" ``` @@ -92,8 +92,8 @@ before this policy existed has no `Cache-Control` at all and needs one backfill pass to pick up its class's header without re-uploading content: ```console -$ aws s3 cp s3://libtmux-docs/py/stable/ \ - s3://libtmux-docs/py/stable/ \ +$ aws s3 cp s3://libtmux-docs/py/latest/ \ + s3://libtmux-docs/py/latest/ \ --recursive \ --metadata-directive REPLACE \ --cache-control "public, max-age=0, s-maxage=300" diff --git a/infra/cloudfront-function.js b/infra/cloudfront-function.js index 282a7c9b0..eafc556c8 100644 --- a/infra/cloudfront-function.js +++ b/infra/cloudfront-function.js @@ -31,7 +31,7 @@ const DEFAULT_LOCALE = 'en' async function handler(event) { const request = event.request const uri = request.uri - const parts = uri.split('/') // '/py/stable/' -> ['', 'py', 'stable', ''] + const parts = uri.split('/') // '/py/latest/' -> ['', 'py', 'latest', ''] // --- 0. The origin root. Every page is published under a locale, so the // bare root is the one URL with nothing behind it. @@ -91,7 +91,7 @@ async function handler(event) { // - !parts[2].includes('.'): excludes files that sit directly under // the locale — "/en/versions.json", "/en/404.html" — each of which // would otherwise pay for a lookup that can only miss. - // - !parts[3]: nothing follows the port. "/en/py/stable" + // - !parts[3]: nothing follows the port. "/en/py/latest" // already names a version and must get its own trailing slash from // rule 3, not be redirected to a different one. if (parts[1] === DEFAULT_LOCALE && parts[2] && !parts[2].includes('.') && !parts[3]) { @@ -132,14 +132,14 @@ async function handler(event) { } // --- 3. Page path without its trailing slash: redirect, don't rewrite. - // A rewrite would serve the same bytes at two URLs ("/py/stable" and - // "/py/stable/"); a redirect keeps exactly one canonical URL per page, + // A rewrite would serve the same bytes at two URLs ("/py/latest" and + // "/py/latest/"); a redirect keeps exactly one canonical URL per page, // which is what Seo.astro's canonical tag and the sitemap both assume. // // "Is this a file?" is decided by the extension, not by "contains a // dot". Testing for a dot looks equivalent and is not: three kinds of // real page carry one in their last segment — a version tag - // ("/py/v0.46.2"), a .NET type ("/csharp/stable/api/libtmux.client", + // ("/py/v0.46.2"), a .NET type ("/csharp/latest/api/libtmux.client", // 215 of them), and a locale-tagged path — and each was silently // treated as a file, passed through, and 403'd at the origin. The // allowlist below is every extension this build actually emits. diff --git a/notes/adding-a-port.md b/notes/adding-a-port.md index 70179cc1a..62720f9a9 100644 --- a/notes/adding-a-port.md +++ b/notes/adding-a-port.md @@ -204,8 +204,8 @@ Its publisher role must grant that family's prefixes and manifest fragments. defaultVersion: Record }`). Adding a port means: - a new key in `ports` holding that port's `VersionEntry[]` — at minimum a - `trunk` entry. Add `next` for a built prerelease or `stable` for a built - stable release; never point a release alias at trunk; + `trunk` entry. Add `next` for a built prerelease and the release tag's own + entry for a built final release; never point a release alias at trunk; - a new key in `defaultVersion` naming which of those entries is the indexable one (`robotsFor()` and the sitemap gate both key off this). @@ -225,7 +225,7 @@ against the port repo; do not push it yourself, and never push anything to a port repo's remote from an agent session. See `AGENTS.md`'s push policy. The caller's `path-prefix` input must be version-qualified — -`/` (e.g. `ts/v0.1.0`, or `ts/stable` on the alias rebuild), +`/` (e.g. `ts/v0.1.0`, or `ts/next` on the prerelease alias rebuild), never the bare `/*` — because the called workflow runs `aws s3 sync --delete` scoped to exactly that prefix. An unqualified prefix widens the delete to the port's whole tree, wiping every previously diff --git a/notes/architecture.md b/notes/architecture.md index 43bd755ec..33217dbcc 100644 --- a/notes/architecture.md +++ b/notes/architecture.md @@ -67,19 +67,20 @@ Every build is one Astro invocation targeting exactly one version, driven by environment variables read in `site/astro.config.ts` and `site/src/lib/versions.ts`: -- `LIBTMUX_DOCS_VERSION` — the slug: `latest`, `stable`, `v0.46.2`, `v0.x`, +- `LIBTMUX_DOCS_VERSION` — the slug: `latest`, `next`, `v0.46.2`, `v0.x`, `pr-123`. - `LIBTMUX_DOCS_VERSION_KIND` — `trunk | tag | branch | pr | alias`. - `LIBTMUX_DOCS_IS_DEFAULT` — `'true'` on exactly one build per port: the one - the default alias (normally `stable`) currently resolves to. + the port's default version names: its newest final release tag, or `latest` + while it has none. - `LIBTMUX_DOCS_BASE` — the Astro `base`, so the build's own links and canonical tag land under the right prefix. - `LIBTMUX_DOCS_SITE` — the absolute origin, for canonical/sitemap URLs. - `LIBTMUX_DOCS_DEFAULT_VERSION` — read by `BaseLayout.astro` (defaults to - `'stable'`) to know which alias this port's pages canonicalise toward; not + `'latest'`) to know which version this port's pages canonicalise toward; not listed in `astro.config.ts`'s own header comment, so look here instead. -`/stable/` and `/latest/` are real, separate builds — not a rewrite of one +`/next/` and `/latest/` are real, separate builds — not a rewrite of one build served at two prefixes. `sortVersions()` orders the switcher: aliases first, then trunk, then tags, then branches, newest first within each kind. @@ -99,14 +100,14 @@ duplicates against each other unless told which one wins. - **One indexable version per port.** `robotsFor(entry, isDefault)` in `versions.ts` returns `noindex, nofollow` for a `pr` build, `noindex, - follow` for anything marked `eol`, `index, follow` for the default-alias + follow` for anything marked `eol`, `index, follow` for the default-version build, and `noindex, follow` for every other version. Shell pages that don't belong to a port (the landing page, concepts, guides) have no version axis at all and are always indexable. -- **Canonical to the default alias.** `canonicalUrl()` points a non-default +- **Canonical to the default version.** `canonicalUrl()` points a non-default version's page at the same path under `defaultVersion` for that port — e.g. a reader on `/py/v0.40.0/guides/panes/` gets a canonical tag pointing - at `/py/stable/guides/panes/`. A page that exists only in that one version + at `/py/v0.46.2/guides/panes/`. A page that exists only in that one version (`existsInDefault: false`) canonicalises to itself instead, so a real page is never told its canonical URL is a 404. - **Sitemap only from the default build.** `astro.config.ts` computes diff --git a/notes/decisions/per-language-prose.md b/notes/decisions/per-language-prose.md index 8355887bf..6d5e8c98f 100644 --- a/notes/decisions/per-language-prose.md +++ b/notes/decisions/per-language-prose.md @@ -5,7 +5,7 @@ Decided 2026-09-02, implemented the same day. ## The problem The site is one shell serving eight ports. Until now every port showed the -same prose: `/cxx/stable/concepts/transports/` was a byte-identical copy of +same prose: `/cxx/latest/concepts/transports/` was a byte-identical copy of `/concepts/transports/`, marked `noindex` and canonicalised back to the root precisely because it carried nothing of its own. @@ -52,13 +52,13 @@ prevent. ## The asymmetry, stated deliberately -Self-hosted ports carry prose at a versioned prefix, `/py/stable/concepts/`. +Self-hosted ports carry prose at a versioned prefix, `/py/latest/concepts/`. Ecosystem ports carry it unversioned, `/rs/concepts/`. This looks inconsistent and is intentional. A version segment has to mean something, and for Rust, Go and Java the only versioned artifact is the reference — which lives on docs.rs, pkg.go.dev and javadoc.io, each of which -already versions it properly. Inventing `/rs/stable/` here would promise a +already versions it properly. Inventing `/rs/latest/` here would promise a versioned tree this site does not build and cannot keep honest. `portPageUrl()` in `lib/ports.ts` is the single place that knows this. Every diff --git a/notes/decisions/port-root-redirect.md b/notes/decisions/port-root-redirect.md index 7a287bae5..1ccf8b51d 100644 --- a/notes/decisions/port-root-redirect.md +++ b/notes/decisions/port-root-redirect.md @@ -57,7 +57,7 @@ permanently, by design: Only **py, ts, cxx** have both a published local version tree and a CloudFront-level bare-root redirect (`infra/cloudfront-function.js` rule 1: `/en/py` or `/en/py/` with no further path segment does a KVS lookup on -`:default` and 302s to `/en/py/stable/` before the request ever reaches +`:default` and 302s to `/en/py//`, its newest release tag, before the request ever reaches the origin). Rule 1 is anchored on the locale segment, so the unprefixed `/py` is claimed by nothing and 404s — the short form stays unowned, which is what keeps a port slug from colliding with a locale code. For those three, `dist/py/index.html` is legitimately @@ -94,9 +94,9 @@ assets to reconcile, only the one HTML file. Per-port deploys can't collide with that file even by accident: `reusable-deploy.yml` validates `path-prefix` is never bare (`"$p" == "$r"` -is rejected with "qualify it, e.g. '$r/stable'"), so a port's own `sync +is rejected with "qualify it, e.g. '$r/latest'"), so a port's own `sync --delete` always runs scoped to `//`, never `/`. The -shell's `/index.html` and a port's `/stable/` tree are disjoint +shell's `/index.html` and a port's `//` tree are disjoint keys; putting one can never race or clobber the other. ### A correction this decision surfaced, then outgrew @@ -104,7 +104,7 @@ keys; putting one can never race or clobber the other. The traced request table used to carry a stale row: ``` -| `/rs` | 1 (KVS) | 302 -> `/rs/stable/` — ecosystem ports still carry +| `/rs` | 1 (KVS) | 302 -> `/rs/latest/` — ecosystem ports still carry a guides prefix even though their API reference is external (ports.ts referenceUrl) | ``` diff --git a/notes/gp-sphinx-parity.md b/notes/gp-sphinx-parity.md index 7d09ae853..e44689da3 100644 --- a/notes/gp-sphinx-parity.md +++ b/notes/gp-sphinx-parity.md @@ -36,12 +36,12 @@ answer beside it, at `///workspace/reference/` and Five ports used to answer "the API" twice, in three different visual systems: Sphinx+Breathe for C++, DocC for Swift, staged Markdown for TypeScript and -.NET, and this site's own components. A reader arriving at `/cxx/stable/api/` +.NET, and this site's own components. A reader arriving at `/cxx/latest/api/` met a page with no cards, no badges, no source links and no prose at all, while this site's reference had all four. Whatever else parity means, it cannot mean two answers. -Python keeps its generated tree because `/py/stable/api/` is not a duplicate: +Python keeps its generated tree because `/py/latest/api/` is not a duplicate: it is gp-sphinx rendering upstream's own documentation, which is a different document from this site's extracted reference, and it is the oracle `check-style-parity.mjs` measures against. Deleting it would delete the diff --git a/notes/port-dx-assessment.md b/notes/port-dx-assessment.md index d242234b8..b9a2a5c49 100644 --- a/notes/port-dx-assessment.md +++ b/notes/port-dx-assessment.md @@ -61,7 +61,7 @@ without harness bindings in scope. ## Open, and not ours to close - **Python has no user-facing examples and no benchmarks.** It is the reference - port and the only one with a stable release, so this is the largest single + port and the only one with a final release, so this is the largest single gap. Its origin is `tmux-python`, a different organisation from the other seven, so changes there need the maintainer. - **TypeScript exports no test fixture.** `TestServer` exists under diff --git a/notes/sphinx-inventories.md b/notes/sphinx-inventories.md index fcbb2d34f..d6da71b1e 100644 --- a/notes/sphinx-inventories.md +++ b/notes/sphinx-inventories.md @@ -120,7 +120,7 @@ catalog for a shell-owned default tree. For independently published trees or versions absent from the shell artifact, it reads the selected version's published catalog from the bucket. The aggregate records each catalog's hash. This prevents a locally built `latest` tree from replacing the inventory of -a published `stable` default. +a published release-tag default. Publish updated port artifacts, including their root `objects.inv` and `targets.json`, before the first root publication. A missing catalog fails diff --git a/notes/status.md b/notes/status.md index 2b8f9c1ce..e395ff078 100644 --- a/notes/status.md +++ b/notes/status.md @@ -82,10 +82,10 @@ Nine broken internal links, found by crawling every page from `/`: | Was | Cause | Fix | |---|---|---| -| `/dotnet/stable/api/`, `/swift/stable/api/` | Landing page and port grid linked a reference that was never built | Ports carry `referencePublished`; the UI says "Reference not published yet" | +| `/dotnet/latest/api/`, `/swift/latest/api/` | Landing page and port grid linked a reference that was never built | Ports carry `referencePublished`; the UI says "Reference not published yet" | | `/rs/latest/`, `/go/latest/`, `/java/latest/` | Port switcher emitted a local version prefix for ecosystem ports, which have no local tree | `portHomeUrl()` sends ecosystem ports to their landing page | | `/third-party-notices/` | The footer linked a page nobody had written | Page written, including the Doxygen GPL note | -| `/ts/stable/README.md` | The generated TypeScript reference links `../README.md`, relative to its own checkout | Staging rewrites it to the file on GitHub | +| `/ts/latest/README.md` | The generated TypeScript reference links `../README.md`, relative to its own checkout | Staging rewrites it to the file on GitHub | ### The version switcher was mostly fiction @@ -100,8 +100,8 @@ switcher is suppressed for them entirely. ### Structural duplication -Every port-plus-version build rendered the `[port]` route, so `/cxx/stable/` -also emitted `/cxx/stable/py/`, `/cxx/stable/rs/` and six more — **76 nonsense +Every port-plus-version build rendered the `[port]` route, so `/cxx/latest/` +also emitted `/cxx/latest/py/`, `/cxx/latest/rs/` and six more — **76 nonsense pages** nothing linked to. Port landings are now scoped to the root build. Total pages fell from 509 to 433. @@ -137,7 +137,7 @@ already existed in the worktree: the design-token adapter and the `_templates/search.html` override that redirects Furo's dead-end search page to `/search/`. Fixed with a one-line addition to the case statement. Confirmed with `node scripts/inject-shell.mjs` (now passes for -`py/latest` and `py/stable`, previously failing every check per +`py/latest` and `py/`, previously failing every check per `site/public/_shell/README.md`'s own "known failure" note) and with the crawl (`/py/*/api/search.md`'s broken link is gone; see below). @@ -245,8 +245,8 @@ a hardcoded list that predated checking. `pages/index.astro` had no root-only guard, so every port+version sub-build rendered its own copy of the site home page at that build's `/` -route. `/py/stable/` — where the version switcher lands — said "libtmux" -instead of "Python stable". Ecosystem ports had the louder version of the +route. `/py/latest/` — where the version switcher lands — said "libtmux" +instead of "Python latest". Ecosystem ports had the louder version of the same bug, their real landing pages overwritten. Both now branch on the build's own port. @@ -428,7 +428,7 @@ Two of the three bugs found afterwards were not about .NET at all: difference. Found by following a link on the built page, not by reading the code. - **The CloudFront function decided "is this a file?" by looking for a - dot**, so `/dotnet/stable/api/libtmux.client` passed through to the + dot**, so `/dotnet/latest/api/libtmux.client` passed through to the origin as an asset instead of redirecting to the trailing-slash form. Now an allowlist of extensions the build actually emits, which also closes the same hole for `/py/v0.46.2` — a residual the old comment @@ -479,13 +479,13 @@ emits an absolute URL. `scripts/check-preview.sh` fails the build if any escape: 33 pages, zero escapes. Worth recording because it looks wrong: `import.meta.env.BASE_URL` cannot -stand in for this. A per-port build has `base=/py/stable/` and a preview +stand in for this. A per-port build has `base=/py/latest/` and a preview has `base=/pr-42/` — same shape, and only one moves the site root. ### llms.txt, built from resolved content rather than source `/llms.txt` and `/llms-full.txt` now exist, and a per-port build gets a -per-port pair: `/ts/stable/llms-full.txt` carries TypeScript and no other +per-port pair: `/ts/latest/llms-full.txt` carries TypeScript and no other language. That is the per-language mechanism applied to the one consumer that cannot see the language switcher. @@ -557,7 +557,7 @@ public repositories, so they are reported rather than patched here. ### Shared prose is copied into every build -`/cxx/stable/concepts/queries/` and its siblings are byte-identical copies +`/cxx/latest/concepts/queries/` and its siblings are byte-identical copies of `/concepts/queries/`. Correctness is handled — `noindex` plus a canonical back to the root — but the page this note is copied into is now bigger: 28 prose pages (5 concepts, 7 guides, 4 examples, 11 topics, plus diff --git a/packages/api-model/src/builtins.ts b/packages/api-model/src/builtins.ts index 2d4dee621..0c99e6c94 100644 --- a/packages/api-model/src/builtins.ts +++ b/packages/api-model/src/builtins.ts @@ -194,6 +194,9 @@ export const BUILTINS: Record> = { 'ArgumentException'].map((name) => [`System.${name}`, dotnet(`system.${name.toLowerCase()}`)])), // PSResourceGet ships with PowerShell 7.4 but is documented under its own view. 'Install-PSResource': 'https://learn.microsoft.com/powershell/module/microsoft.powershell.psresourceget/install-psresource?view=powershellget-3.x', + // `InnerException` is the property every .NET exception carries; `NotImplemented` is the ErrorCategory member the error record reports. + InnerException: dotnet('system.exception.innerexception'), + NotImplemented: `${dotnet('system.management.automation.errorcategory')}?view=powershellsdk-7.4.0#system-management-automation-errorcategory-notimplemented`, 'System.Nullable': dotnet('system.nullable-1'), 'System.Management.Automation.SwitchParameter': `${dotnet('system.management.automation.switchparameter')}?view=powershellsdk-7.4.0`, 'System.Management.Automation.ActionPreference': `${dotnet('system.management.automation.actionpreference')}?view=powershellsdk-7.4.0`, diff --git a/packages/api-model/src/index.ts b/packages/api-model/src/index.ts index 0ab8dc0ec..3f7aef439 100644 --- a/packages/api-model/src/index.ts +++ b/packages/api-model/src/index.ts @@ -27,7 +27,7 @@ export * from './prose.ts' export { BUILTINS, builtinHref } from './builtins.ts' export * from './nav.ts' export { NAV } from './nav-config.ts' -export { MEMBER_TIERS, memberSignals, memberTier, compareMembers, membersOf, type MemberSignals, type MemberTier } from './member-order.ts' +export { MEMBER_TIERS, memberSignals, memberTier, compareMembers, membersOf, pageMembersOf, aliasTarget, aliasMembersTarget, type MemberSignals, type MemberTier } from './member-order.ts' export { parentInventory } from './parent-inventory.ts' diff --git a/packages/api-model/src/languages/spec.ts b/packages/api-model/src/languages/spec.ts index 48f458250..51c3a06ea 100644 --- a/packages/api-model/src/languages/spec.ts +++ b/packages/api-model/src/languages/spec.ts @@ -493,6 +493,9 @@ function walk(node: Node, ctx: Ctx, parent: string | undefined): void { // A type alias carries its parameters on itself; a callable carries them on its signature. const generics = hasParams ? undefined : declaredTypeParameters(child, spec) const memberDoc = docFor(raw, spec, memberSignatures, ctx.parser, generics) + // A TypeScript alias writes its right-hand side in `value`; Rust's `type_item` and + // other members write the annotation in `type`. + const aliasedType = child.childForFieldName('type') ?? (resolvedKind === 'typealias' ? child.childForFieldName('value') : null) emit(ctx, { id: memberId, name, @@ -502,9 +505,9 @@ function walk(node: Node, ctx: Ctx, parent: string | undefined): void { signatures: memberSignatures, ...(scopeBoundary !== undefined ? { typeScopeBoundary: scopeBoundary } : {}), ...(variant ? { variant: variant.shape } : {}), - type: hasParams ? undefined : child.childForFieldName('type') && spec.typeText - ? spec.typeText(child.childForFieldName('type')!) - : (child.childForFieldName('type')?.text ?? spec.implicitType?.(child))?.replace(/\s+/g, ' '), + type: hasParams ? undefined : aliasedType && spec.typeText + ? spec.typeText(aliasedType) + : (aliasedType?.text ?? spec.implicitType?.(child))?.replace(/\s+/g, ' '), value: child.type === 'annotation_type_element_declaration' && spec.grammar === 'java' ? child.childForFieldName('value')?.text : variant ? variant.value : hasParams ? undefined : child.childForFieldName('declarator')?.childForFieldName('value')?.text.replace(/\s+/g, ' '), diff --git a/packages/api-model/src/languages/swift-examples.test.ts b/packages/api-model/src/languages/swift-examples.test.ts index fa57eb8ea..639230555 100644 --- a/packages/api-model/src/languages/swift-examples.test.ts +++ b/packages/api-model/src/languages/swift-examples.test.ts @@ -55,6 +55,19 @@ describe('complete Swift API examples', () => { `https://github.com/${source.repo}/blob/${source.revision}/Examples/Sources/ApiServer/ApiServer.swift`) }) + it('depends on a final release with from:, the range the package README recommends', () => { + const { read, files } = fixture() + files['Sources/LibTmux/LibTmuxVersion.swift'] = + 'public enum LibTmuxVersion {\n public static let current = "0.1.0"\n}\n' + const target = symbol() + attachCompleteSwiftExamples([target], read, source) + const packageBlock = target.doc?.examples?.[1] + expect(packageBlock?.code).toContain( + '.package(url: "https://github.com/libtmux/libtmux-swift.git", from: "0.1.0")') + expect(packageBlock?.code).not.toContain('exact:') + expect(packageBlock?.intro).toContain('from release 0.1.0') + }) + it('leaves older source revisions without a manifest unchanged', () => { const target = symbol() const original = structuredClone(target) diff --git a/packages/api-model/src/languages/swift-examples.ts b/packages/api-model/src/languages/swift-examples.ts index 832b69b15..97ca1198f 100644 --- a/packages/api-model/src/languages/swift-examples.ts +++ b/packages/api-model/src/languages/swift-examples.ts @@ -20,8 +20,9 @@ interface SwiftExamples { * * The port's consumer package depends on a checkout by path; readers get the * same package depending on the repository at the release the documented - * revision declares, which moves only in release commits. `exact:` is the - * only requirement SwiftPM resolves for a prerelease. + * revision declares, which moves only in release commits. A final release + * takes `from:`, the range the package README recommends; a prerelease takes + * `exact:`, the only requirement SwiftPM resolves for one. */ export function attachCompleteSwiftExamples( symbols: ApiSymbol[], @@ -56,8 +57,11 @@ export function attachCompleteSwiftExamples( const pathDependency = '.package(name: "libtmux", path: "libtmux-source")' require(localPackage.split(pathDependency).length === 2 && localPackage.includes('package: "libtmux")'), 'consumer package must depend on the checkout by path') + const prerelease = release!.includes('-') + const requirement = prerelease ? `exact: "${release}"` : `from: "${release}"` + const fetched = prerelease ? `at release ${release}` : `from release ${release}` const packageCode = localPackage - .replace(pathDependency, `.package(url: "https://github.com/${source.repo}.git", exact: "${release}")`) + .replace(pathDependency, `.package(url: "https://github.com/${source.repo}.git", ${requirement})`) .replaceAll('package: "libtmux")', `package: "${source.repo.split('/')[1]}")`) const names = new Set() const targets = new Set() @@ -79,7 +83,7 @@ export function attachCompleteSwiftExamples( const blocks: NonNullable = [ { lang: 'swift', - intro: `${example.title}. ${example.description.replace(/\n/g, ' ')} Use Swift ${tools} or newer and tmux 3.3a or newer on Linux or macOS. In an empty directory, save this consumer package as \`Package.swift\`; SwiftPM fetches the library at release ${release}:`, + intro: `${example.title}. ${example.description.replace(/\n/g, ' ')} Use Swift ${tools} or newer and tmux 3.3a or newer on Linux or macOS. In an empty directory, save this consumer package as \`Package.swift\`; SwiftPM fetches the library ${fetched}:`, code: packageCode, }, { diff --git a/packages/api-model/src/link.ts b/packages/api-model/src/link.ts index ff68d6c52..1754d4fd1 100644 --- a/packages/api-model/src/link.ts +++ b/packages/api-model/src/link.ts @@ -1077,6 +1077,11 @@ export class SymbolIndex { const out: TypeSpan[] = [] const rustPayload = this.lang === 'rs' && (context?.variant || (context?.parent && this.byDeclared.get(context.parent)?.variant)) const variantDelimiters: string[] = [] + // Names a TypeScript type binds inside its own text: `[Key in Keys]` and `infer Item`. + const innerBound = new Set() + if (this.lang === 'ts') { + for (const bound of annotation.matchAll(/\[\s*([A-Za-z_$][\w$]*)\s+in\s|\binfer\s+([A-Za-z_$][\w$]*)/g)) innerBound.add(bound[1] ?? bound[2]!) + } // A bound name never takes a same-named global type's URL; it links to its declaration instead. const bindings = this.typeParameterBindings(context, signature) // Identifiers, including dotted ones; everything else is punctuation, @@ -1141,6 +1146,34 @@ export class SymbolIndex { out.push({ text: ident }) continue } + if (this.lang === 'ts') { + const before = annotation.slice(0, m.index) + const after = annotation.slice(m.index! + ident.length) + // Type predicates, mapped types and assertions: syntax, unless a field is called `is` or `in`. + if (/^(?:is|in|as|asserts)$/.test(ident) && !/^\s*\??\s*:/.test(after)) { + out.push({ text: ident, keyword: true }) + continue + } + if ((innerBound.has(ident) && !before.endsWith('.')) || /^\s+is\s/.test(after)) { + out.push({ text: ident, declaration: true }) + continue + } + if (/^(?:true|false)$/.test(ident) && !/^\s*\??\s*:/.test(after)) { + out.push({ text: ident, nonReference: true }) + continue + } + // A method signature in an object type, `{ execute(request: Request): Result }`, names its member. + if (/^\s*\??\s*[(<]/.test(after) && /(?:^|[{;,])(?:\s|\/\*[\s\S]*?\*\/|\/\/[^\n]*)*(?:readonly\s+)?$/.test(before) && /\{/.test(before)) { + out.push({ text: ident, declaration: true }) + continue + } + // A computed key, `readonly [brand]: Kind`, names the member it declares. + if (/^\s*\]\s*\??\s*:(?!:)/.test(after) && + /(?:^|[{;,])(?:\s|\/\*[\s\S]*?\*\/|\/\/[^\n]*)*(?:readonly\s+)?\[\s*$/.test(before)) { + out.push({ text: ident, declaration: true }) + continue + } + } const bound = declaresValue(annotation.slice(0, m.index), annotation.slice(m.index! + ident.length)) ? undefined : this.boundSpans(ident, bindings) if (bound) { diff --git a/packages/api-model/src/member-order.ts b/packages/api-model/src/member-order.ts index c7d002d99..4b37a0513 100644 --- a/packages/api-model/src/member-order.ts +++ b/packages/api-model/src/member-order.ts @@ -88,6 +88,42 @@ export function memberSignals( const idOf = (s: ApiSymbol) => s.publicId ?? s.id +const TYPE_KINDS: ReadonlySet = new Set(['class', 'interface', 'struct', 'union', 'enum', 'trait', 'typealias', 'exception']) +/** A name, possibly qualified: no type arguments, unions, object types or functions. */ +const BARE_REFERENCE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/ + +/** + * The declaration a type alias names, when its right-hand side is one bare reference. + * + * `type ConnectOptions = ConnectionOptions` is the same type as its target, so its page + * shows the target's members. A reference with type arguments, a union or an object + * type is a new type and has none to show. The alias's own module wins over a same-named + * declaration elsewhere; otherwise the name must be unique in the model. + */ +export function aliasTarget(model: ApiModelBase, alias: ApiSymbol): ApiSymbol | undefined { + const reference = alias.kind === 'typealias' ? alias.type?.trim() : undefined + if (!reference || !BARE_REFERENCE.test(reference)) return undefined + const name = reference.slice(reference.lastIndexOf('.') + 1) + const named = model.symbols.filter((symbol) => symbol !== alias && symbol.name === name && TYPE_KINDS.has(symbol.kind)) + const scope = alias.parent ?? alias.id.slice(0, Math.max(0, alias.id.length - alias.name.length - 1)) + const local = named.filter((symbol) => symbol.id === `${scope}.${name}` || (scope === '' && symbol.id === name)) + const found = local.length ? local : named + return found.length === 1 ? found[0] : undefined +} + +/** Ports whose `type` on an alias is its right-hand side, as written, and whose alias pages are covered by tests. */ +const ALIAS_MEMBER_PORTS: ReadonlySet = new Set(['ts']) + +/** + * The declaration whose members an alias page lists: an alias that owns no member and names + * one declaration, on a port that has opted in. + */ +export function aliasMembersTarget(model: ApiModelBase & { port?: string }, owner: ApiSymbol): ApiSymbol | undefined { + if (!ALIAS_MEMBER_PORTS.has(model.port ?? (model as { language?: string }).language ?? '')) return undefined + if (model.symbols.some((symbol) => symbol.parent === owner.id)) return undefined + return aliasTarget(model, owner) +} + /** Include explicit public re-exports without inferring access from private bases. */ export function membersOf(model: ApiModelBase & { port?: string }, owner: ApiSymbol, signals = memberSignals(model.port ?? '')): ApiSymbol[] { const members = model.symbols.filter((symbol) => symbol.parent === owner.id) @@ -97,8 +133,28 @@ export function membersOf(model: ApiModelBase & { port?: string }, owner: ApiSym members.push({ ...source, parent: owner.id, inheritedFrom: source.parent }) } } - return owner.variant || owner.declarations?.some((declaration) => declaration.kind === 'constant') + return sortMembers(owner, members, signals) +} + +const sortMembers = (owner: ApiSymbol, members: ApiSymbol[], signals: MemberSignals) => + owner.variant || owner.declarations?.some((declaration) => declaration.kind === 'constant') ? members : members.sort(compareMembers(signals)) + +/** + * The members a type's own page lists: `membersOf`, and for an alias of one declaration that + * declaration's members too. An alias is another name, so each keeps its id and page. + * + * Only the alias page and its Markdown export call this. The navigation tree, sidebar, search + * and inventories take `membersOf`, where a member has exactly one owner. + */ +export function pageMembersOf(model: ApiModelBase & { port?: string }, owner: ApiSymbol, signals = memberSignals(model.port ?? ''), seen = new Set()): ApiSymbol[] { + const members = membersOf(model, owner, signals) + const target = members.length ? undefined : aliasMembersTarget(model, owner) + if (!target || seen.has(target.id)) return members + seen.add(owner.id) + // The target's members keep their own inheritance marks; an alias adds none. + const listed = pageMembersOf(model, target, signals, seen).map((member) => ({ ...member, parent: owner.id })) + return sortMembers(owner, listed, signals) } /** diff --git a/packages/api-model/src/mentions.ts b/packages/api-model/src/mentions.ts index a55b7a4f8..f93be1085 100644 --- a/packages/api-model/src/mentions.ts +++ b/packages/api-model/src/mentions.ts @@ -160,6 +160,23 @@ export interface PageMentionsInput { authoredTarget: (href: string | undefined) => LinkedOwner | undefined } +/** + * Whether a bare member name is a member of the one qualified type that an earlier span in its paragraph names. + * + * `The exception carries `ActualVersion` and `Command`` follows a paragraph that names + * `LibTmux.TmuxUnsupportedOnReleaseException`; `Command` alone belongs to many types, but only that one + * type named there has it. Two types with the member leave the name unresolved. + */ +function ownedByPrecedingType(text: string, before: string, port: string, resolver: Resolver, product: ApiProduct | undefined): boolean { + if (!/^[A-Za-z_]\w*$/.test(text)) return false + const types = new Set([...before.matchAll(/`([A-Z]\w*(?:\.\w+)+)`/g)].map((match) => match[1]!)) + const owned = [...types].filter((type) => { + const res = resolver.resolve(port, `${type}.${text}`, product) + return res.how === 'federated' || 'symbol' in res + }) + return owned.length === 1 +} + /** * The symbols one page mentions, and the spans in it that look like API but resolve to nothing. * @@ -185,6 +202,7 @@ export function pageMentions(input: PageMentionsInput): { targets: LinkedOwner[] const decision = decideMention(text, { pagePort, product, before }, resolver, models) if (decision.kind !== 'link') { const authored = decision.kind === 'unresolved' ? linkedHere.recur(contextPort, text) : undefined + if (!authored && decision.kind === 'unresolved' && pagePort && ownedByPrecedingType(text, before, pagePort, resolver, product)) continue if (!authored) { if (decision.kind === 'unresolved' && pagePort && isLikelyReference(text) && !notApiReason(text)) { dangling.push({ port: pagePort, text, page, line, why: decision.why }) diff --git a/packages/api-model/src/parent-inventory.ts b/packages/api-model/src/parent-inventory.ts index 77c93cd81..380fff1be 100644 --- a/packages/api-model/src/parent-inventory.ts +++ b/packages/api-model/src/parent-inventory.ts @@ -2,16 +2,22 @@ import type { ApiModel, ApiSymbol } from './model.ts' import type { InventoryEntry } from './inventory.ts' import { OWNER_KINDS } from './prose.ts' -/** Parent APIs used by a facade, including unambiguous short names. */ +/** + * Parent APIs used by a facade, including unambiguous short names. + * + * The parent's workspace and MCP products are named only by their full qualified name: their short + * names would compete with the core's for a bare word the facade's prose uses for its own API. + */ export function parentInventory(model: ApiModel, hrefFor: (symbol: ApiSymbol) => string): InventoryEntry[] { const candidates = new Map>() for (const symbol of model.symbols) { - if (symbol.apiScope === 'internal' || (symbol.product && symbol.product !== 'core')) continue + if (symbol.apiScope === 'internal') continue + const core = !symbol.product || symbol.product === 'core' const qualified = symbol.qualifiedName ?? (symbol.publicId ?? symbol.id).replace(/(^|\.)(\w+)\.\2(?=\.|$)/g, '$1$2') const name = model.port === 'java' && symbol.id.endsWith('()') ? `${qualified}()` : qualified const uri = hrefFor(symbol).replace(/^\/+/, '') const parts = name.split('.') - for (let offset = 0; offset < parts.length; offset++) { + for (let offset = 0; offset < (core ? parts.length : 1); offset++) { const alias = parts.slice(offset).join('.') const entries = candidates.get(alias) ?? new Map() entries.set(uri, { diff --git a/packages/api-model/src/prose-fields.ts b/packages/api-model/src/prose-fields.ts index d3714e3b1..af4ffc48a 100644 --- a/packages/api-model/src/prose-fields.ts +++ b/packages/api-model/src/prose-fields.ts @@ -126,6 +126,7 @@ export const RENDERED_TEXTS: Record = { 'fact.value': 'commandFacts and parameterBindingFacts', 'parameterBindingText(p)!': 'parameterBindingText', 'e.note': 'conceptNotes', + 'cell.note': 'conceptNotes', 'block.text': 'ApiProse blocks', 'item.text': 'ApiProse blocks', } diff --git a/packages/api-model/src/resolver.ts b/packages/api-model/src/resolver.ts index a57f7ed57..97d527104 100644 --- a/packages/api-model/src/resolver.ts +++ b/packages/api-model/src/resolver.ts @@ -100,7 +100,7 @@ export const DEFAULT_TEMPLATES: UrlTemplate[] = [ export function notASymbol(text: string): string | undefined { if (/^[a-z][a-z0-9+.-]*:\/\//i.test(text)) return 'a protocol URI' if (/^(?:net|v)?\d+\.\d+(?:\.\d+)?(?:[a-z]|[-+][\w.-]+)?$/.test(text)) return 'a version' - if (/^(?:net|v)?\d+(?:\.\d+)*\.x$/.test(text)) return 'a version line' + if (/^(?:net|v)?\d+(?:\.\d+)*\.[xXnN]$/.test(text)) return 'a version line' if (/^\w+(?:\.\w+)+:[\w.-]+(?::[\w.<>{}-]+)?$/.test(text)) return 'a dependency coordinate' // `objects.inv` is the published Sphinx inventory, named by the setup guides next to a Python fence. if (/\.(?:tsv|html|inv)$/.test(text)) return 'a filename' diff --git a/packages/api-model/test/builtins.test.ts b/packages/api-model/test/builtins.test.ts index 2d8fbba19..d9f186d35 100644 --- a/packages/api-model/test/builtins.test.ts +++ b/packages/api-model/test/builtins.test.ts @@ -156,6 +156,14 @@ describe('standard types in product signatures', () => { expect(builtinHref('csharp', 'Install-PSResource')).toBeUndefined() }) + it('links the exception property and error category that PowerShell guides name', () => { + expect(builtinHref('powershell', 'InnerException')).toBe('https://learn.microsoft.com/dotnet/api/system.exception.innerexception') + expect(builtinHref('powershell', 'NotImplemented')) + .toBe('https://learn.microsoft.com/dotnet/api/system.management.automation.errorcategory?view=powershellsdk-7.4.0#system-management-automation-errorcategory-notimplemented') + for (const port of ['csharp', 'go']) expect(builtinHref(port, 'NotImplemented'), port).toBeUndefined() + expect(builtinHref('powershell', 'Message')).toBeUndefined() + }) + it('resolves compiler utility types without claiming local declarations', () => { const utilities = new SymbolIndex([], () => '#', 'ts') for (const [name, target] of Object.entries(TYPESCRIPT_UTILITY_TYPES)) { diff --git a/packages/api-model/test/inventory.test.ts b/packages/api-model/test/inventory.test.ts index 2da0bfa0e..c764e06d7 100644 --- a/packages/api-model/test/inventory.test.ts +++ b/packages/api-model/test/inventory.test.ts @@ -5,7 +5,7 @@ import type { ApiSymbol } from '../src/model.ts' const entry: InventoryEntry = { name: 'sample', type: 'std:label', priority: 1, uri: 'guide/#sample', dispname: 'Example' } const options = { project: 'libtmux', version: 'test' } -const target: InventoryTarget = { scope: 'cxx', product: 'core', category: 'api', identity: 'libtmux::Pane', display: 'Pane', href: '/pr-42/en/cxx/stable/reference/pane/#Pane', version: 'stable' } +const target: InventoryTarget = { scope: 'cxx', product: 'core', category: 'api', identity: 'libtmux::Pane', display: 'Pane', href: '/pr-42/en/cxx/v0.1.0/reference/pane/#Pane', version: 'v0.1.0' } describe('inventory records', () => { it('is byte-stable regardless of collection order and preserves spaces in option names', () => { @@ -59,9 +59,9 @@ describe('durable portable references', () => { expect(targetKey(target)).toBe('cxx:core:api:libtmux%3a%3a%50ane') }) it('separates identity and display from the current page URL', () => { - const moved = { ...target, display: 'A new title', href: '/pr-42/en/cxx/stable/new-page/#retained' } + const moved = { ...target, display: 'A new title', href: '/pr-42/en/cxx/v0.1.0/new-page/#retained' } expect(targetKey(moved)).toBe(targetKey(target)) - expect(targetEntries([moved], '/pr-42/en/')[0].uri).toBe('cxx/stable/new-page/#retained') + expect(targetEntries([moved], '/pr-42/en/')[0].uri).toBe('cxx/v0.1.0/new-page/#retained') }) it('normalizes glossary aliases for the case-insensitive standard term role', () => { const entries = targetEntries([{ ...target, native: [{ type: 'std:term', name: 'Blocking Call' }] }], '/pr-42/en/', true) @@ -97,7 +97,7 @@ describe('durable portable references', () => { it('retains qualified native aliases when short names are ambiguous across products', () => { const core = { ...target, native: [{ type: 'cpp:class', name: 'Pane' }] } const workspace = { ...core, product: 'workspace', href: core.href.replace('reference/', 'workspace/reference/') } - const names = targetEntries([core, workspace], '/pr-42/en/cxx/stable/', true).filter((entry) => entry.type === 'cpp:class').map((entry) => entry.name) + const names = targetEntries([core, workspace], '/pr-42/en/cxx/v0.1.0/', true).filter((entry) => entry.type === 'cpp:class').map((entry) => entry.name) expect(names).toEqual(['cxx:core:Pane', 'cxx:workspace:Pane']) }) }) diff --git a/packages/api-model/test/mentions.test.ts b/packages/api-model/test/mentions.test.ts index 5d95a50c0..ecca6529f 100644 --- a/packages/api-model/test/mentions.test.ts +++ b/packages/api-model/test/mentions.test.ts @@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest' import type { ApiModel } from '../src/model.ts' import { LinkedOwners, pageMentions, proseMentions, type LinkedOwner } from '../src/mentions.ts' import { Resolver } from '../src/resolver.ts' +import { parentInventory } from '../src/parent-inventory.ts' import { isLikelyReference, notApiReason } from '../src/prose.ts' const LABELS = { Python: 'py', TypeScript: 'ts', Go: 'go' } @@ -178,3 +179,35 @@ describe('a name that earlier links on the page gave an owner', () => { expect(owners.recur(undefined, 'PaneExited')).toBeUndefined() }) }) + +describe('a bare member after the qualified type its paragraph names', () => { + const sym = (id: string, kind: string, product = 'core') => ({ id, name: id.split('.').at(-1), kind, product, slug: id.toLowerCase().replaceAll('.', '-'), signatures: [], docs: [] }) + const csharp = { port: 'csharp', version: '0', symbols: [ + sym('LibTmux.TmuxUnsupportedOnReleaseException', 'class'), + sym('LibTmux.TmuxUnsupportedOnReleaseException.Command', 'property'), + sym('LibTmux.SelectLayoutRequest', 'class'), + sym('LibTmux.SelectLayoutRequest.Command', 'property'), + sym('LibTmux.Workspace.WorkspaceFormatException', 'class', 'workspace'), + sym('LibTmux.Workspace.WorkspaceFormatException.Command', 'property', 'workspace'), + ] } + const powershell = { port: 'powershell', version: '0', symbols: [sym('LibTmux\\Get-TmuxPane', 'function')] } + const models = { csharp, powershell } as unknown as Record + const resolver = new Resolver([csharp, powershell] as unknown as ApiModel[]) + resolver.addInventory('Library API', '', parentInventory(csharp as unknown as ApiModel, (s) => `/reference/csharp/${s.slug}/`), ['powershell']) + const page = (body: string) => pageMentions({ + body, portAt: () => 'powershell', portByLabel: LABELS, page: '/guide/', nativeTmux: false, resolver, models, authoredTarget: () => undefined, + }).dangling.map((row) => row.text) + + it('resolves a name only one named type has, and names a workspace type by its qualified name', () => { + expect(page('Raises `LibTmux.TmuxUnsupportedOnReleaseException`. It carries `Command`.')).toEqual([]) + expect(page('See `LibTmux.Workspace.WorkspaceFormatException`.')).toEqual([]) + }) + + it('leaves the name unresolved when no named type, or two, has it', () => { + // Controls: nothing named before it, a type without the member, two types with it, and a short workspace name. + expect(page('It carries `Command`.')).toEqual(['Command']) + expect(page('Raises `LibTmux.Workspace.Missing`. It carries `Command`.')).toEqual(['LibTmux.Workspace.Missing', 'Command']) + expect(page('Raises `LibTmux.TmuxUnsupportedOnReleaseException` or `LibTmux.SelectLayoutRequest`. It carries `Command`.')).toEqual(['Command']) + expect(page('See `WorkspaceFormatException`.')).toEqual(['WorkspaceFormatException']) + }) +}) diff --git a/packages/api-model/test/resolver.test.ts b/packages/api-model/test/resolver.test.ts index 4ba838807..d0734f523 100644 --- a/packages/api-model/test/resolver.test.ts +++ b/packages/api-model/test/resolver.test.ts @@ -45,6 +45,11 @@ d('resolver', () => { for (const text of ['server.x', 'Version.x', 'x']) expect(notASymbol(text), text).toBeUndefined() }) + it('rejects a release-numbering label, and keeps a real symbol', () => { + for (const text of ['0.1.N', 'v0.1.N', '0.1.0', 'v0.1.0', '0.x', '1.2.X']) expect(notASymbol(text), text).toBeTruthy() + for (const text of ['Server.new_session', 'LibTmux.Window', 'Version.N', 'N']) expect(notASymbol(text), text).toBeUndefined() + }) + it('rejects things that are not references', () => { expect(notASymbol('sync_snippets.py --check')).toBeTruthy() expect(notASymbol('pane.pane_id == other.pane_id')).toBeTruthy() diff --git a/packages/api-model/test/typescript-aliases.test.ts b/packages/api-model/test/typescript-aliases.test.ts new file mode 100644 index 000000000..e6ced114a --- /dev/null +++ b/packages/api-model/test/typescript-aliases.test.ts @@ -0,0 +1,124 @@ +import { mkdtempSync, rmSync, writeFileSync } from 'node:fs' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import { afterEach, describe, expect, it } from 'vitest' +import { aliasTarget, membersOf, pageMembersOf } from '../src/member-order.ts' +import { SymbolIndex } from '../src/link.ts' +import { extractProject } from '../src/project.ts' + +const dirs: string[] = [] +afterEach(() => { + for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true }) +}) + +const SOURCE = ` +/** Options. */ +export interface ConnectionOptions { + bufferSize?: number; + signal?: AbortSignal; +} +export interface Other { other: string } +/** Options for connecting. */ +export type ConnectOptions = ConnectionOptions; +export type Twice = ConnectOptions; +export type Either = ConnectionOptions | Other; +export type Shape = { readonly a: string }; +export type Boxed = Wrapper; +export type Applied = Boxed<"y">; +export type Generic = Readonly; +export type Loop = Loop2; +export type Loop2 = Loop; +` + +async function extract(source: string | Record = SOURCE) { + const dir = mkdtempSync(join(tmpdir(), 'ts-alias-')) + dirs.push(dir) + for (const [file, text] of Object.entries(typeof source === 'string' ? { 'types.ts': source } : source)) writeFileSync(join(dir, file), text) + return extractProject({ port: 'ts', root: dir }) +} + +describe('TypeScript type aliases', () => { + it('records the right-hand side as written, with its type parameters', async () => { + const model = await extract() + const type = (name: string) => model.symbols.find((symbol) => symbol.id === `types.${name}`) + expect(type('ConnectOptions')?.type).toBe('ConnectionOptions') + expect(type('Either')?.type).toBe('ConnectionOptions | Other') + expect(type('Shape')?.type).toBe('{ readonly a: string }') + expect(type('Boxed')?.type).toBe('Wrapper') + expect(type('Boxed')?.typeParams).toEqual(['T extends string = "x"']) + // A member that is not an alias keeps its annotation in `type`, unchanged. + expect(type('ConnectionOptions.bufferSize')?.type).toBe('number') + }) + + it('resolves only a lone reference, following alias chains', async () => { + const model = await extract() + const named = (name: string) => model.symbols.find((symbol) => symbol.id === `types.${name}`)! + const names = (name: string) => pageMembersOf({ ...model, port: 'ts' }, named(name)).map((member) => member.name) + expect(aliasTarget(model, named('ConnectOptions'))?.id).toBe('types.ConnectionOptions') + expect(names('ConnectOptions')).toEqual(['bufferSize', 'signal']) + // An alias is another name, so its members are not marked inherited. + expect(pageMembersOf({ ...model, port: 'ts' }, named('ConnectOptions')).some((member) => member.inheritedFrom)).toBe(false) + // Navigation, search and inventories read `membersOf`, where an alias owns nothing. + expect(membersOf({ ...model, port: 'ts' }, named('ConnectOptions'))).toEqual([]) + expect(membersOf({ ...model, port: 'ts' }, named('Twice'))).toEqual([]) + expect(names('Twice')).toEqual(['bufferSize', 'signal']) + // Controls: a union, an object type, an applied or built-in generic and an unknown name name no single declaration. + for (const name of ['Either', 'Shape', 'Boxed', 'Applied', 'Generic']) expect(names(name), name).toEqual([]) + expect(aliasTarget(model, named('Either'))).toBeUndefined() + expect(aliasTarget(model, named('Applied'))).toBeUndefined() + }) + + it('stops on an alias cycle and on a port that has not opted in', async () => { + const model = await extract() + const loop = model.symbols.find((symbol) => symbol.id === 'types.Loop')! + expect(pageMembersOf({ ...model, port: 'ts' }, loop)).toEqual([]) + const connect = model.symbols.find((symbol) => symbol.id === 'types.ConnectOptions')! + expect(pageMembersOf({ ...model, port: 'rs' }, connect)).toEqual([]) + }) + + it.each(['Foo', 'Foo[]', 'Foo | null', 'typeof foo', 'Foo["bar"]'])('does not resolve %s', async (written) => { + const model = await extract(`export interface Foo { a: string }\nexport const foo = 1;\nexport type Alias = ${written};\n`) + const alias = model.symbols.find((symbol) => symbol.id === 'types.Alias')! + expect(alias.type).toBe(written) + expect(aliasTarget(model, alias)).toBeUndefined() + expect(pageMembersOf({ ...model, port: 'ts' }, alias)).toEqual([]) + }) + + it('prefers the alias\'s own module for a name declared in two, and refuses an ambiguous one', async () => { + const model = await extract({ + 'a.ts': 'export interface Shared { fromA: string }\nexport type Local = Shared;\n', + 'b.ts': 'export interface Shared { fromB: string }\nexport type Remote = Shared;\n', + 'c.ts': 'export type Elsewhere = Shared;\n', + }) + const target = (id: string) => aliasTarget(model, model.symbols.find((symbol) => symbol.id === id)!)?.id + expect(target('a.Local')).toBe('a.Shared') + expect(target('b.Remote')).toBe('b.Shared') + expect(target('c.Elsewhere')).toBeUndefined() + }) + + it('gives the words a type binds or reserves a grammar role instead of leaving them plain', async () => { + const model = await extract(` +export interface Foo { a: string } +declare const brand: unique symbol; +export type Mapped = { readonly [K in Key]: K | Foo }; +export type Guard = (x: unknown) => x is Foo; +export type Branded = string & { readonly [brand]: 1 }; +export type Unwrapped = T extends Array ? Item : never; +export type Named = { is: string; in?: number }; +export type Engine = { readonly endpoint?: true; execute(request: Foo): Promise }; +`) + const index = new SymbolIndex(model.symbols, (symbol) => `/${symbol.slug}/`, 'ts') + const roles = (name: string) => { + const alias = model.symbols.find((symbol) => symbol.id === `types.${name}`)! + return index.linkType(alias.type!, alias).filter((span) => /^[A-Za-z_$]/.test(span.text)) + .map((span) => `${span.text}:${span.keyword ? 'keyword' : span.nonReference ? 'syntax' : span.declaration ? 'name' : span.link ? 'link' : 'plain'}`) + } + expect(roles('Mapped')).toEqual(['readonly:keyword', 'K:name', 'in:keyword', 'Key:name', 'K:name', 'Foo:link']) + expect(roles('Guard')).toEqual(['x:name', 'unknown:link', 'x:name', 'is:keyword', 'Foo:link']) + expect(roles('Branded')).toEqual(['string:link', 'readonly:keyword', 'brand:name']) + expect(roles('Unwrapped')).toEqual(['T:name', 'extends:keyword', 'Array:link', 'infer:keyword', 'Item:name', 'Item:name', 'never:link']) + expect(roles('Engine')).toEqual(['readonly:keyword', 'endpoint:name', 'true:syntax', 'execute:name', 'request:name', 'Foo:link', 'Promise:link', 'Foo:link']) + // A field that is called `is` or `in` stays a field name. + expect(roles('Named')).toEqual(['is:name', 'string:link', 'in:name', 'number:link']) + }) +}) diff --git a/scripts/README.md b/scripts/README.md index 4622ff32e..a8e6d1aa7 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -86,7 +86,7 @@ $ ./scripts/build-site.sh --skip-pagefind `--ports` limits which ports get a shell build and a reference generation pass (comma-separated slugs from `site/src/lib/ports.ts`). -`--versions` overrides the default `latest,stable`. `--skip-refs` builds +`--versions` overrides the default `latest`. `--skip-refs` builds only the shell and search index. `--skip-pagefind` skips the final indexing pass, useful while iterating on everything before it. @@ -529,13 +529,13 @@ $ node scripts/gen-registry.mjs ``` Regenerates `site/src/data/registry.json`, which records what each port's -package registry carries right now: a stable release, a prerelease only, or +package registry carries right now: a final release, a prerelease only, or nothing at all. `installCommand` in [ports.ts](../site/src/lib/ports.ts) composes that with the install spellings to produce the command a page or an agent prompt shows, so the command cannot name a version the registry does not have. -It matters because most ports have no stable release, and several +It matters because a port with only prereleases is common, and several resolve nothing unless the prerelease is named: Cargo treats an alpha as out of range for a plain requirement, `go get` without a version resolves the highest release and a prerelease is not one, and SwiftPM's `from:` excludes prereleases @@ -630,9 +630,8 @@ Entries are derived per port from each checkout named in `site/src/lib/ports.ts` (`~/work/python/libtmux`, and so on): git tags matching that port's grammar become `tag` entries, local branches matching `vX.x` become `branch` entries, the checkout's current `HEAD` is always `latest` -(kind `trunk`), and `stable` is an `alias` resolving to the newest -non-prerelease tag. A prerelease-only port gets `next`; it does not get a -fabricated `stable`. RubyGems and LuaRocks release spellings keep their native +(kind `trunk`). The newest non-prerelease tag is the port's default version. +A prerelease-only port gets `next` and keeps `latest` as its default. RubyGems and LuaRocks release spellings keep their native forms. A port whose checkout is absent falls back to the same latest-only seed that `--seed` produces, with a note on stderr. Set `LIBTMUX_DOCS_CHECKOUT_` to derive refs from an exact CI checkout. diff --git a/scripts/build-site.sh b/scripts/build-site.sh index 5752bcdf9..b970b1aec 100755 --- a/scripts/build-site.sh +++ b/scripts/build-site.sh @@ -17,7 +17,7 @@ usage() { Usage: scripts/build-site.sh [options] --versions v1,v2,... Version slugs to build per self-hosted port - (default: latest,stable) + (default: latest) --ports p1,p2,... Limit to these port slugs (default: all self-hosted ports from site/src/lib/ports.ts) --skip-refs Skip native reference renderers (selected-source MCP is required) @@ -27,7 +27,7 @@ Usage: scripts/build-site.sh [options] USAGE } -versions_arg="latest,stable" +versions_arg="latest" versions_explicit=0 ports_filter="" skip_refs=0 @@ -966,7 +966,7 @@ for shell_locale in $(list_locales); do log "building the shell for $shell_locale (base=$LIBTMUX_DOCS_LOCALES_ROOT/$shell_locale/)" LIBTMUX_DOCS_LOCALE="$shell_locale" \ LIBTMUX_DOCS_ROOT="${LIBTMUX_DOCS_LOCALES_ROOT:-}/$shell_locale/" \ - build_shell "$LIBTMUX_DOCS_LOCALES_ROOT/$shell_locale/" "$root_version" "trunk" "true" "stable" "$assembly_out/$shell_locale" + build_shell "$LIBTMUX_DOCS_LOCALES_ROOT/$shell_locale/" "$root_version" "trunk" "true" "latest" "$assembly_out/$shell_locale" done # Every port's home page (site/src/pages/[port]/index.astro) is built here, @@ -1019,7 +1019,7 @@ while IFS='|' read -r slug name versioned renderer generator checkout ecosystem_ # `versionedDocs: false` stays supported, not because anything uses it. log "building $name ($slug) prose only (base=$LIBTMUX_DOCS_PORT_ROOT/$slug/, reference on $ecosystem_host)" LIBTMUX_DOCS_PORT="$slug" \ - build_shell "$LIBTMUX_DOCS_PORT_ROOT/$slug/" "stable" "alias" "false" "stable" "$site_out/$slug" + build_shell "$LIBTMUX_DOCS_PORT_ROOT/$slug/" "latest" "trunk" "false" "latest" "$site_out/$slug" # That build just overwrote this port's home page with a copy of the # site homepage — see the snapshot comment above. Put the real one back. [ -f "$port_home_snapshots/$slug.html" ] && @@ -1072,11 +1072,11 @@ while IFS='|' read -r slug name versioned renderer generator checkout ecosystem_ # Five ports used to answer "the API" twice, in three different visual # systems: Breathe for C++, DocC for Swift, staged Markdown for TypeScript # and .NET, and this site's own components at /reference/. A reader - # arriving at /cxx/stable/api/ met a page with no cards, no badges, no + # arriving at /cxx/latest/api/ met a page with no cards, no badges, no # source links and no prose, while /reference/cxx/ had all four. # # A port that publishes its own API tree is the exception and stays - # generated: /py/stable/api/ is gp-sphinx rendering upstream's own + # generated: /py/latest/api/ is gp-sphinx rendering upstream's own # documentation — the thing this reference is built to match, and the # oracle `site/scripts/check-style-parity.mjs` compares against. Deleting # it would delete the measurement. `publishesOwnApi` in ports.ts carries @@ -1210,7 +1210,7 @@ fi log "publishing inventories from assembled pages" node "$script_dir/publish-inventories.mjs" "$site_out" "$LIBTMUX_DOCS_PORT_ROOT/" -# Only here is a whole-site link check meaningful. Every `/py/stable/` path is +# Only here is a whole-site link check meaningful. Every `/py/latest/` path is # written by a different `astro build`, so any single build reports thousands # of them missing and is right to; the assembly is the first moment all of # them exist at once. diff --git a/scripts/check-canonicals.mjs b/scripts/check-canonicals.mjs index 543302243..9809c260f 100644 --- a/scripts/check-canonicals.mjs +++ b/scripts/check-canonicals.mjs @@ -57,13 +57,21 @@ if (siteDir === defaultSite && existsSync(lock)) { } /** - * Each port's default version, read from the tree that was built: a port - * publishing one prefix is its own default, and Python's two make `stable` - * the canonical one. + * Each port's default version, read from the tree that was built: the + * manifest's `defaultVersion` when that version was built, else the one + * prefix a port published. */ +const MANIFEST = (() => { + try { + return JSON.parse(readFileSync(join(siteDir, 'versions.json'), 'utf8')) + } catch { + return {} + } +})() const DEFAULTS = Object.fromEntries(PORTS.map((port) => { const built = referenceDirs(siteDir, port).map((dir) => dir.split('/').at(-2)) - return [port, built.includes('stable') ? 'stable' : built[0]] + const declared = MANIFEST.defaultVersion?.[port] + return [port, built.includes(declared) ? declared : built[0]] }).filter(([, version]) => version)) const roots = PORTS.flatMap((port) => referenceDirs(siteDir, port, { products: true })) diff --git a/scripts/check-canonicals.negative.mjs b/scripts/check-canonicals.negative.mjs index 035b5dd09..c2fd9b85e 100644 --- a/scripts/check-canonicals.negative.mjs +++ b/scripts/check-canonicals.negative.mjs @@ -75,6 +75,35 @@ const check = (name, ok, detail) => { rmSync(dir, { recursive: true, force: true }) } +{ + // A port whose default is a release tag: every other version canonicalises + // to that tag, and the tag to itself. The control is the tree that does; + // the failure is trunk claiming itself while the manifest names the tag. + const tree = (latestCanonical) => { + const dir = mkdtempSync(join(tmpdir(), 'check-canonicals-default-')) + for (const version of ['latest', 'v0.46.2']) { + const page = join(dir, 'py', version, 'reference', 'pane') + mkdirSync(page, { recursive: true }) + const target = version === 'latest' ? latestCanonical : 'v0.46.2' + writeFileSync(join(page, 'index.html'), ``) + } + writeFileSync(join(dir, 'versions.json'), JSON.stringify({ schema: 1, ports: {}, defaultVersion: { py: 'v0.46.2' } })) + return dir + } + const control = tree('v0.46.2') + const passed = run(control) + check('trunk canonicalising to the default release tag passes', passed.code === 0, `exited ${passed.code}:\n${passed.out}`) + rmSync(control, { recursive: true, force: true }) + const wrong = tree('latest') + const failed = run(wrong) + check( + 'trunk canonicalising to itself while a release is the default fails', + failed.code !== 0 && failed.out.includes('canonicalise somewhere other than themselves'), + `exited ${failed.code}:\n${failed.out}`, + ) + rmSync(wrong, { recursive: true, force: true }) +} + { const dir = mkdtempSync(join(tmpdir(), 'check-canonicals-bare-')) mkdirSync(join(dir, 'py', 'latest', 'reference'), { recursive: true }) diff --git a/scripts/check-links.mjs b/scripts/check-links.mjs index 05429a130..efb5ec6bd 100755 --- a/scripts/check-links.mjs +++ b/scripts/check-links.mjs @@ -16,7 +16,7 @@ * fast path after a reference change and is meaningful against any build. * * --all checks every internal href and is only meaningful against a full - * assembly: every port-and-version path like `/py/stable/` is produced by a + * assembly: every port-and-version path like `/py/latest/` is produced by a * different `astro build`, so a root-only build reports thousands of them * missing and is right to. */ diff --git a/scripts/check-sidebar-refs.mjs b/scripts/check-sidebar-refs.mjs index 9df2be99b..8464bcf44 100755 --- a/scripts/check-sidebar-refs.mjs +++ b/scripts/check-sidebar-refs.mjs @@ -39,10 +39,10 @@ function pageUnder(portDir) { const unversioned = join(portDir, 'concepts', 'index.html') if (existsSync(unversioned)) return unversioned /* - * Whichever versions were built, rather than a slug guessed in advance. - * `stable` was the guess, and it is absent for a port with no release — so - * this reported seven ports as having no shell page at all when what they - * had was a shell page somewhere this function did not look. + * Whichever versions were built, rather than a slug guessed in advance: a + * port with no release has no release tree, and guessing one reported + * seven ports as having no shell page at all when what they had was a shell + * page somewhere this function did not look. */ if (!existsSync(portDir)) return undefined for (const version of readdirSync(portDir)) { diff --git a/scripts/check-versions.negative.sh b/scripts/check-versions.negative.sh index 6aec7b3a6..1a04deb1e 100755 --- a/scripts/check-versions.negative.sh +++ b/scripts/check-versions.negative.sh @@ -8,9 +8,9 @@ # # The assertion is on the guard's message, not on the exit code. Both were # tried; exit code is worthless here. `--versions latest` on its own exits 1 -# because a tree with no /py/stable/ has dangling cross-port links — a real -# failure, unrelated to this guard, that made the control look like a pass for -# the wrong reason. A control that fails for its own reasons proves nothing. +# when the partial build it starts fails for its own reasons — a real failure, +# unrelated to this guard, that made the control look like a pass for the wrong +# reason. A control that fails for its own reasons proves nothing. # # Honest slugs are checked with a timeout: the guard fires within a second, so # if the message has not appeared by then it never will, and there is no need @@ -57,7 +57,6 @@ check v1 1 'unrecognised, treated as a branch' # The controls. Without them a guard that refused everything would pass above. check latest 0 'trunk, which is what HEAD is' -check stable 0 'an alias, resolved at render time' if [ "$failures" -gt 0 ]; then echo @@ -65,4 +64,4 @@ if [ "$failures" -gt 0 ]; then exit 1 fi echo -echo 'check-versions.negative: only latest and stable build; every other slug is refused' +echo 'check-versions.negative: only latest builds; every other slug is refused' diff --git a/scripts/check-xrefs.mjs b/scripts/check-xrefs.mjs index ca9fabe17..302d9902b 100755 --- a/scripts/check-xrefs.mjs +++ b/scripts/check-xrefs.mjs @@ -53,7 +53,7 @@ function countIn(dir) { } // Core and companion references share one floor within a version. Count each -// version separately: a healthy stable tree must not conceal broken latest +// version separately: a healthy release tree must not conceal broken latest // references, and building both versions must not double the recorded floor. const versionCounts = Object.fromEntries(PORTS.map((port) => { const versions = {} diff --git a/scripts/check-xrefs.negative.mjs b/scripts/check-xrefs.negative.mjs index 0216e39e9..52a316214 100755 --- a/scripts/check-xrefs.negative.mjs +++ b/scripts/check-xrefs.negative.mjs @@ -60,20 +60,20 @@ const CASES = [ { name: 'port unrecorded', built: 0, floor: 10, omit: ['go'], mustFail: true, says: 'no floor recorded for go' }, { name: 'version masks fall', built: 10, floor: 10, mustFail: true, - setup: (dir) => { version(dir, 'py', 'latest', 2); version(dir, 'py', 'stable', 20) }, + setup: (dir) => { version(dir, 'py', 'latest', 2); version(dir, 'py', 'v0.46.2', 20) }, says: 'resolution fell on py', }, { name: 'both versions hold', built: 10, floor: 10, mustFail: false, - setup: (dir) => version(dir, 'py', 'stable', 10), + setup: (dir) => version(dir, 'py', 'v0.46.2', 10), }, { name: 'products share version', built: 10, floor: 10, mustFail: false, setup: (dir) => { version(dir, 'py', 'latest', 6) version(dir, 'py', 'latest/mcp', 4) - version(dir, 'py', 'stable', 5) - version(dir, 'py', 'stable/workspace', 5) + version(dir, 'py', 'v0.46.2', 5) + version(dir, 'py', 'v0.46.2/workspace', 5) }, }, ] @@ -129,11 +129,11 @@ const GUARDS = [ { name: 'version lowering refused', built: 10, floor: 10, wantCode: 1, wantFloor: 10, port: 'py', says: 'refusing to lower', - setup: (dir) => { version(dir, 'py', 'latest', 2); version(dir, 'py', 'stable', 20) }, + setup: (dir) => { version(dir, 'py', 'latest', 2); version(dir, 'py', 'v0.46.2', 20) }, }, { name: 'version count not added', built: 10, floor: 10, wantCode: 0, wantFloor: 10, - port: 'py', setup: (dir) => version(dir, 'py', 'stable', 10), + port: 'py', setup: (dir) => version(dir, 'py', 'v0.46.2', 10), }, ] diff --git a/scripts/compose-published-inventory.mjs b/scripts/compose-published-inventory.mjs index 8869b7ea0..24591ed54 100644 --- a/scripts/compose-published-inventory.mjs +++ b/scripts/compose-published-inventory.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import { execFileSync } from 'node:child_process' import { createHash } from 'node:crypto' -import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs' +import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs' import { resolve } from 'node:path' import { pathToFileURL } from 'node:url' @@ -19,38 +19,66 @@ export async function compose({ directory, runtime, catalogs, bucket, locale }) const targets = shared.targets.filter((target) => target.scope === 'site' || target.scope.startsWith('tmux@')) const inputs = [] const compatibility = [] - for (const [port, versions] of Object.entries(manifest.ports)) { - if (!versions.length) continue - const version = manifest.defaultVersion[port] - if (!versions.some((entry) => entry.slug === version)) throw new Error(`No published default for ${port}/${version}`) - const relative = `${port}/${version}/targets.json` + const missing = [] + const fallback = [] + // A catalog's file, or null when it is absent. Only a 404 is absence. + const locate = (relative) => { let file = resolve(out, relative) - if (ownership.portTrees.includes(port) || !existsSync(file)) { + if (ownership.portTrees.includes(relative.split('/')[0]) || !existsSync(file)) { file = resolve(catalogs, relative) if (bucket) { mkdirSync(resolve(file, '..'), { recursive: true }) - execFileSync('aws', ['s3', 'cp', `s3://${bucket}/${locale}/${relative}`, file, '--only-show-errors'], { stdio: 'inherit' }) + try { + execFileSync('aws', ['s3', 'cp', `s3://${bucket}/${locale}/${relative}`, file, '--only-show-errors'], { stdio: ['ignore', 'inherit', 'pipe'], encoding: 'utf8' }) + } catch (error) { + // Only a missing object is absence; credentials, network and permission errors still fail. + if (!/\(404\)|Not Found/.test(String(error.stderr ?? ''))) { + process.stderr.write(String(error.stderr ?? '')) + throw error + } + } } - if (!existsSync(file)) throw new Error(`Publish ${locale}/${relative} before advertising its full inventory`) } + return existsSync(file) ? file : null + } + for (const [port, versions] of Object.entries(manifest.ports)) { + if (!versions.length) continue + const version = manifest.defaultVersion[port] + if (!versions.some((entry) => entry.slug === version)) throw new Error(`No published default for ${port}/${version}`) + // The advertised default may predate targets.json; its latest tree is the fallback. + let used = version + let relative = `${port}/${version}/targets.json` + let file = locate(relative) + if (!file && version !== 'latest') { + used = 'latest' + relative = `${port}/latest/targets.json` + file = locate(relative) + } + if (!file) { + missing.push({ port, version, catalog: `${base}${port}/${version}/targets.json` }) + rmSync(resolve(out, 'reference', port, 'objects.inv'), { force: true }) + continue + } + if (used !== version) fallback.push({ port, default: version, used, catalog: `${base}${relative}` }) const bytes = readFileSync(file) + const published = used const catalog = JSON.parse(bytes.toString()) - const expectedBase = `${base}${port}/${version}/` - if (catalog.schema !== 1 || catalog.scope !== port || catalog.version !== version || catalog.base !== expectedBase || !catalog.targets?.length) { + const expectedBase = `${base}${port}/${published}/` + if (catalog.schema !== 1 || catalog.scope !== port || catalog.version !== published || catalog.base !== expectedBase || !catalog.targets?.length) { throw new Error(`Published target catalog has the wrong identity: ${relative}`) } for (const target of catalog.targets) { - if (target.scope !== port || target.version !== version || !target.href.startsWith(expectedBase) || + if (target.scope !== port || target.version !== published || !target.href.startsWith(expectedBase) || !new URL(target.href, 'https://inventory.invalid').pathname.startsWith(expectedBase) || target.key !== targetKey(target)) { - throw new Error(`Published target is outside ${port}/${version}: ${target.key}`) + throw new Error(`Published target is outside ${port}/${published}: ${target.key}`) } } targets.push(...catalog.targets) - inputs.push({ port, version, catalog: `${base}${relative}`, sha256: createHash('sha256').update(bytes).digest('hex') }) + inputs.push({ port, version: published, catalog: `${base}${relative}`, sha256: createHash('sha256').update(bytes).digest('hex') }) const entries = compatibilityEntries(catalog.targets, base).map((entry) => ({ ...entry, uri: `../../${entry.uri}` })) compatibility.push({ file: resolve(out, 'reference', port, 'objects.inv'), - bytes: writeInventoryEntries(entries, { project: `libtmux ${port}`, version, legacyCaseSensitiveLabels: true }), + bytes: writeInventoryEntries(entries, { project: `libtmux ${port}`, version: published, legacyCaseSensitiveLabels: true }), }) } targets.sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0) @@ -64,8 +92,10 @@ export async function compose({ directory, runtime, catalogs, bucket, locale }) } writeFileSync(resolve(out, 'objects-full.inv'), full) writeFileSync(resolve(out, 'objects.inv'), legacy) - writeFileSync(resolve(out, 'targets.json'), `${JSON.stringify({ schema: 1, base, defaults: manifest.defaultVersion, coverage: { inputs }, targets })}\n`) - return { targets: targets.length, inputs } + writeFileSync(resolve(out, 'targets.json'), `${JSON.stringify({ schema: 1, base, defaults: manifest.defaultVersion, coverage: { inputs, fallback, missing }, targets })}\n`) + for (const { port, default: from, used, catalog } of fallback) console.log(`Composed ${port}/${used} because ${port}/${from} has not published its catalog: ${catalog}`) + for (const { port, version, catalog } of missing) console.log(`Left out of the full inventory: ${port}/${version} has not published ${catalog}`) + return { targets: targets.length, inputs, fallback, missing } } if (import.meta.url === pathToFileURL(process.argv[1]).href) { diff --git a/scripts/gen-registry.mjs b/scripts/gen-registry.mjs index ba1ad1202..4eb7c70cf 100644 --- a/scripts/gen-registry.mjs +++ b/scripts/gen-registry.mjs @@ -4,15 +4,16 @@ * * The agent prompts name an install command, and an install command that does * not resolve is worse than no prompt at all: the reader's agent runs it, - * fails, and starts inventing. Seven of the eight ports have no stable release - * and one is not published at all, so the right spelling differs per port and - * changes the day any of them ships. + * fails, and starts inventing. A port with only prereleases needs a different + * spelling from one with a final release, and one port is not published at + * all, so the right spelling differs per port and changes the day one ships. * * Two spellings are forced rather than chosen, and the rest are pinned so a * prompt's prose and its command agree: * - * - Swift tags only prereleases, and `0.1.0-alpha.4` sorts below `0.1.0`, so - * `from: "0.1.0"` has nothing in range. `exact:` is the only form. + * - A Swift prerelease such as `0.1.0-alpha.4` sorts below `0.1.0`, so + * `from:` never selects one. `exact:` is the only form for a prerelease; + * a final release takes `from:`. * - C++ has no vcpkg port, so a CMake FetchContent block at a tag is the * only way in. * @@ -21,9 +22,9 @@ * pin, because a resolver with no release to prefer falls back to a * prerelease. The pins stay because the prompt names a version in prose beside * the command, and because a bare command changes what it installs the day a - * stable lands while a generated pin changes visibly. + * release lands while a generated pin changes visibly. * - * So which of `installForms.{stable,prerelease,git}` applies is a fact about + * So which of `installForms.{release,prerelease,git}` applies is a fact about * the registry today, not about the port, and it belongs in generated data * rather than in a hand-typed string that goes stale the next time anyone * publishes. `ports.ts` owns the spellings; this owns the state. @@ -84,7 +85,7 @@ const expand = (p) => (p.startsWith('~/') ? join(homedir(), p.slice(2)) : p) * written for git tags. Registries mostly report the bare number: crates.io * says `0.1.0-alpha.10`, Maven Central says `0.0.1-alpha.10`, PyPI says * `0.62.0`, and only the Go proxy says `v0.0.1-alpha.6`. Parsing a bare - * number with those regexes returns null, which would classify every stable + * number with those regexes returns null, which would classify every final * release as unpublished. Normalise first, once, here. */ /** Whether a version string is a prerelease under this port's grammar. */ @@ -96,10 +97,12 @@ function isPrerelease(version, grammar) { const newestFirst = (versions, grammar) => [...versions].sort((a, b) => comparePackageVersions(a, b, grammar)) -/** The release stage a PyPI project declares in its Development Status classifier. */ -const PYPI_STAGES = { - '2 - Pre-Alpha': 'pre-alpha', '3 - Alpha': 'alpha', '4 - Beta': 'beta', '5 - Production/Stable': 'stable', '6 - Mature': 'stable', -} +/** + * The prerelease stage a PyPI project declares in its Development Status + * classifier. A later classifier declares nothing here: a final release is + * named by its version's series, never by a claim of stability. + */ +const PYPI_STAGES = { '2 - Pre-Alpha': 'pre-alpha', '3 - Alpha': 'alpha', '4 - Beta': 'beta' } const declaredStage = (classifiers) => PYPI_STAGES[ classifiers?.find((entry) => entry.startsWith('Development Status :: '))?.slice('Development Status :: '.length) ] @@ -358,13 +361,13 @@ async function allTags(port) { /** Classify one port from the versions its registry carries. */ function classify(port, versions, tag) { if (versions === null || versions.length === 0) { - return { status: 'unpublished', version: null, stable: null, tag } + return { status: 'unpublished', version: null, release: null, tag } } const ordered = newestFirst(versions, port.tagGrammar) - const stable = ordered.find((v) => !isPrerelease(v, port.tagGrammar)) ?? null - return stable - ? { status: 'stable', version: stable, stable, tag } - : { status: 'prerelease', version: ordered[0], stable: null, tag } + const release = ordered.find((v) => !isPrerelease(v, port.tagGrammar)) ?? null + return release + ? { status: 'release', version: release, release, tag } + : { status: 'prerelease', version: ordered[0], release: null, tag } } const opts = parseArgs(process.argv.slice(2)) @@ -378,12 +381,14 @@ if (opts.help) { * port may not be published yet, so fill only missing entries from the seed. * Reading --out alone would leave a fresh output path without any fallback. */ -const seed = existsSync(DEFAULT_OUT) - ? JSON.parse(readFileSync(DEFAULT_OUT, 'utf8')) - : existsSync(opts.out) - ? JSON.parse(readFileSync(opts.out, 'utf8')) - : { ports: {} } -const baseline = opts.baseline ? JSON.parse(readFileSync(opts.baseline, 'utf8')) : seed +const SCHEMA = 2 +/** A file written under another schema is no fallback: its entries name other fields. */ +const read = (path) => { + const data = JSON.parse(readFileSync(path, 'utf8')) + return data.schema === SCHEMA ? data : { ports: {} } +} +const seed = existsSync(DEFAULT_OUT) ? read(DEFAULT_OUT) : existsSync(opts.out) ? read(opts.out) : { ports: {} } +const baseline = opts.baseline ? read(opts.baseline) : seed const committed = { ports: { ...seed.ports, ...baseline.ports } } const ports = {} @@ -457,7 +462,7 @@ for (const port of PORTS) { } const payload = { - schema: 1, + schema: SCHEMA, /** * Deliberately not a timestamp of this run. A field that changes on every * invocation makes `--check` fail for no reason and turns a no-op refresh diff --git a/scripts/gen-registry.negative.mjs b/scripts/gen-registry.negative.mjs index 293724089..6c0b1827f 100644 --- a/scripts/gen-registry.negative.mjs +++ b/scripts/gen-registry.negative.mjs @@ -95,7 +95,7 @@ for (const [name, mutate] of mutations) { const baseline = structuredClone(seed) delete baseline.ports.powershell delete baseline.ports.julia - baseline.ports.csharp = { status: 'stable', version: '1.2.3', stable: '1.2.3', tag: 'v1.2.3' } + baseline.ports.csharp = { status: 'release', version: '1.2.3', release: '1.2.3', tag: 'v1.2.3' } writeFileSync(join(dir, 'published.json'), JSON.stringify(baseline)) writeFileSync(join(dir, 'fetch.mjs'), ` import { readFileSync } from 'node:fs' @@ -161,10 +161,16 @@ for (const [name, mutate] of mutations) { check('a package Hex does not carry is unpublished', unlisted.ports.elixir?.status === 'unpublished' && unlisted.ports.elixir?.version === null, `${JSON.stringify(unlisted.ports.elixir)} ${unlisted.error}`) check('an unavailable existing port retains its newer published entry', same(result.ports.csharp, baseline.ports.csharp), result.error) + // A published copy written under another schema names other fields, so it is no fallback. + writeFileSync(join(dir, 'published.json'), JSON.stringify({ ...baseline, schema: 1 })) + result = invoke(replies) + check('a baseline under another schema is ignored', same(result.ports.csharp, seed.ports.csharp), `${JSON.stringify(result.ports.csharp)} ${result.error}`) + writeFileSync(join(dir, 'published.json'), JSON.stringify(baseline)) + result = invoke(replies) // The baseline names a tag the repository never published. Tags the // repository still carries keep their recorded entry; tags it lacks do not. - const staleJulia = { status: 'unpublished', version: null, stable: null, tag: 'v0.1.0-alpha.1' } + const staleJulia = { status: 'unpublished', version: null, release: null, tag: 'v0.1.0-alpha.1' } writeFileSync(join(dir, 'published.json'), JSON.stringify({ ...baseline, ports: { ...baseline.ports, julia: staleJulia } })) const julia = 'https://api.github.com/repos/libtmux/libtmux-julia/tags?per_page=100' result = invoke({ ...replies, [julia]: { body: '[]' }, [general]: { status: 404, body: '404: Not Found' } }) @@ -184,7 +190,7 @@ for (const [name, mutate] of mutations) { const unread = (resolved) => { const count = Object.keys(resolved.ports).length if (count !== PORTS.length) return [`the resolver wrote ${count} of ${PORTS.length} ports: ${resolved.error}`] - const registry = { schema: 1, ports: resolved.ports } + const registry = { schema: 2, ports: resolved.ports } return PORTS.flatMap((port) => [ ...['core', 'mcp', 'workspace'].filter((product) => product === 'core' || productAvailable(port, product)) .map((product) => [`${port.slug} ${product}`, () => productStatus(port, product, registry)]), @@ -204,7 +210,7 @@ for (const [name, mutate] of mutations) { const notInGeneral = { status: 404, body: '404: Not Found' } const prereleaseOnly = { body: `["0.1.0-alpha.2"]\ngit-tree-sha1 = "${'c'.repeat(40)}"\n` } for (const [state, repository, registry, stage] of [ - ['a final tag General does not carry yet', ['v0.1.0'], notInGeneral, 'stable'], + ['a final tag General does not carry yet', ['v0.1.0'], notInGeneral, '0.x'], ['a prerelease tag General does not carry yet', ['v0.1.0-alpha.1'], notInGeneral, 'alpha'], ['a prerelease General carries', ['v0.1.0-alpha.2'], prereleaseOnly, 'alpha'], ['a prerelease General carries beside a final tag it lacks', ['v0.1.0-alpha.2', 'v0.1.0'], prereleaseOnly, 'alpha'], @@ -212,16 +218,16 @@ for (const [name, mutate] of mutations) { ]) { result = invoke({ ...replies, [julia]: tagged(...repository), [general]: registry }) const failures = unread(result) - const read = failures.length === 0 ? productStatus(juliaPort, 'core', { schema: 1, ports: result.ports }) : undefined + const read = failures.length === 0 ? productStatus(juliaPort, 'core', { schema: 2, ports: result.ports }) : undefined check(`every badge reads ${state} as ${stage}`, read === stage, `${read} ${JSON.stringify(failures)}`) } result = invoke({ ...replies, [julia]: tagged('v0.1.0'), [general]: notInGeneral }) check('a final tag General does not carry yet is recorded as the live registry recorded it', - same(result.ports.julia, { status: 'unpublished', version: null, stable: null, tag: 'v0.1.0' }), `${JSON.stringify(result.ports.julia)} ${result.error}`) + same(result.ports.julia, { status: 'unpublished', version: null, release: null, tag: 'v0.1.0' }), `${JSON.stringify(result.ports.julia)} ${result.error}`) // Once the registry lists a release, a newer tag it lacks is not recorded; the support page says so. result = invoke({ ...replies, [julia]: tagged('v0.1.0-alpha.2', 'v0.1.0'), [general]: prereleaseOnly }) check('a final tag beside a registry that lists only a prerelease is not recorded', - same(result.ports.julia, { status: 'prerelease', version: '0.1.0-alpha.2', stable: null, tag: 'v0.1.0-alpha.2' }), `${JSON.stringify(result.ports.julia)} ${result.error}`) + same(result.ports.julia, { status: 'prerelease', version: '0.1.0-alpha.2', release: null, tag: 'v0.1.0-alpha.2' }), `${JSON.stringify(result.ports.julia)} ${result.error}`) // The reads above pass only if the read can fail, so name the port and the tag it could not place. result = invoke({ ...replies, [julia]: tagged('v0.1.0-dev.3'), [general]: notInGeneral }) diff --git a/scripts/gen-versions.mjs b/scripts/gen-versions.mjs index b1728690e..83a93ea6e 100755 --- a/scripts/gen-versions.mjs +++ b/scripts/gen-versions.mjs @@ -58,10 +58,9 @@ const BRANCH_RE = /^v\d+\.x$/ /** * The entry every port gets when there is no checkout to inspect. * - * Trunk alone. A seeded `stable` could only resolve to `latest`, which is an - * alias from the word for "the released version" to the unreleased one — the - * claim this generator exists to stop making. Absent is honest: it says we do - * not know of a release, rather than naming trunk as one. + * Trunk alone. A seeded release entry could only name trunk as the released + * version, the claim this generator exists to stop making. Absent is honest: + * it says we do not know of a release. * * This is the normal path in CI, which has no port checkouts, so the seed is * what most builds actually publish. @@ -109,23 +108,19 @@ function deriveEntries(port) { headDate = undefined } - // `tags` is already newest-first, so the first match in each case is the one - // the alias should name. A suffix decides these, not a hyphen: `v0.11.0b0` - // has no hyphen and is not a release. - const stableTag = tags.find((t) => t.pre === null)?.name + // `tags` is already newest-first, so the first match in each case is the + // newest one. A suffix decides these, not a hyphen: `v0.11.0b0` has no hyphen + // and is not a release. The newest final tag is the default version. + const defaultTag = tags.find((t) => t.pre === null)?.name const preTag = tags.find((t) => t.pre !== null)?.name const entries = [ { slug: 'latest', label: 'latest', kind: 'trunk', supported: true, ...(headDate ? { published: headDate } : {}) }, - // Absent, not pointed at trunk. An alias called `stable` that resolves to - // an unreleased HEAD tells a reader — and, through robotsFor, a search - // engine — the opposite of the truth. - ...(stableTag ? [{ slug: 'stable', label: 'stable', kind: 'alias', resolvesTo: stableTag, supported: true }] : []), ...(preTag ? [{ slug: 'next', label: 'next', kind: 'alias', resolvesTo: preTag, supported: true }] : []), ...tags.map((t) => ({ slug: t.name, label: t.name, kind: 'tag', supported: true, ...(t.date ? { published: t.date } : {}) })), ...branches.map((b) => ({ slug: b.name, label: b.name, kind: 'branch', supported: true, ...(b.date ? { published: b.date } : {}) })), ] - return { entries, defaultVersion: stableTag ? 'stable' : 'latest', note: undefined } + return { entries, defaultVersion: defaultTag ?? 'latest', note: undefined } } function mergeOverrides(manifest, overridesPath) { @@ -160,9 +155,7 @@ function main() { : deriveEntries(port) if (derived.note) process.stderr.write(`gen-versions: ${port.slug}: ${derived.note}\n`) manifest.ports[port.slug] = sortVersions(derived.entries, port.tagGrammar, port.tagPrefix) - // Not unconditionally 'stable' any more: a port with no release has no - // stable entry to point at, and naming one anyway is what made seven of - // eight ports advertise trunk as their released version. + // The newest final release tag, or `latest` while the port has none. manifest.defaultVersion[port.slug] = derived.defaultVersion } diff --git a/scripts/inject-shell.mjs b/scripts/inject-shell.mjs index 5b5054a5a..06587d07a 100644 --- a/scripts/inject-shell.mjs +++ b/scripts/inject-shell.mjs @@ -1,6 +1,6 @@ #!/usr/bin/env node // Validate the compiled native shell and its complete static asset closure. -// Usage: node scripts/inject-shell.mjs --site _site [--version stable] +// Usage: node scripts/inject-shell.mjs --site _site [--version latest] import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs' import { dirname, join, relative } from 'node:path' import { fileURLToPath } from 'node:url' diff --git a/scripts/lib/api-sources.mjs b/scripts/lib/api-sources.mjs index 65755cd1d..7d86ec922 100644 --- a/scripts/lib/api-sources.mjs +++ b/scripts/lib/api-sources.mjs @@ -176,6 +176,8 @@ export const BARE_OWNERS = Object.fromEntries(Object.entries({ py: { typing: ['Unpack', 'TypeGuard', 'TypeAlias'], 'collections.abc': ['Mapping', 'Sequence', 'Callable', 'Iterator'] }, powershell: { 'System.IO': ['FileInfo'], 'System.Management.Automation': ['ApplicationInfo'], + // The guides name an exception's property and an error record's category member bare. + 'System.Exception': ['InnerException'], 'System.Management.Automation.ErrorCategory': ['NotImplemented'], 'microsoft.powershell.utility': ['Get-Member', 'Invoke-WebRequest'], 'microsoft.powershell.core': ['Where-Object', 'Receive-Job', 'CommonParameters'], // PSResourceGet ships with PowerShell 7.4 and is documented under its own module. 'microsoft.powershell.psresourceget': ['Install-PSResource'], diff --git a/scripts/native-shell-context.mjs b/scripts/native-shell-context.mjs index b0997264c..fbba059cd 100644 --- a/scripts/native-shell-context.mjs +++ b/scripts/native-shell-context.mjs @@ -33,6 +33,67 @@ function localPath(value, field) { return value } +const escapeHtml = (text) => text.replace(/&/g, '&').replace(//g, '>') + +/** A title as Sphinx renders it: text, with inline literals kept as ``. */ +function navigationTitle(link) { + let html = '' + let plain = '' + let code = false + const walk = (node) => { + for (const child of node.childNodes) { + if (child.nodeType === 3) { + const text = child.textContent.replace(/\s+/g, ' ') + plain += text + html += escapeHtml(text) + } else if (child.nodeType === 1) { + if (child.localName === 'svg') continue + const literal = child.localName === 'code' + if (literal) { code = true; html += '' } + walk(child) + if (literal) html += '' + } + } + } + walk(link) + return { title: plain.trim(), ...(code ? { html: html.trim() } : {}) } +} + +/** + * The global toctree one page carries, as nested data on published URLs. + * + * gp-furo-theme renders it with `toctree(collapse=False, maxdepth=-1, + * titles_only=True, includehidden=True)`: every page lists the whole tree, + * with hrefs relative to that page, so the current-page markers and the + * relative spelling are the only differences between pages. A top-level + * `p.caption` heading owns the `ul` that follows it. + */ +export function captureToctree(sidebar, pageUrl) { + const resolve = (href) => { + if (/^[a-z][a-z\d+.-]*:/i.test(href)) return { url: href, external: true } + const url = new URL(href, `https://native.invalid${pageUrl}`) + return { url: `${url.pathname}${url.hash}` } + } + const items = (list) => [...list.children].filter((child) => child.localName === 'li').map((item) => { + const link = [...item.children].find((child) => child.localName === 'a') + if (!link) throw new Error('Native toctree entry has no link') + const nested = [...item.children].find((child) => child.localName === 'ul') + return { ...navigationTitle(link), ...resolve(link.getAttribute('href')), children: nested ? items(nested) : [] } + }) + const tree = [] + for (const child of sidebar.children) { + if (child.localName === 'p' && child.classList.contains('caption')) { + tree.push({ title: child.textContent.trim(), caption: true, children: [] }) + } else if (child.localName === 'ul') { + const entries = items(child) + const last = tree.at(-1) + if (last?.caption && !last.children.length) last.children = entries + else tree.push(...entries) + } + } + return tree +} + /** Bind native routes, exported Markdown and source files before Astro renders their shell. */ export async function collectNativeContext(directory, { prefix, sphinxPort, version, checkout, sourceSha }) { const port = PORT_BY_SLUG[sphinxPort] @@ -56,6 +117,8 @@ export async function collectNativeContext(directory, { prefix, sphinxPort, vers } const pages = [] const redirects = [] + let toctree + let toctreeFile const window = new Window({ settings: { disableJavaScriptEvaluation: true, disableCSSFileLoading: true, disableJavaScriptFileLoading: true } }) try { for (const file of files.filter((path) => path.endsWith('.html') && !path.startsWith('_sources/'))) { @@ -68,6 +131,13 @@ export async function collectNativeContext(directory, { prefix, sphinxPort, vers const path = file.replace(/index\.html$/, '') const entry = metadata.get(`/${path}`) window.document.body.innerHTML = html + const sidebar = window.document.querySelector('.sidebar-tree') + if (!sidebar) throw new Error(`Native page has no global toctree: ${file}`) + const captured = captureToctree(sidebar, `${base}${path}`) + if (!toctree) { toctree = captured; toctreeFile = file } + else if (JSON.stringify(captured) !== JSON.stringify(toctree)) { + throw new Error(`Native global toctree differs between ${toctreeFile} and ${file}`) + } const sourcePath = window.document.querySelector('.page-source code')?.textContent?.trim() let source let markdownHref @@ -117,7 +187,7 @@ export async function collectNativeContext(directory, { prefix, sphinxPort, vers return { schema: 1, port: port.slug, version, locale, root, base, source: { repository: port.repo, sha }, - artifactSha256: nativeHash(JSON.stringify(hashes)), pages, redirects, + artifactSha256: nativeHash(JSON.stringify(hashes)), pages, redirects, toctree: toctree ?? [], } } diff --git a/scripts/port-docs-identity.sh b/scripts/port-docs-identity.sh index e49282f36..d30269c09 100755 --- a/scripts/port-docs-identity.sh +++ b/scripts/port-docs-identity.sh @@ -9,12 +9,14 @@ # branch's context, where checking out and running a pull request's head # could poison its caches. # - A push to the default branch publishes `latest`. It is the default version -# only until the port's first stable release: from then on `stable` is, and -# a push to trunk must not take the default back. TAGS lists the port's -# tags, one per line. -# - A release tag publishes its version plus an alias: `next` for a -# prerelease, `stable` (the default) for a release. TAG_PREFIX is stripped -# first, so libtmux-rs's `libtmux@v0.1.0` publishes `v0.1.0`. +# only until the port's first final release: from then on the newest final +# release tag is, and a push to trunk must not take the default back. TAGS +# lists the port's tags, one per line. +# - A release tag publishes its version alone, plus `next` for a prerelease. +# A final release is the default only when no newer final release tag +# exists, so a backport tag never takes the default from a newer release. +# TAG_PREFIX is stripped first, so libtmux-rs's `libtmux@v0.1.0` publishes +# `v0.1.0`. # - A dispatch publishes exactly what its inputs name, at any ref. # # Reads the event from the environment and writes source_ref, matrix and @@ -29,6 +31,20 @@ entry() { slug='^[A-Za-z0-9][A-Za-z0-9._-]*$' +# The final release versions in TAGS, prefix stripped. Any letter after the +# leading v marks a prerelease, whatever the grammar: 0.1.0-alpha.1, 0.62.0a1, +# 0.1.0.alpha.1, 0.1.0alpha1. +final_versions() { + local name version + while IFS= read -r name; do + [[ "$name" == "$TAG_PREFIX"* ]] || continue + version="${name#"$TAG_PREFIX"}" + if [[ "$version" =~ ^v?[0-9]+\.[0-9]+ && ! "${version#v}" =~ [A-Za-z] ]]; then + printf '%s\n' "$version" + fi + done <<< "${TAGS:-}" +} + case "$EVENT" in pull_request) source_ref="$SHA" @@ -56,24 +72,19 @@ case "$EVENT" in echo "unsupported release tag: $REF_NAME" >&2 exit 1 } - entries=$(entry "$version" tag false '' true) - # Any letter after the leading v marks a prerelease, whatever the - # grammar: 0.1.0-alpha.1, 0.62.0a1, 0.1.0.alpha.1, 0.1.0alpha1. if [[ "${version#v}" =~ [A-Za-z] ]]; then + entries=$(entry "$version" tag false '' true) entries+=$'\n'$(entry next alias false "$version" true) else - entries+=$'\n'$(entry stable alias true "$version" true) + # Newest by version order among every final tag and this one. + newest=$(printf '%s\n%s\n' "$(final_versions)" "$version" | sed '/^$/d; s/^v//' | sort -V | tail -n 1) + is_default=false + [[ "${version#v}" == "$newest" ]] && is_default=true + entries=$(entry "$version" tag "$is_default" '' true) fi elif [[ "$REF_NAME" == "$DEFAULT_BRANCH" ]]; then default=true - while IFS= read -r name; do - [[ "$name" == "$TAG_PREFIX"* ]] || continue - version="${name#"$TAG_PREFIX"}" - if [[ "$version" =~ ^v?[0-9]+\.[0-9]+ && ! "${version#v}" =~ [A-Za-z] ]]; then - default=false - break - fi - done <<< "${TAGS:-}" + [[ -n "$(final_versions)" ]] && default=false entries=$(entry latest trunk "$default" '' true) else echo "unsupported documentation branch: $REF_NAME" >&2 diff --git a/scripts/publish-default-versions.sh b/scripts/publish-default-versions.sh index 8c41b0970..9ae8cef42 100755 --- a/scripts/publish-default-versions.sh +++ b/scripts/publish-default-versions.sh @@ -31,8 +31,8 @@ if ! jq -e '.schema == 1 and (.defaultVersion | type == "object")' "$manifest" > exit 1 fi -# `latest` is the fallback: every port publishes one, `stable` only after a -# release. +# `latest` is the fallback: every port publishes one, a release tag only after +# the port's first final release. declare -A desired while IFS= read -r slug; do [[ -z "$slug" ]] && continue diff --git a/scripts/publish-plan.mjs b/scripts/publish-plan.mjs index 092e5e427..6180dc4ed 100644 --- a/scripts/publish-plan.mjs +++ b/scripts/publish-plan.mjs @@ -3,10 +3,10 @@ // One dispatch publishes any set of ports at a ref: // // - `latest` publishes each port's default branch as `latest`. It is the -// default version only while the port has no stable release, the rule a +// default version only while the port has no final release, the rule a // trunk push follows (scripts/port-docs-identity.sh). // - `release` republishes each port's newest release tag, plus `next` for a -// prerelease or `stable` (the default) for a release, as a tag push does. +// prerelease. A final release is the default, as a tag push makes it. // - Any other ref is one port's exact ref, published as the inputs name it. // // Dispatch capability and the caller branch come from the port catalog. @@ -80,15 +80,15 @@ export function plan(inputs, catalog, lookup, versions) { workflow: dispatch.workflow, dispatchRef: dispatch.ref ?? defaultBranch, language: dispatch.language ?? '' } const releases = tags.filter((tag) => versions.releaseTag(tag, port) !== null) if (ref === 'latest') { - const stable = releases.some((tag) => !versions.packageVersionIsPrerelease(versionOf(tag, port), port.tagGrammar)) - entries.push({ ...base, sourceRef: defaultBranch, version: 'latest', kind: 'trunk', isDefault: !stable, resolvesTo: '' }) + const released = releases.some((tag) => !versions.packageVersionIsPrerelease(versionOf(tag, port), port.tagGrammar)) + entries.push({ ...base, sourceRef: defaultBranch, version: 'latest', kind: 'trunk', isDefault: !released, resolvesTo: '' }) } else if (ref === 'release') { const tag = versions.newestPublishedTag(releases, port, null) if (!tag) continue const version = versionOf(tag, port) - const alias = versions.packageVersionIsPrerelease(version, port.tagGrammar) ? 'next' : 'stable' - entries.push({ ...base, sourceRef: tag, version, kind: 'tag', isDefault: false, resolvesTo: '' }) - entries.push({ ...base, sourceRef: tag, version: alias, kind: 'alias', isDefault: alias === 'stable', resolvesTo: version }) + const prerelease = versions.packageVersionIsPrerelease(version, port.tagGrammar) + entries.push({ ...base, sourceRef: tag, version, kind: 'tag', isDefault: !prerelease, resolvesTo: '' }) + if (prerelease) entries.push({ ...base, sourceRef: tag, version: 'next', kind: 'alias', isDefault: false, resolvesTo: version }) } else { const kind = inputs.versionKind if (!KINDS.includes(kind)) fail(`an exact ref needs version-kind trunk, tag or alias, not ${kind || 'auto'}`) diff --git a/scripts/test-all.sh b/scripts/test-all.sh index f10dbcb5c..1f457322e 100755 --- a/scripts/test-all.sh +++ b/scripts/test-all.sh @@ -288,7 +288,7 @@ step 'build' if [[ -n "$preview" ]]; then LIBTMUX_DOCS_LOCALES_ROOT="$preview" LIBTMUX_DOCS_VERSION="${preview#/}" \ LIBTMUX_DOCS_VERSION_KIND=pr LIBTMUX_DOCS_IS_DEFAULT=false \ - ./scripts/build-site.sh --versions latest,stable + ./scripts/build-site.sh --versions latest # Production robots, sitemaps and indexing must still render on a PR. # Two root locale renders cover those contracts without rebuilding ports. @@ -419,7 +419,7 @@ node scripts/check-api-fidelity.mjs "$site_out" # twin as well — which only a full assembly produces. Both run against a # running server; `pnpm test:publication` reports that they were not run rather than # implying they passed. -if curl --connect-timeout 1 --max-time 3 -sf -o /dev/null "$SERVE_SITE/py/stable/reference/libtmux-server/"; then +if curl --connect-timeout 1 --max-time 3 -sf -o /dev/null "$SERVE_SITE/py/latest/reference/libtmux-server/"; then # Type is checked here rather than with the static suites because half of # it is a rendering question: which faces a page opens with is answered by # laying the page out, not by reading its HTML. @@ -444,7 +444,7 @@ if curl --connect-timeout 1 --max-time 3 -sf -o /dev/null "$SERVE_SITE/py/stable step 'Ruby and Lua browser coverage' (cd site && node scripts/check-ruby-lua.mjs "$SERVE_SITE") - if curl --connect-timeout 1 --max-time 3 -sf -o /dev/null "$SERVE_SITE/py/stable/api/api/libtmux.server/"; then + if curl --connect-timeout 1 --max-time 3 -sf -o /dev/null "$SERVE_SITE/py/latest/api/api/libtmux.server/"; then step 'native page navigation' (cd site && node scripts/check-native-shell.mjs "$SERVE_SITE") (cd site && node scripts/check-native-navigation.mjs "$SERVE_SITE") diff --git a/scripts/tmux-usage/claims.json b/scripts/tmux-usage/claims.json index fdee8baa2..1caa6ec8e 100644 --- a/scripts/tmux-usage/claims.json +++ b/scripts/tmux-usage/claims.json @@ -11144,19 +11144,19 @@ "forwardable": true, "evidence": [ { - "at": "src/LibTmux/Pane.Topology.cs:588", + "at": "src/LibTmux/Pane.Topology.cs:590", "has": [ "_commandDispatcher.ExecuteAsync(arguments" ] }, { - "at": "src/LibTmux/Pane.Topology.cs:105", + "at": "src/LibTmux/Pane.Topology.cs:107", "has": [ "\"split-window\"" ] }, { - "at": "src/LibTmux/Pane.Topology.cs:244", + "at": "src/LibTmux/Pane.Topology.cs:246", "has": [ "CreatePaneFromAsync(arguments, \"split-window\"" ], diff --git a/scripts/tmux-usage/conditions.json b/scripts/tmux-usage/conditions.json index 49a602271..597feb833 100644 --- a/scripts/tmux-usage/conditions.json +++ b/scripts/tmux-usage/conditions.json @@ -661,13 +661,13 @@ "when": "break-pane prints no window ID", "evidence": [ { - "at": "src/LibTmux/Pane.Topology.cs:192", + "at": "src/LibTmux/Pane.Topology.cs:194", "has": [ "result.StandardOutputLines.Count == 0" ] }, { - "at": "src/LibTmux/Pane.Topology.cs:196", + "at": "src/LibTmux/Pane.Topology.cs:198", "has": [ "\"display-message\", \"-p\", \"-t\", Target" ] diff --git a/scripts/tmux-usage/dispatchers.json b/scripts/tmux-usage/dispatchers.json index 129cbb66f..a1aa2c6ca 100644 --- a/scripts/tmux-usage/dispatchers.json +++ b/scripts/tmux-usage/dispatchers.json @@ -8039,13 +8039,13 @@ "why": "Sends the tmux arguments it is given, or the list command it is named for, to the server.", "evidence": [ { - "at": "src/LibTmux/Pane.Topology.cs:579", + "at": "src/LibTmux/Pane.Topology.cs:581", "has": [ "CreatePaneFromAsync" ], "reaches": [ { - "at": "src/LibTmux/Pane.Topology.cs:588", + "at": "src/LibTmux/Pane.Topology.cs:590", "has": [ "_commandDispatcher.ExecuteAsync(arguments, cancellationToken)" ], @@ -8157,7 +8157,7 @@ "why": "Builds the argument list of a command from the command it is given.", "evidence": [ { - "at": "src/LibTmux/Pane.Topology.cs:545", + "at": "src/LibTmux/Pane.Topology.cs:547", "has": [ "BuildRehomeArguments" ] diff --git a/scripts/tmux-usage/not-senders.json b/scripts/tmux-usage/not-senders.json index 1094d958c..1e463f730 100644 --- a/scripts/tmux-usage/not-senders.json +++ b/scripts/tmux-usage/not-senders.json @@ -417,13 +417,13 @@ "why": "These send next-layout and previous-layout, and last-pane, and not select-layout or select-window.", "evidence": [ { - "at": "src/LibTmux/Window.Layout.cs:122", + "at": "src/LibTmux/Window.Layout.cs:126", "has": [ "\"next-layout\"" ] }, { - "at": "src/LibTmux/Window.Layout.cs:135", + "at": "src/LibTmux/Window.Layout.cs:139", "has": [ "\"previous-layout\"" ] diff --git a/scripts/version-bookkeeping.sh b/scripts/version-bookkeeping.sh index 7615f5467..750509af4 100644 --- a/scripts/version-bookkeeping.sh +++ b/scripts/version-bookkeeping.sh @@ -70,9 +70,9 @@ default_version_for() { # Whether this port's manifest actually lists a version slug. # -# `stable` is absent for a port with no release, so building one would serve a -# tree the switcher does not list and the reader cannot reach by any offered -# route. site/test/site-pruning.test.ts asserts the two agree. +# A slug the manifest does not list would serve a tree the switcher does not +# offer and the reader cannot reach by any offered route. +# site/test/site-pruning.test.ts asserts the two agree. port_lists_version() { LIBTMUX_DOCS_MANIFEST="$manifest" LIBTMUX_DOCS_PORT="$1" LIBTMUX_DOCS_VERSION_SLUG="$2" node -e ' const fs = require("node:fs") @@ -83,8 +83,8 @@ port_lists_version() { } # Every port's default version, as JSON, for the components that link across -# ports. `stable` is not a safe constant any more: a port with no release has -# no stable entry, so a switcher hard-coding it links at a tree nothing builds. +# ports. A port's default is its newest final release tag, or `latest` while it +# has none, so no slug is a safe constant. port_defaults_json() { LIBTMUX_DOCS_MANIFEST="$manifest" node -e ' const fs = require("node:fs") @@ -100,7 +100,6 @@ kind_for_version() { fi case "$1" in latest) echo trunk ;; - stable) echo alias ;; pr-*) echo pr ;; v*.x) echo branch ;; v*.*.*) echo tag ;; @@ -135,7 +134,7 @@ for version in "${versions[@]}"; do fi die "cannot build '$version': this script renders the checkout at HEAD and never checks anything out, so this slug would publish current content at - //$version/ as though it came from that source. Use latest or stable." + //$version/ as though it came from that source. Use latest." ;; esac done diff --git a/site/astro.config.ts b/site/astro.config.ts index a9ac855f1..71f5c43ff 100644 --- a/site/astro.config.ts +++ b/site/astro.config.ts @@ -32,7 +32,7 @@ import { isLegacyTmuxManualPath } from './src/lib/tmux-manual-data.ts' * falls back to a root-mounted trunk build so the site is browsable with no * environment set at all. * - * LIBTMUX_DOCS_VERSION 'latest' | 'stable' | 'v0.46.2' | 'v0.x' | 'pr-123' + * LIBTMUX_DOCS_VERSION 'latest' | 'next' | 'v0.46.2' | 'v0.x' | 'pr-123' * LIBTMUX_DOCS_VERSION_KIND 'trunk' | 'tag' | 'branch' | 'pr' | 'alias' * LIBTMUX_DOCS_IS_DEFAULT 'true' on the one build that may be indexed * LIBTMUX_DOCS_BASE override the URL base; defaults to '/' diff --git a/site/scripts/check-badge-centring.mjs b/site/scripts/check-badge-centring.mjs index 3bafdb38e..7fcbfed0f 100644 --- a/site/scripts/check-badge-centring.mjs +++ b/site/scripts/check-badge-centring.mjs @@ -20,9 +20,11 @@ import { chromium } from 'playwright' * * `p` and `$` are not measured: their ink hangs below the baseline. */ +/** The version the dev build mounts a port's prose pages at: its default, as check-dev sets it. */ +const defaultVersion = (port) => JSON.parse(process.env.LIBTMUX_DOCS_PORT_DEFAULTS || '{}')[port] ?? 'latest' const PAGES = [ { label: 'Rust MCP reference', path: '/rs/latest/mcp/reference/mcp-caller-calleridentity-from_env/' }, - { label: 'Python attaching-to-tmux', path: '/py/stable/guides/attaching-to-tmux/' }, + { label: 'Python attaching-to-tmux', get path() { return `/py/${defaultVersion('py')}/guides/attaching-to-tmux/` } }, { label: 'TypeScript reference', path: '/ts/latest/reference/client-client/' }, { label: 'Go reference', path: '/go/latest/reference/tmux-server-server/' }, { label: 'tmux manual', path: '/tmux/latest/manual/list-clients/' }, @@ -634,7 +636,7 @@ export async function checkMentionDensity(browser, base) { } return found }) - await page.goto(`${base}/py/stable/guides/attaching-to-tmux/`, { waitUntil: 'load' }) + await page.goto(`${base}/py/${defaultVersion('py')}/guides/attaching-to-tmux/`, { waitUntil: 'load' }) await page.waitForFunction(() => document.documentElement.dataset.pageReadiness === 'ready', null, { timeout: 30000 }).catch(() => {}) const marked = await page.locator('a:has(> .api-link-kind)').count() assert(marked > 0, 'No marked mention to check') diff --git a/site/scripts/check-dev-sample.mjs b/site/scripts/check-dev-sample.mjs index 2575ebde4..4c3238d30 100644 --- a/site/scripts/check-dev-sample.mjs +++ b/site/scripts/check-dev-sample.mjs @@ -259,7 +259,7 @@ export async function checkDevSample(browser, base) { 'A declaration permalink lands on its signature bar') assert.equal(await declaration.locator(':scope > .section-anchor-alias').getAttribute('id'), `${identity}.declaration`, 'The previous declaration fragment remains available') - const equivalents = page.locator('.api-elsewhere a') + const equivalents = page.locator('section:has(> #api-other-ports) .tmux-usage a') const hrefs = await equivalents.evaluateAll((links) => links.map((link) => link.getAttribute('href'))) const java = hrefs.find((href) => /\/java\/latest\/reference\/.*capture/.test(href)) assert(java, 'Pane.capture has its verified Java equivalent') diff --git a/site/scripts/check-dev.mjs b/site/scripts/check-dev.mjs index 0045315e7..7212a1831 100644 --- a/site/scripts/check-dev.mjs +++ b/site/scripts/check-dev.mjs @@ -19,7 +19,7 @@ import { checkHomeExampleOptions } from './check-home-example-options.mjs' import { checkDevSample, checkRowPermalinks } from './check-dev-sample.mjs' import { checkDeclarationControlAlignment, checkDeclarationControlsLevel, checkMemberBodyInsets, checkNativeSignatureGeometry, checkNativeSignatureLinks } from './check-native-layout.mjs' import { checkBadgeCentring, checkChipGrowth, checkMentionDensity, checkUsageChips } from './check-badge-centring.mjs' -import { checkBlockLinksUndecorated, checkKindBadgeLinks, checkKindBadgeLinksFail, checkRequiredAppearance, checkTmuxReferencePreviews, checkWebAnalytics, checkWebAnalyticsTransitions } from './check-page-readiness.mjs' +import { checkBlockLinksUndecorated, checkKindBadgeLinks, checkKindBadgeLinksFail, checkRequiredAppearance, checkTmuxReferencePreviews, checkTmuxReferencePreviewsFail, checkWebAnalytics, checkWebAnalyticsTransitions } from './check-page-readiness.mjs' import { checkTypeParameters } from './check-type-parameters.mjs' import { checkTmuxKeys, TMUX_KEY_PAGES } from './check-tmux-keys.mjs' import { checkSidebarDemo } from './check-sidebar-demo.mjs' @@ -56,11 +56,11 @@ Object.assign(process.env, { LIBTMUX_DOCS_SITE: 'https://libtmux.org', LIBTMUX_DOCS_BASE: '/en/', LIBTMUX_DOCS_ROOT: '/en', LIBTMUX_DOCS_PORT_ROOT: '/en', LIBTMUX_DOCS_LOCALES_ROOT: '', LIBTMUX_DOCS_LOCALE: 'en', LIBTMUX_DOCS_PORT: '', - LIBTMUX_DOCS_VERSION: 'latest', LIBTMUX_DOCS_PORT_DEFAULTS: '{"py":"stable"}', + LIBTMUX_DOCS_VERSION: 'latest', LIBTMUX_DOCS_PORT_DEFAULTS: '{"py":"v0.46.2"}', }) // The one version of each port's reference this build serves: its own target, as the site's build target says it. A port's core // reference is a tree of its own, so a link to another version of it (the Python reference that the other ports link to at its -// default, `stable`) names a tree this build does not contain. The routes below and the checks that ask what is served read it here. +// default version) names a tree this build does not contain. The routes below and the checks that ask what is served read it here. const MIRRORED_VERSION = buildTarget(process.env).version // Astro always writes root/.astro, so a separate cacheDir alone cannot isolate it. const source = fileURLToPath(new URL('../', import.meta.url)) @@ -754,11 +754,24 @@ async function checkReferenceAndHeroes(browser, base) { qualifiedName: 'io.github.libtmux.Server', namespace: 'io.github.libtmux', }, 'Java manifest records source identity alongside its stable declaration URL') await page.goto(`${base}/kotlin/latest/reference/io-github-libtmux-kotlin-server/`) - const javaEquivalent = page.locator('.api-elsewhere a[href$="/java/latest/reference/io-github-libtmux-server-server/"]') - assert.equal(await javaEquivalent.locator(':scope > code').textContent(), 'io.github.libtmux.Server', - 'Equivalent Java API labels use the target source identity while retaining its stable URL') - assert.equal(await javaEquivalent.locator(':scope > .api-badge--kind-class[aria-hidden="true"]').textContent(), 'C', - 'The decorative kind badge remains separate from the exact source name') + // The equivalent is a row of the In other ports table: the target's source name in code, led by its decorative kind badge. + const javaEquivalent = page.locator('section:has(> #api-other-ports) .tmux-usage a[href$="/java/latest/reference/io-github-libtmux-server-server/"]') + const assertJavaEquivalent = async () => { + assert.equal(await javaEquivalent.count(), 1, 'The In other ports table links the Java equivalent') + assert.equal(await javaEquivalent.locator(':scope > code').count(), 1, 'The Java equivalent names its target in code') + assert.equal(await javaEquivalent.locator(':scope > code').textContent(), 'io.github.libtmux.Server', + 'Equivalent Java API labels use the target source identity while retaining its stable URL') + assert.equal(await javaEquivalent.locator(':scope > .api-badge--kind-class[aria-hidden="true"]').count(), 1, + 'The Java equivalent keeps its decorative kind badge') + assert.equal(await javaEquivalent.locator(':scope > .api-badge--kind-class[aria-hidden="true"]').textContent(), 'C', + 'The decorative kind badge remains separate from the exact source name') + } + await assertJavaEquivalent() + // The control: the same assertions fail once the badge or the code is gone. + await javaEquivalent.locator(':scope > .api-badge--kind-class').evaluate((badge) => badge.remove()) + await assert.rejects(assertJavaEquivalent(), /keeps its decorative kind badge/) + await javaEquivalent.locator(':scope > code').evaluate((code) => code.replaceWith(document.createElement('span'))) + await assert.rejects(assertJavaEquivalent(), /names its target in code/) console.log('Java names: source package and exact qualified names render without changing declaration anchors') } finally { await page.close() @@ -771,7 +784,7 @@ try { const firstPage = homeLauncherOnly || homeControlsOnly ? '/' : keywordHelpOnly ? '/kotlin/latest/reference/io-github-libtmux-kotlin-withserver/' : apiStickyOnly ? '/swift/latest/reference/server/' - : badgeCentringOnly ? '/py/stable/guides/attaching-to-tmux/' + : badgeCentringOnly ? '/py/v0.46.2/guides/attaching-to-tmux/' : referencePreviewsOnly ? '/cxx/latest/reference/libtmux-server-panes/' : documentationNavigationOnly || headerMenuSectionsOnly || statusBadgesOnly ? '/py/latest/' : apiSignaturesOnly ? '/api-signature-probe/' : apiNavigationOnly ? '/lua/latest/reference/libtmux-server/' @@ -830,6 +843,7 @@ try { await checkUsageChips(browser, base) } else if (referencePreviewsOnly) { await retryReload(() => checkTmuxReferencePreviews(browser, base, { served: servedBuild(base) })) + await checkTmuxReferencePreviewsFail(browser, base) } else if (referencePreferencesOnly) { await retryReload(() => checkReferencePreferences(browser, base)) await retryReload(() => checkGlobalHeader(browser, base)) @@ -913,7 +927,8 @@ try { .then(() => checkChipGrowth(browser, base)) .then(() => checkUsageChips(browser, base))) const blockLinks = schedule(() => retryReload(() => checkBlockLinksUndecorated(browser, base))) - const referencePreviews = schedule(() => retryReload(() => checkTmuxReferencePreviews(browser, base, { served: servedBuild(base) }))) + const referencePreviews = schedule(() => retryReload(() => checkTmuxReferencePreviews(browser, base, { served: servedBuild(base) })) + .then(() => checkTmuxReferencePreviewsFail(browser, base))) await apiAnchors const apiSticky = schedule(() => retryReload(() => checkApiStickyHeadings(browser, base)) .then(() => checkApiStickyHeadingsFail(browser, base))) @@ -923,7 +938,7 @@ try { const typeParameters = schedule(() => retryReload(() => checkTypeParameters(browser, base))) await typeParameters const paths = ['tmux/concepts/server-session-window-pane', 'tmux/examples/attach-and-send-keys', 'mcp/tools', 'ts/latest/workspace/reference/builder-applyworkspace', - 'ts/latest/workspace/internals/guides', 'py/stable/workspace/guides', + 'ts/latest/workspace/internals/guides', 'py/v0.46.2/workspace/guides', 'ts/latest/mcp/tools', 'csharp/latest/mcp/tools/capture_pane'] for (const path of paths) await retryReload(async () => { await page.setViewportSize({ width: 1440, height: 1000 }) @@ -950,13 +965,13 @@ try { }) assert(geometry.above && geometry.contextAbove, `${path}: context controls precede the breadcrumb and heading`) } - const expected = isReference ? '/en/py/stable/workspace/reference/tmuxp-workspace-builder-classicworkspacebuilder-build/' : path.includes('workspace/') ? `/en/${path}/` - : path === 'csharp/latest/mcp/tools/capture_pane' ? '/en/py/stable/mcp/tools/capture_pane/' : `/en/py/stable/${path.replace(/^(?:ts\/latest\/|tmux\/)/, '')}/` + const expected = isReference ? '/en/py/v0.46.2/workspace/reference/tmuxp-workspace-builder-classicworkspacebuilder-build/' : path.includes('workspace/') ? `/en/${path}/` + : path === 'csharp/latest/mcp/tools/capture_pane' ? '/en/py/v0.46.2/mcp/tools/capture_pane/' : `/en/py/v0.46.2/${path.replace(/^(?:ts\/latest\/|tmux\/)/, '')}/` if (hasSwitcher) { assert.equal(await portLinks.first().getAttribute('href'), expected) assert.equal(await switcher.locator('.tmux-area a').getAttribute('href'), '/en/tmux/') } - if (path === 'py/stable/workspace/guides') { + if (path === 'py/v0.46.2/workspace/guides') { // Native PowerShell and Julia articles live at workspace/source-guide, // not this guide index; product availability alone is not a counterpart. const guidePorts = ['py', 'ruby', 'ts', 'rs', 'go', 'java', 'csharp', 'cxx', 'swift'] @@ -985,7 +1000,7 @@ try { assert.match(await python.textContent(), /No matching page/) assert.equal(await python.locator('a[data-port]').count(), 0) assert.equal(await python.getAttribute('aria-disabled'), null) - assert.equal(await python.locator('[data-picker-home]').getAttribute('href'), '/en/py/stable/workspace/') + assert.equal(await python.locator('[data-picker-home]').getAttribute('href'), '/en/py/v0.46.2/workspace/') assert.equal(await python.locator('[data-picker-home]').getAttribute('aria-label'), 'Go to Python Workspace Manager home') } if (path === 'csharp/latest/mcp/tools/capture_pane') { @@ -994,7 +1009,7 @@ try { port: link.dataset.port, href: link.getAttribute('href'), })))).sort((a, b) => a.port.localeCompare(b.port)), capturePorts.map((port) => ({ - port, href: `/en/${port}/${port === 'py' ? 'stable' : 'latest'}/mcp/tools/capture_pane/`, + port, href: `/en/${port}/${port === 'py' ? 'v0.46.2' : 'latest'}/mcp/tools/capture_pane/`, })).sort((a, b) => a.port.localeCompare(b.port))) assert.equal(await switcher.locator('a[aria-current="page"]').getAttribute('href'), `/en/${path}/`) } @@ -1033,8 +1048,8 @@ try { assert.equal(result.redundantHeaderLinks, 0, 'Surface destinations are absent from the header bar') assert(result.headerControls.every((control) => Math.abs(control.height - result.headerControls[0].height) < 0.1 && Math.abs(control.top - result.headerControls[0].top) < 0.1), `${path} at ${width}px: header controls align at equal heights`) - // tmux pages document tmux itself, so the libtmux alpha notice is absent there. - if (path.startsWith('tmux/')) assert.equal(result.badgeForeground, null, `${path}: no libtmux alpha notice`) + // tmux pages document tmux itself, so the libtmux release notice is absent there. + if (path.startsWith('tmux/')) assert.equal(result.badgeForeground, null, `${path}: no libtmux release notice`) else assert.equal(result.badgeForeground, 'rgb(255, 255, 255)', 'Filled badge uses white foreground') if (width < 1536) assert(result.schemeLabelWidth <= 1, 'Compact color-scheme controls hide their text visually') assert(result.overflow <= 1, `${path} at ${width}px: page overflow ${result.overflow}px`) @@ -1062,13 +1077,15 @@ try { }, page) for (const path of [ 'py/latest/reference/libtmux-server', - 'py/stable/workspace/reference/tmuxp-workspace-builder-classicworkspacebuilder', + 'py/v0.46.2/workspace/reference/tmuxp-workspace-builder-classicworkspacebuilder', 'java/latest/workspace/reference/io-github-libtmux-workspace-workspacebuilder-workspacebuilder', ]) await retryReload(async () => { const response = await page.goto(`${base}/${path}/`, { waitUntil: 'load' }) assert(response?.ok(), `${path}: HTTP ${response?.status()}`) await page.evaluate(() => document.fonts.ready) + // A product page's members keep the collapsed disclosure; the page's own equivalents are a table that is always open. await page.locator('.api-elsewhere').evaluateAll((entries) => entries.forEach((entry) => { entry.open = true })) + assert(await page.locator('.api-elsewhere, section:has(> #api-other-ports) .tmux-usage table').count() > 0, `${path}: no equivalents were open to measure`) for (const width of [1440, 768, 390]) { await page.setViewportSize({ width, height: 1000 }) const overflow = await page.evaluate(() => document.documentElement.scrollWidth - innerWidth) @@ -1122,7 +1139,7 @@ try { for (const mode of ['light', 'dark']) { await page.locator(`.scheme-switch input[value="${mode}"]`).check({ force: true }) let reference - for (const port of ['py/stable', 'swift/latest', 'go/latest', 'cxx/latest']) { + for (const port of ['py/v0.46.2', 'swift/latest', 'go/latest', 'cxx/latest']) { await page.goto(`${base}/${port}/workspace/`, { waitUntil: 'load' }) const reading = await page.evaluate(() => { const tokens = getComputedStyle(document.documentElement) diff --git a/site/scripts/check-fonts.mjs b/site/scripts/check-fonts.mjs index e33074361..da8033c40 100755 --- a/site/scripts/check-fonts.mjs +++ b/site/scripts/check-fonts.mjs @@ -50,7 +50,7 @@ const FAMILIES = ['IBM Plex Sans', 'IBM Plex Mono'] const ARCHETYPES = [ ['home', '/', true], ['port page', '/py/', true], - ['reference entry', '/py/stable/reference/libtmux-server/', true], + ['reference entry', '/py/latest/reference/libtmux-server/', true], ['reference index', '/go/latest/reference/', true], ['symbol index', '/reference/symbols/p/', true], ['topic', '/tmux/topics/traversal/', true], @@ -58,7 +58,7 @@ const ARCHETYPES = [ // Sphinx builds this one and emits its own preloads. It is checked — a // vendored page still has to open with the type it declares — but its // preload list is gp-sphinx's to choose, so it does not vote on ours. - ['vendored gp-sphinx', '/py/stable/api/api/libtmux.server/', false], + ['vendored gp-sphinx', '/py/latest/api/api/libtmux.server/', false], // One reference entry per port. The layout is shared, but the content is // not: a C++ signature and a Go one reach for different faces, and the // goal is no missing text in *any* port rather than in the one that was @@ -66,7 +66,7 @@ const ARCHETYPES = [ // `libtmux.Server`, not a `_compat` shim: the reference stopped publishing // the vendored and compatibility modules, and a sample page has to be one // the port actually exports if it is to keep being built. - ['ref py', '/py/stable/reference/libtmux-server/', true], + ['ref py', '/py/latest/reference/libtmux-server/', true], ['ref ts', '/ts/latest/reference/builder-applywindowcontext/', true], ['ref rs', '/rs/latest/reference/blocking-runtime/', true], ['ref go', '/go/latest/reference/tmux-activityaction/', true], @@ -78,7 +78,7 @@ const ARCHETYPES = [ // lists its members, the member carries the signature. The italic type // annotations in a signature live only here, so an archetype list without // one reports Mono 400 italic as preloaded and unused. - ['member py', '/py/stable/reference/libtmux-server-wait_for/', true], + ['member py', '/py/latest/reference/libtmux-server-wait_for/', true], ['member dotnet', '/csharp/latest/reference/libtmux-pane-clearhistoryasync/', true], ] diff --git a/site/scripts/check-mobile-nav.mjs b/site/scripts/check-mobile-nav.mjs index 0d9ddb0ed..8a1679183 100755 --- a/site/scripts/check-mobile-nav.mjs +++ b/site/scripts/check-mobile-nav.mjs @@ -134,7 +134,7 @@ for (const [w, want] of [[360, true], [390, true], [768, true], [1023, true], [1 await p.close() } // The shared picker stays reachable while the API drawer opens and resizes. -for (const path of ['/go/latest/reference/', '/py/stable/reference/libtmux-server/']) { +for (const path of ['/go/latest/reference/', '/py/latest/reference/libtmux-server/']) { const p = await page(path) const menu = p.locator('[data-documentation-context] [data-surface-picker]') const trigger = menu.locator(':scope > summary') diff --git a/site/scripts/check-native-layout.mjs b/site/scripts/check-native-layout.mjs index 3dcb2c8bb..db2dd4c92 100644 --- a/site/scripts/check-native-layout.mjs +++ b/site/scripts/check-native-layout.mjs @@ -451,13 +451,15 @@ export function measureMemberBodies(page) { } /** - * Pages that give each port a member body of every common shape: only "In other - * ports", parameters first, a description or example last, Methods, a type, + * Pages that give each port a member body of every common shape: a member listed on + * a product page, whose last row is the collapsed "In other ports" disclosure (a page's own + * symbol lists its equivalents as a section instead), parameters first, a description or example last, Methods, a type, * a command and an MCP object. The second field names a direct child the page * must still render, so a content change cannot quietly retire the sample. */ const MEMBER_BODY_PAGES = [ - ['go/latest/reference/tmux-server-configfile/', 'details.api-elsewhere'], + ['py/v0.46.2/workspace/reference/tmuxp-workspace-builder-classicworkspacebuilder/', 'details.api-elsewhere'], + ['java/latest/workspace/reference/io-github-libtmux-workspace-workspacebuilder-workspacebuilder/', 'details.api-elsewhere'], ['go/latest/reference/tmux-window-setotherpanewidth/', 'div.gp-sphinx-api-parameters'], ['julia/latest/reference/libtmux-snapshot-1gv6/', 'div.gp-sphinx-api-methods'], ['julia/latest/reference/libtmux-kill_window/', 'div.gp-sphinx-api-description'], @@ -465,10 +467,9 @@ const MEMBER_BODY_PAGES = [ ['ruby/latest/workspace/reference/libtmux-workspace-configerror/', 'p.gp-sphinx-api-facts'], ['py/latest/reference/libtmux-server-new_session/', 'div.gp-sphinx-api-examples'], ['py/latest/reference/libtmux-common-has_lt_version/', 'div.gp-sphinx-api-parameters'], - ['ts/latest/reference/server-server-configfile/', 'details.api-elsewhere'], + ['swift/latest/reference/server-loadbuffer(from-named-)/', 'div.gp-sphinx-api-parameters'], + ['ts/latest/reference/server-server-configfile/', 'div.gp-sphinx-api-examples'], ['ts/latest/reference/types-newsessionoptions/', 'div.gp-sphinx-api-description'], - ['swift/latest/reference/pane-index/', 'details.api-elsewhere'], - ['csharp/latest/reference/libtmux-window-height/', 'details.api-elsewhere'], ['csharp/latest/reference/libtmux-server-searchclientsasync/', 'div.gp-sphinx-api-parameters'], ['java/latest/reference/io-github-libtmux-windowlayout-windowlayout/', 'div.gp-sphinx-api-examples'], ['java/latest/mcp/reference/io-github-libtmux-mcp-main-main/', 'div.gp-sphinx-api-examples'], @@ -490,7 +491,7 @@ export async function checkMemberBodyInsets(browser, base) { await page.goto(`${base}/${path}`, { waitUntil: 'load' }) await page.evaluate(() => document.fonts.ready) const bodies = await measureMemberBodies(page) - assert(bodies.some((body) => body.children.includes(shape)), `${path}: still renders ${shape}`) + assert(bodies.some((body) => body.children.includes(shape)), `${path}: still renders ${shape} (its bodies hold ${JSON.stringify(bodies.map((body) => body.children))})`) for (const body of bodies) { measured += 1 const { top, bottom, padding } = body diff --git a/site/scripts/check-native-navigation.mjs b/site/scripts/check-native-navigation.mjs index 3961f3a37..8d1f2f6ba 100644 --- a/site/scripts/check-native-navigation.mjs +++ b/site/scripts/check-native-navigation.mjs @@ -3,7 +3,7 @@ import assert from 'node:assert/strict' import { chromium } from 'playwright' const base = (process.argv.find((arg) => arg.startsWith('http')) ?? 'http://localhost:8080/en').replace(/\/$/, '') -const version = process.argv.find((arg) => arg.startsWith('--version='))?.slice('--version='.length) ?? 'stable' +const version = process.argv.find((arg) => arg.startsWith('--version='))?.slice('--version='.length) ?? 'latest' const root = `${base}/py/${version}/api/` const browser = await chromium.launch({ channel: process.env.LIBTMUX_DOCS_BROWSER_CHANNEL }) @@ -27,6 +27,58 @@ async function openNativeLink(page, suffix) { return scroll } +/** The sidebar is the Sphinx global toctree: nested, the current page's ancestors open, externals marked, no id as a label. */ +async function checkToctree(page, current) { + const opener = page.locator('[data-api-nav-toggle]') + if (await opener.isVisible() && await opener.getAttribute('aria-expanded') !== 'true') await opener.click() + const state = await page.evaluate(() => { + const tree = document.querySelector('.api-nav__tree') + const rows = [...tree.querySelectorAll('.api-nav__label')].map((label) => label.textContent.trim()) + const here = tree.querySelector('a[aria-current="page"]') + const ancestors = [] + for (let item = here?.closest('li')?.parentElement?.closest('li'); item; item = item.parentElement?.closest('li')) { + ancestors.push({ label: item.querySelector(':scope > .api-nav__row .api-nav__label')?.textContent.trim(), expanded: item.getAttribute('aria-expanded') }) + } + const external = [...tree.querySelectorAll('a[target="_blank"]')].map((link) => ({ label: link.textContent.replace(/\s+/g, ' ').trim(), rel: link.rel, mark: link.hasAttribute('data-external-link') && !link.querySelector('.api-nav__external'), sr: /opens in a new tab/.test(link.textContent) })) + const depth = Math.max(0, ...[...tree.querySelectorAll('[aria-level]')].map((item) => Number(item.getAttribute('aria-level')))) + return { rows, top: [...tree.querySelectorAll(':scope > li')].map((item) => item.querySelector('.api-nav__label')?.textContent.trim()), here: here?.pathname, ancestors, external, depth, + groups: tree.querySelectorAll('[role="group"]').length, flat: tree.querySelector('.api-nav__section:not(.api-nav__caption)') !== null } + }) + const where = `Toctree at ${current}` + for (const title of ['Quickstart', 'Topics', 'API Reference', 'Internals', 'Project', 'Changelog', 'Glossary']) { + assert(state.top.includes(title), `${where}: top level lacks ${title}: ${state.top}`) + } + assert(state.depth >= 3 && state.groups > 3, `${where}: the tree is not nested (depth ${state.depth}, ${state.groups} groups)`) + assert(!state.flat, `${where}: a flat section list is back`) + assert(state.here?.endsWith(current), `${where}: the current page is not marked: ${state.here}`) + assert(state.ancestors.length >= 1 && state.ancestors.every((item) => item.expanded === 'true'), `${where}: ancestors are not open: ${JSON.stringify(state.ancestors)}`) + assert(state.external.some((item) => item.label.startsWith('GitHub') && item.mark && item.sr && /noopener/.test(item.rel)), `${where}: GitHub is not marked as leaving the site: ${JSON.stringify(state.external)}`) + assert(!state.rows.some((row) => row.startsWith('page:')), `${where}: a row is labelled with an id: ${state.rows.find((row) => row.startsWith('page:'))}`) +} + +async function checkToctreeSearch(page) { + const input = page.locator('#api-symbol-search') + await input.fill('client') + await page.locator('[data-api-search-results] a').first().waitFor() + const labels = await page.locator('[data-api-search-results] a').allTextContents() + assert(labels.length > 0 && !labels.some((label) => label.includes('page:')), `Search shows a page id: ${labels.find((label) => label.includes('page:'))}`) + await input.fill('') +} + +async function checkToctreeNegative(page, current) { + // The same assertions must reject a flattened tree and a raw id as a label. + await page.evaluate(() => { + const tree = document.querySelector('.api-nav__tree') + for (const item of tree.querySelectorAll('li[aria-expanded]')) item.setAttribute('aria-expanded', 'false') + }) + await assert.rejects(checkToctree(page, current), /ancestors are not open/) + await page.evaluate(() => { + document.querySelector('.api-nav__tree').querySelectorAll('li[aria-expanded]').forEach((item) => item.setAttribute('aria-expanded', 'true')) + document.querySelector('.api-nav__tree .api-nav__group .api-nav__leaf .api-nav__label').textContent = 'page:api/libtmux.client/' + }) + await assert.rejects(checkToctree(page, current), /labelled with an id/) +} + async function checkMetadata(page) { const html = await (await page.request.get(page.url())).text() await page.waitForFunction((html) => { @@ -106,6 +158,19 @@ try { console.log(`Native navigation: ${width}px ${colorScheme} ${reducedMotion}, document links, metadata, anchors, history, copy, theme, and boundary PASS`) } finally { await context.close() } } + for (const width of [1027, 390]) { + const context = await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: 'reduce' }) + try { + const page = await context.newPage() + const current = 'internals/api/libtmux._internal.query_list/' + await page.goto(`${root}${current}`) + await page.locator('html[data-page-readiness="ready"]').waitFor({ state: 'attached' }) + await checkToctree(page, current) + await checkToctreeSearch(page) + await checkToctreeNegative(page, current) + console.log(`Native toctree: ${width}px nested tree, open ancestors, external marks, labels, search, and negative cases PASS`) + } finally { await context.close() } + } for (const javaScriptEnabled of [false, true]) { const context = await browser.newContext({ javaScriptEnabled, viewport: { width: 1027, height: 1450 }, reducedMotion: 'reduce' }) try { diff --git a/site/scripts/check-native-shell.mjs b/site/scripts/check-native-shell.mjs index d3daeb410..a961d2f01 100644 --- a/site/scripts/check-native-shell.mjs +++ b/site/scripts/check-native-shell.mjs @@ -4,7 +4,7 @@ import { chromium } from 'playwright' import { checkNativeFirstPaint, checkNativeHeader } from './check-native-layout.mjs' const base = (process.argv.find((arg) => arg.startsWith('http')) ?? 'http://localhost:8080/en').replace(/\/$/, '') -const version = process.argv.find((arg) => arg.startsWith('--version='))?.slice('--version='.length) ?? 'stable' +const version = process.argv.find((arg) => arg.startsWith('--version='))?.slice('--version='.length) ?? 'latest' const browser = await chromium.launch({ channel: process.env.LIBTMUX_DOCS_BROWSER_CHANNEL }) try { for (const javaScriptEnabled of [true, false]) { @@ -30,6 +30,17 @@ try { page.on('response', (response) => { if (response.ok()) loaded.add(response.url()) }) + // The column is the Sphinx global toctree, still present without a script. + const nested = () => page.evaluate(() => { + const tree = document.querySelector('.api-nav__tree') + return { groups: tree.querySelectorAll('[role="group"] [role="treeitem"], [role="group"] a[href]').length, labelled: tree.querySelectorAll('.api-nav__label').length, + ids: [...tree.querySelectorAll('.api-nav__label')].filter((label) => /^page:/.test(label.textContent.trim())).length } + }) + await page.goto(`${base}/py/${version}/api/api/libtmux.session/`, { waitUntil: 'load' }) + const toctree = await nested() + assert(toctree.groups > 10 && toctree.ids === 0, `Native sidebar is not the nested toctree: ${JSON.stringify(toctree)}`) + await page.evaluate(() => document.querySelectorAll('.api-nav__tree [role="group"]').forEach((group) => group.remove())) + assert.equal((await nested()).groups, 0, 'The nesting probe cannot tell a flat list from a nested tree') for (const width of [1440, 1062, 1027, 768, 688, 641, 390]) { for (const colorScheme of ['light', 'dark']) { await page.setViewportSize({ width, height: 900 }) diff --git a/site/scripts/check-navigation.mjs b/site/scripts/check-navigation.mjs index 0abf5d31c..c64f62314 100644 --- a/site/scripts/check-navigation.mjs +++ b/site/scripts/check-navigation.mjs @@ -4,6 +4,9 @@ import registry from '../src/data/registry.json' with { type: 'json' } import mcpCatalogs from '../src/data/mcp-tools.json' with { type: 'json' } import { checkPickerFilters } from './check-picker-filters.mjs' +/** The version the dev build mounts a port's prose pages at: its default, as check-dev sets it. */ +const defaultVersion = (port) => JSON.parse(process.env.LIBTMUX_DOCS_PORT_DEFAULTS || '{}')[port] ?? 'latest' + /** Optional scripts injected at the end of the body cannot gate navigation. */ export async function checkNavigationBeforeAnalytics(browser, base) { const page = await browser.newPage({ viewport: { width: 390, height: 900 }, reducedMotion: 'reduce' }) @@ -1045,7 +1048,7 @@ export async function checkNavigation(page, base) { 'Back preserves the saved language preference') console.log('Navigation: native documents, Back, search, code tabs, menu and saved theme/cooldown pass') - for (const [port, version] of [['ts', 'latest'], ['py', 'stable']]) { + for (const [port, version] of [['ts', 'latest'], ['py', defaultVersion('py')]]) { const prefix = new URL(`${base}/${port}/${version}/`).pathname for (const width of [1440, 390]) { await page.setViewportSize({ width, height: 900 }) diff --git a/site/scripts/check-page-readiness.mjs b/site/scripts/check-page-readiness.mjs index a86d84b4c..3e135b922 100644 --- a/site/scripts/check-page-readiness.mjs +++ b/site/scripts/check-page-readiness.mjs @@ -205,7 +205,7 @@ export async function checkRequiredAppearance(browser, base) { // Exercise insertion even when a new preview's actual manifest has // only one published version for the selected port. const entries = [ - { slug: 'stable', label: 'stable', supported: true }, + { slug: 'v0.46.2', label: 'v0.46.2', supported: true }, { slug: 'latest', label: 'latest', supported: true }, ] await route.fulfill({ json: { schema: 1, ports: { py: entries, ts: entries } } }) @@ -292,7 +292,7 @@ const BADGE_GAP = { min: .21, max: .29 } * and centres one on the whole row when a long name wraps, so only the * decorations are measured here; the badge-centring check owns the geometry. */ -const SIDEBAR_PAGE = '/py/stable/workspace/reference/tmuxp-workspace-builder-classicworkspacebuilder-build/' +const SIDEBAR_PAGE = '/py/v0.46.2/workspace/reference/tmuxp-workspace-builder-classicworkspacebuilder-build/' const SIDEBAR_BADGE_LINKS = [ { label: 'sidebar member link', path: SIDEBAR_PAGE, badges: 'a.api-nav__leaf > .api-nav__kind', gap: false, centre: false }, { label: 'sidebar type row', path: SIDEBAR_PAGE, badges: 'div.api-nav__row > .api-nav__kind', gap: false, centre: false }, @@ -303,13 +303,18 @@ const SIDEBAR_BADGE_LINKS = [ * marks single-line prose links, which must not grow their line; `sample` * keeps an entry in the bounded sample. */ +/** An equivalent in another port, in the In other ports table of a symbol's page. */ +const EQUIVALENT_BADGE_LINK = { + label: 'API equivalent', path: '/py/v0.46.2/workspace/reference/tmuxp-workspace-builder-classicworkspacebuilder-build/', + badges: 'section:has(> #api-other-ports) .tmux-usage a > .api-nav__kind', gap: false, sample: true, +} const BADGE_LINKS = [ { label: 'prose link', path: '/rs/latest/concepts/server-session-window-pane/', badges: 'p a > .api-link-kind', line: true, fixtures: true, sample: true }, - { label: 'guide prose link', path: '/py/stable/guides/attaching-to-tmux/', badges: 'p a > .api-link-kind', line: true, sample: true }, - { label: 'MCP prose link', path: '/py/stable/mcp/tools/capture_pane/', badges: 'p a > .api-link-kind', line: true }, - { label: 'MCP index card', path: '/py/stable/mcp/tools/', badges: '.api-index-card a > .api-nav__kind', gap: false, centre: false, sample: true }, - { label: 'MCP catalog heading', path: '/py/stable/mcp/tools/', badges: 'h2 a > .api-nav__kind', gap: false, centre: false }, - { label: 'API equivalent', path: '/py/stable/workspace/reference/tmuxp-workspace-builder-classicworkspacebuilder-build/', badges: '.api-elsewhere-value a > .api-nav__kind', gap: false, sample: true }, + { label: 'guide prose link', path: '/py/v0.46.2/guides/attaching-to-tmux/', badges: 'p a > .api-link-kind', line: true, sample: true }, + { label: 'MCP prose link', path: '/py/v0.46.2/mcp/tools/capture_pane/', badges: 'p a > .api-link-kind', line: true }, + { label: 'MCP index card', path: '/py/v0.46.2/mcp/tools/', badges: '.api-index-card a > .api-nav__kind', gap: false, centre: false, sample: true }, + { label: 'MCP catalog heading', path: '/py/v0.46.2/mcp/tools/', badges: 'h2 a > .api-nav__kind', gap: false, centre: false }, + EQUIVALENT_BADGE_LINK, ...SIDEBAR_BADGE_LINKS, // The MCP tree draws no marks under a group of one kind, so its leaf marks are measured on an API tree. { label: 'navigation tree link', path: '/java/latest/reference/io-github-libtmux-server-server/', badges: 'a.api-nav__leaf > .api-nav__kind', gap: false }, @@ -487,11 +492,11 @@ export async function checkKindBadgeLinks(browser, base, { sample = false, entri * of it alone and has to report the missing badge by its own name. */ export async function checkKindBadgeLinksFail(browser, base) { - for (const entry of SIDEBAR_BADGE_LINKS) { - await assert.rejects(checkKindBadgeLinks(browser, base, { entries: [{ ...entry, path: '/py/stable/workspace/guides/' }] }), + for (const entry of [...SIDEBAR_BADGE_LINKS, EQUIVALENT_BADGE_LINK]) { + await assert.rejects(checkKindBadgeLinks(browser, base, { entries: [{ ...entry, path: '/py/v0.46.2/workspace/guides/' }] }), new RegExp(`no ${entry.label} badge to measure`)) } - console.log(`Kind badges: a sidebar without badged rows fails each of its ${SIDEBAR_BADGE_LINKS.length} selectors PASS`) + console.log(`Kind badges: a sidebar without badged rows fails each of its ${SIDEBAR_BADGE_LINKS.length + 1} selectors PASS`) } /** Overview pages with cards, then a prose page whose inline preview links must keep their line. */ @@ -580,7 +585,7 @@ function coreReference(pathname, { root, ports, segment }) { * * The build under test serves one version of each port's core reference: `version`, the one its own target names. A link * to another version of a port's reference leaves for a tree this build does not contain, such as the Python reference that - * the other ports' pages link to at its default, `stable`. That tree exists in the assembly, where the port's own shell build + * the other ports' pages link to at its default version. That tree exists in the assembly, where the port's own shell build * renders it at `///reference/` with its payloads; `reference-previews.test.ts` checks them there. * Everything else is served at whatever version a link names: tmux's pages, a product's pages, the glossary. * @@ -626,6 +631,42 @@ export async function payloadGaps(request, origin, hrefs, served) { * so hover it and read the card, then ask the same of every marked link on the pages whose destination the build * serves (`served`, from `servedByBuild`; without it every destination is asked), and of one that has no payload. */ +/** The method page's C function link, with the marker that opts it into the card. */ +async function functionLinkMarked(page) { + const link = page.locator(TMUX_FUNCTION_LINK).first() + assert.equal(await link.count(), 1, 'The method page has no C function link marked for a preview') + assert.equal(await link.textContent(), 'cmd_list_panes_server') + return link +} + +/** + * The link check must fail when the page loses the marker, the link or the section: it reads the same page after each is + * taken away, and a page that never had the section. + */ +export async function checkTmuxReferencePreviewsFail(browser, base) { + const context = await browser.newContext({ reducedMotion: 'reduce', viewport: { width: 1440, height: 1000 } }) + const page = await context.newPage() + page.setDefaultTimeout(process.env.CI ? 20000 : 10000) + try { + await page.goto(`${base}${TMUX_METHOD_PAGE}`, { waitUntil: 'load' }) + await page.waitForFunction(() => document.documentElement.dataset.pageReadiness === 'ready') + await functionLinkMarked(page) + await page.evaluate(() => { for (const link of document.querySelectorAll('.tmux-send a')) delete link.dataset.linkPreview }) + await assert.rejects(functionLinkMarked(page), /no C function link marked for a preview/) + await page.evaluate(() => document.querySelector('#api-tmux-command')?.closest('section')?.remove()) + await assert.rejects(functionLinkMarked(page), /no C function link marked for a preview/) + await page.goto(`${base}/py/v0.46.2/workspace/guides/`, { waitUntil: 'load' }) + await assert.rejects(functionLinkMarked(page), /no C function link marked for a preview/) + console.log('Reference previews: a page without the marked C function link fails the check PASS') + } finally { + await context.close() + } +} + +/** The C function a method's tmux command line names, in the tmux command section of its page. */ +const TMUX_FUNCTION_LINK = 'section.api-tmux-section:has(> #api-tmux-command) .tmux-send a[data-link-preview]' +const TMUX_METHOD_PAGE = '/cxx/latest/reference/libtmux-server-panes/' + export async function checkTmuxReferencePreviews(browser, base, { served: build } = {}) { const context = await browser.newContext({ reducedMotion: 'reduce', viewport: { width: 1440, height: 1000 } }) const page = await context.newPage() @@ -634,11 +675,9 @@ export async function checkTmuxReferencePreviews(browser, base, { served: build const origin = new URL(base).origin const served = build ? (href) => servedByBuild(href, build) : undefined try { - await page.goto(`${base}/cxx/latest/reference/libtmux-server-panes/`, { waitUntil: 'load' }) + await page.goto(`${base}${TMUX_METHOD_PAGE}`, { waitUntil: 'load' }) await page.waitForFunction(() => document.documentElement.dataset.pageReadiness === 'ready') - const link = page.locator('p.gp-sphinx-api-mentions .tmux-send a[data-link-preview]').first() - assert.equal(await link.count(), 1, 'The method page has no C function link marked for a preview') - assert.equal(await link.textContent(), 'cmd_list_panes_server') + const link = await functionLinkMarked(page) await link.hover() // The first request for a declaration's card compiles its route in the dev server. await page.waitForFunction(() => document.getElementById('reference-link-preview')?.matches(':popover-open'), null, { timeout: 60000 }) @@ -671,7 +710,7 @@ export async function checkTmuxReferencePreviews(browser, base, { served: build // left out and not reported, so the sweep cannot go green by skipping what it should have asked. if (served) { const kept = `${build.root}/${build.ports[0].slug}/${build.version}/${build.segment}/no-such-declaration/` - const elsewhere = build.version === 'stable' ? 'latest' : 'stable' + const elsewhere = build.version === 'latest' ? 'v0.46.2' : 'latest' const away = `${build.root}/${build.ports.find((port) => port.versionedDocs).slug}/${elsewhere}/${build.segment}/no-such-declaration/` const control = await payloadGaps(page.request, origin, [kept, away], served) assert.deepEqual(control.missing, [`${kept} answers 404`], 'A payload missing on a served port was not reported') diff --git a/site/scripts/check-sidebar-demo.mjs b/site/scripts/check-sidebar-demo.mjs index 2136dd56a..cc99be605 100644 --- a/site/scripts/check-sidebar-demo.mjs +++ b/site/scripts/check-sidebar-demo.mjs @@ -35,6 +35,41 @@ export async function checkSidebarDemo(browser, url, options = {}) { if (await f.locator('.api-nav').evaluate((nav) => nav.inert)) await f.locator('[data-api-nav-toggle]').click() } const waitSelection = (f, symbol) => f.waitForFunction((id) => document.querySelector('.api-nav')?.dataset.symbol === id && document.querySelector('h1[data-preview-title]')?.textContent === id, symbol) + // Guide lines, heading weight and the glossary row, measured on the rendered tree. Each negative control breaks one of them on purpose. + const checkTreeDecoration = async (f, variant, where, collapsed = false) => { + const control = values['negative-control'] + const tree = f.locator('.api-nav__tree') + if (control === 'guide') await f.addStyleTag({ content: '.api-nav__label::before { border-inline-start: 0 solid !important; }' }) + if (control === 'weight') await f.addStyleTag({ content: '.api-nav__item > .api-nav__row > .api-nav__label { font-weight: 400 !important; }' }) + if (control === 'glossary-first') await tree.evaluate((node) => { const last = node.querySelector(':scope > li:last-child'); if (last?.querySelector('a[href$="/glossary/"]')) node.prepend(last) }) + if (control === 'glossary-twice') await tree.evaluate((node) => { const last = node.querySelector(':scope > li:last-child'); if (last?.querySelector('a[href$="/glossary/"]')) node.append(last.cloneNode(true)) }) + if (control === 'guide-top') await f.addStyleTag({ content: '[aria-level="1"] > .api-nav__row > .api-nav__label::before, a[aria-level="1"] > .api-nav__label::before { content: "" !important; position: absolute; top: 0; bottom: 0; border-inline-start: 1px solid red !important; }' }) + const rows = await tree.evaluate((node) => [...node.querySelectorAll('[role="treeitem"]')].filter((row) => row.getClientRects().length).map((row) => { + const label = row.matches('a') ? row.querySelector('.api-nav__label') : row.querySelector(':scope > .api-nav__row > .api-nav__label') + const level = Number(row.getAttribute('aria-level')) + return { text: label?.textContent.trim(), href: row.getAttribute('href'), leaf: row.classList.contains('api-nav__leaf'), level, + subgroup: row.matches("[data-lazy^='group:']"), line: label ? getComputedStyle(label, '::before').borderInlineStartWidth : '0px', + weight: Number(label ? getComputedStyle(label).fontWeight : 0), heading: row.matches('.api-nav__item') && level === 1 } + })) + // Every nested row carries the guide line, kind subgroups included, in each layout that nests. + const nested = rows.filter((row) => row.level > 1) + if (variant !== 'focus' && !collapsed) assert(nested.length > 0, `${where}: the layout shows nested rows`) + if (variant === 'grouped' && !collapsed) assert(nested.some((row) => /^Methods?\b/.test(row.text) && row.subgroup), `${where}: the Grouped kind subgroup is a nested row`) + for (const row of nested) assert.equal(row.line, '1px', `${where}: nested row ${row.text} shows its guide line`) + // Clean control: a top-level row and the glossary never draw one. + for (const row of rows.filter((row) => row.level === 1)) assert.equal(row.line, '0px', `${where}: top-level row ${row.text} has no guide line`) + // Bucket headings read as headings in the layouts that group. + if (variant !== 'focus') { + const headings = rows.filter((row) => row.heading) + assert(headings.length > 0, `${where}: bucket headings are present`) + for (const row of headings) assert(row.weight >= 600, `${where}: heading ${row.text} is bold`) + } + // The glossary is one ordinary row and the tree's last, reached after every declaration. + const glossary = rows.filter((row) => /\/glossary\/$/.test(row.href ?? '')) + assert.equal(glossary.length, 1, `${where}: the glossary appears exactly once`) + assert.equal(rows.at(-1), glossary[0], `${where}: no row after the glossary, and none before it links to it`) + assert.deepEqual({ text: glossary[0].text, leaf: glossary[0].leaf, level: glossary[0].level }, { text: 'API glossary', leaf: true, level: 1 }, `${where}: the glossary is an ordinary row`) + } const screenshot = async (name) => { if (!values.screenshots) return await mkdir(values.screenshots, { recursive: true }) @@ -184,6 +219,7 @@ export async function checkSidebarDemo(browser, url, options = {}) { const ownerCount = f.locator('.api-nav__tree .api-nav__row:has(> .api-nav__kind)').filter({ has: f.locator('.api-nav__label').filter({ hasText: /^Server$/ }) }).first().locator('.api-nav__count') if (values['negative-control'] === 'count') await ownerCount.evaluate((node) => { node.textContent = '0' }) assert.equal(await ownerCount.textContent(), String(serverCount)) + await checkTreeDecoration(f, variant, `${variant}/${viewport}/${theme}`) const geometry = await f.locator('.api-nav').evaluate((nav) => ({ width: nav.clientWidth, overflow: nav.scrollWidth > nav.clientWidth, role: nav.getAttribute('role') })) assert.equal(geometry.overflow, false, `${variant}/${viewport}/${theme}: no sidebar overflow`) if (viewport === 'desktop') assert.equal(geometry.role, null) @@ -205,6 +241,25 @@ export async function checkSidebarDemo(browser, url, options = {}) { } console.log('PASS: 18 mode / viewport / theme combinations') + // The same row rules hold with every bucket folded, and again with the first one opened. + await select('viewport', 'desktop') + for (const variant of ['outline', 'grouped']) { + await select('variant', variant) + await f.waitForFunction((mode) => document.querySelector('.api-nav')?.dataset.presentation === mode, variant) + await action(f, 'collapse') + await checkTreeDecoration(f, variant, `${variant}/collapsed`, true) + const first = f.locator('.api-nav__tree > .api-nav__item > .api-nav__row').first() + await first.click() + await f.waitForFunction(() => document.querySelector('.api-nav__tree > .api-nav__item[aria-expanded="true"] > [role="group"] [role="treeitem"]')) + await checkTreeDecoration(f, variant, `${variant}/bucket opened`) + } + console.log('PASS: glossary last, guide lines and heading weight with folded and opened buckets') + // The tree is hidden while searching, so the glossary is the last result. + await f.locator('#api-symbol-search').fill('Window') + await f.locator('[data-api-search-results] a[data-api-glossary]').waitFor() + assert.equal(await f.locator('[data-api-search-results] li:last-child > a').getAttribute('data-api-glossary'), '', 'Search results end with the glossary') + await f.locator('#api-symbol-search').fill('') + await select('viewport', 'desktop') await select('variant', 'outline') await action(f, 'collapse') @@ -243,7 +298,7 @@ export async function checkSidebarDemo(browser, url, options = {}) { await select('symbol', empty.id) await waitSelection(f, empty.id) assert.equal(await tree.locator('.api-nav__count').textContent(), '0') - assert.equal(await tree.locator('[role="treeitem"]').count(), 1) + assert.equal(await tree.locator('[role="treeitem"]:not([href$="/glossary/"])').count(), 1) await select('symbol', long.id) await waitSelection(f, long.id) assert.equal(await current(f).evaluate((node) => node.scrollWidth <= node.clientWidth), true, 'Long symbol wraps') diff --git a/site/scripts/check-status-badges.mjs b/site/scripts/check-status-badges.mjs index bef31c115..659a0c151 100644 --- a/site/scripts/check-status-badges.mjs +++ b/site/scripts/check-status-badges.mjs @@ -1,5 +1,5 @@ import assert from 'node:assert/strict' -import { CONCEPT_DESCRIPTION, PICKER_GROUP_SUMMARY, PORT_BY_SLUG, PRODUCT_STATUS_GUIDE, PRODUCT_STATUS_LINE, PRODUCT_STATUS_LINK, productAvailable, productStatus } from '../src/lib/ports.ts' +import { CONCEPT_DESCRIPTION, PICKER_GROUP_SUMMARY, PORT_BY_SLUG, PRODUCT_STATUS_GUIDE, PRODUCT_STATUS_LINK, productStatusLine, productAvailable, productStatus } from '../src/lib/ports.ts' import registry from '../src/data/registry.json' with { type: 'json' } import { HOVER_OPEN } from '../src/lib/status-toggletip.ts' @@ -128,7 +128,7 @@ async function checkRows(page, picker, slug, where, kind) { assert(Math.abs(gap - listGap) <= 1, `${where}: the trigger's badge sits ${gap.toFixed(1)}px from its name, the list's ${listGap.toFixed(1)}px`) } const description = await picker.locator(':scope > summary').getAttribute('aria-description') - assert.equal(description, PRODUCT_STATUS_LINE[rows[0].status], `${where}: the trigger is described by the short line`) + assert.equal(description, productStatusLine(rows[0].status), `${where}: the trigger is described by the short line`) } } @@ -142,7 +142,7 @@ async function checkToggletip(page, picker, badge, status, label, where) { assert.equal((await card.locator('.status-toggletip__title').innerText()).trim(), status, `${where}: the card is titled with the stage`) const line = (await card.locator('.status-toggletip__line').innerText()).trim() assert(line.length <= TOGGLETIP_BUDGET, `${where}: the card's line is ${line.length} characters, over the ${TOGGLETIP_BUDGET} budget: "${line}"`) - assert.equal(line, PRODUCT_STATUS_LINE[status], `${where}: the card holds the ${status} line`) + assert.equal(line, productStatusLine(status), `${where}: the card holds the ${status} line`) assert.equal(await card.getAttribute('role'), 'group', `${where}: the card is a named group`) assert.equal(await card.getAttribute('aria-label'), `${status}: ${label}`, `${where}: the card names its product`) const box = await card.boundingBox() @@ -296,7 +296,7 @@ export async function checkStatusBadgesFail(browser, base) { }, /has exactly one status badge/], ['a wrong stage', picker, { script: () => document.querySelector('.status-toggletip > .status-badge').setAttribute('data-status', 'concept'), - }, /Core Library states alpha/], + }, /Core Library states (?!concept\b)\S+/], ['a badge far from its name', picker, { css: '.surface-entry > .surface-entry__badge { left: auto !important; right: 2.1rem !important; top: 1.15rem !important; translate: none !important }', }, /badge sits beside its name/], diff --git a/site/scripts/check-style-parity.mjs b/site/scripts/check-style-parity.mjs index 343363db3..ead796b35 100755 --- a/site/scripts/check-style-parity.mjs +++ b/site/scripts/check-style-parity.mjs @@ -3,7 +3,7 @@ * The reference looks like gp-sphinx's, asserted rather than eyeballed. * * Both pages describe `libtmux.Server`, from the same tree: gp-sphinx renders - * it at `/py/stable/api/api/libtmux.server/` and this site at + * it at `/py/latest/api/api/libtmux.server/` and this site at * `/reference/py/libtmux-server/`. That coincidence is the only oracle * available — the other seven ports have no gp-sphinx twin — so it is worth * using precisely. @@ -20,7 +20,7 @@ import { chromium } from 'playwright' const base = process.argv[2] ?? 'http://localhost:8080' -const SPHINX = `${base}/py/stable/api/api/libtmux.server/` +const SPHINX = `${base}/py/latest/api/api/libtmux.server/` /* * A member's page, not the type's. * @@ -31,7 +31,7 @@ const SPHINX = `${base}/py/stable/api/api/libtmux.server/` * shows them did, and pointing at the old one reported all seven treatments * as "not found on this site" rather than as different. */ -const OURS = `${base}/py/stable/reference/libtmux-server-new_session/` +const OURS = `${base}/py/latest/reference/libtmux-server-new_session/` /* * A second page, because a page is now one symbol. @@ -41,7 +41,7 @@ const OURS = `${base}/py/stable/reference/libtmux-server-new_session/` * it — and now each symbol has its own, so no single URL carries both. A case * names the page it needs; the default is the method page. */ -const OURS_ATTRIBUTE = `${base}/py/stable/reference/libtmux-_internal-constants-hooks-after_capture_pane/` +const OURS_ATTRIBUTE = `${base}/py/latest/reference/libtmux-_internal-constants-hooks-after_capture_pane/` /** * Equivalent elements, and the properties that carry the look. diff --git a/site/scripts/check-visual.mjs b/site/scripts/check-visual.mjs index e70e5056f..10e9e16da 100755 --- a/site/scripts/check-visual.mjs +++ b/site/scripts/check-visual.mjs @@ -33,7 +33,7 @@ const base = process.argv.find((a) => a.startsWith('http')) ?? 'http://localhost /** One page per rendering path, not one per port: the component is shared. */ const PAGES = [ - ['py-class', '/py/stable/reference/libtmux-server/'], + ['py-class', '/py/latest/reference/libtmux-server/'], // Rust carries the other prose path: fenced examples and `# Errors` // rubrics, which no Python docstring in this estate uses. ['rs-class', '/rs/latest/reference/server-server/'], diff --git a/site/src/components/PortHero.astro b/site/src/components/PortHero.astro index 473e919d5..1b95a6e5c 100644 --- a/site/src/components/PortHero.astro +++ b/site/src/components/PortHero.astro @@ -11,7 +11,7 @@ import { hasReference, PORT_BY_SLUG, portPageUrl, type Port } from '../lib/ports * name and package, and where its API reference actually lives. * * That last part is the reason this is its own component rather than inline - * markup: both `/go/` and `/go/stable/` render it, so the hand-off is stated + * markup: both `/go/` and `/go/latest/` render it, so the hand-off is stated * once. * * It used to carry the reference hand-off itself, and said that Rust, Go and diff --git a/site/src/components/PrereleaseNotice.astro b/site/src/components/PrereleaseNotice.astro index bf0832080..33f1d10d5 100644 --- a/site/src/components/PrereleaseNotice.astro +++ b/site/src/components/PrereleaseNotice.astro @@ -1,11 +1,14 @@ --- /** - * The bar that says this site describes an alpha. + * The bar that says the libraries are released but still change between releases. * * Sits directly under the header and scrolls away with the page rather than * pinning: the header is `sticky top-0`, and a second sticky strip would take * a permanent bite out of every viewport for a sentence a reader needs once. * + * The storage key names the release line. A reader who dismissed the alpha + * notice under the old key sees this one, because it says something else. + * * Dismissal is remembered, and the remembering has to survive first paint. * `ThemeScript` reads the key in and sets `data-prerelease` on the * root before any body markup is parsed, so a reader who has dismissed this @@ -28,17 +31,17 @@ const { centered = false } = Astro.props

- Prerelease + Early release - This site documents an alpha of libtmux. Its structure, - URLs and APIs are subject to change. + libtmux is released, and its APIs may still change between releases. + This site's structure and URLs may change too.

@@ -241,9 +245,6 @@ if (!mark(nodes)) {
} - {presentation && glossaryHref && {glossaryLabel}}