From 4907cf046c26c3ccb0fb67c9345e24ef95629a60 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 5 Dec 2026 11:56:06 -0600 Subject: [PATCH] fix(site[build]) Keep shared pages scoped in port builds why: Source-bound builds gave shared glossaries a port-specific Markdown link. Clearing the port also exposed routes and link limits reserved for full site builds. what: - Render shared locales without port-specific page settings. - Keep the selected revision in the shell cache key and build scope. - Cover C preview routing, link limits, and the glossary footer. --- scripts/build-site.sh | 7 ++++--- site/src/integrations/dangling-report.ts | 3 ++- site/src/lib/site-root.ts | 5 +++++ site/src/lib/tmux-manual-data.ts | 6 +++--- site/test/dangling-report.test.ts | 9 +++++++++ site/test/machine-readable.test.ts | 8 ++++++++ site/test/tmux-reference.test.ts | 13 +++++++++++++ 7 files changed, 44 insertions(+), 7 deletions(-) diff --git a/scripts/build-site.sh b/scripts/build-site.sh index 80bc31a84..c1db24b3a 100755 --- a/scripts/build-site.sh +++ b/scripts/build-site.sh @@ -448,11 +448,11 @@ build_shell() { fi # The origin sets canonical URLs and the sitemap; the root sets where links # resolve. Builds that differ only in these must not share an entry. - key="$(printf '%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s' \ + key="$(printf '%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s' \ "$base_fingerprint" "$base" "$version" "$kind" "$is_default" "$default_version" \ "${LIBTMUX_DOCS_PORT:-}" "${LIBTMUX_DOCS_PORT_DEFAULTS:-}" \ "${LIBTMUX_DOCS_LOCALE:-}" "${LIBTMUX_DOCS_PORT_ROOT:-}" "$native_context_digest" \ - "$site_origin" "${LIBTMUX_DOCS_ROOT:-/}" | sha256sum | cut -c1-40)" + "$site_origin" "${LIBTMUX_DOCS_ROOT:-/}" "${LIBTMUX_DOCS_SOURCE_SHA:-}" | sha256sum | cut -c1-40)" cached="$cache_dir/shell-$key" if [ "$no_cache" -eq 0 ] && [ -d "$cached" ]; then cp -a "$cached/." "$outdir/" @@ -1006,7 +1006,8 @@ log "building shell root (shared prose)" # page whose every link pointed into /en/. 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_PORT="" LIBTMUX_DOCS_NATIVE_CONTEXT="" \ + 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" "latest" "$assembly_out/$shell_locale" done diff --git a/site/src/integrations/dangling-report.ts b/site/src/integrations/dangling-report.ts index 1b8d47bf8..00826bf4d 100644 --- a/site/src/integrations/dangling-report.ts +++ b/site/src/integrations/dangling-report.ts @@ -3,6 +3,7 @@ import { join } from 'node:path' import { fileURLToPath } from 'node:url' import type { AstroIntegration } from 'astro' import { danglingReportPath } from '../lib/dangling-report-path' +import { buildsGeneralDocumentation } from '../lib/site-root' interface DanglingReference { port: string; text: string; why: string } @@ -69,7 +70,7 @@ export function danglingReport(maxDangling = 60): AstroIntegration { } }, 'astro:build:done': ({ logger }) => { - if (process.env.LIBTMUX_DOCS_PORT) return + if (!buildsGeneralDocumentation()) return const report = danglingReportPath() if (!report || !existsSync(report)) { throw new Error( diff --git a/site/src/lib/site-root.ts b/site/src/lib/site-root.ts index 05b4b692f..e04ac4c24 100644 --- a/site/src/lib/site-root.ts +++ b/site/src/lib/site-root.ts @@ -69,6 +69,11 @@ export const LOCALES_ROOT: string = (process.env.LIBTMUX_DOCS_LOCALES_ROOT || '' */ export const IS_ROOT_BUILD: boolean = !process.env.LIBTMUX_DOCS_PORT +/** A port build keeps its selected source revision while rendering shared pages. */ +export function buildsGeneralDocumentation(env: Record = process.env): boolean { + return !env.LIBTMUX_DOCS_PORT && !env.LIBTMUX_DOCS_SOURCE_SHA +} + /** * The root under which the port trees and the reference live. * diff --git a/site/src/lib/tmux-manual-data.ts b/site/src/lib/tmux-manual-data.ts index 7f004db95..f99f64790 100644 --- a/site/src/lib/tmux-manual-data.ts +++ b/site/src/lib/tmux-manual-data.ts @@ -7,7 +7,7 @@ import v32 from '../data/tmux/3.2a.json' import v37 from '../data/tmux/3.7c.json' import { API_MODELS, referenceHref } from './api-models' import { PORT_BY_SLUG } from './ports' -import { withPortRoot } from './site-root' +import { buildsGeneralDocumentation, withPortRoot } from './site-root' import { rowAnchor } from './row-anchors' import { linkTmuxManualTree } from './tmux-manual' import { tmuxUsage, tmuxUsageCommands } from './tmux-library-usage' @@ -24,9 +24,9 @@ export function tmuxManual(version: string): TmuxManual { return reference } -/** tmux belongs to the general documentation, outside each library's tree. */ +/** Only the general English site publishes tmux's manual and C reference. */ export function buildsTmuxDocumentation(env: Record = process.env): boolean { - return !env.LIBTMUX_DOCS_PORT && (!env.LIBTMUX_DOCS_LOCALE || env.LIBTMUX_DOCS_LOCALE === 'en') + return buildsGeneralDocumentation(env) && (!env.LIBTMUX_DOCS_LOCALE || env.LIBTMUX_DOCS_LOCALE === 'en') } /** The kinds of tmux name the manual documents; the tmux catalog shares these names. */ diff --git a/site/test/dangling-report.test.ts b/site/test/dangling-report.test.ts index d836456d1..166d162a7 100644 --- a/site/test/dangling-report.test.ts +++ b/site/test/dangling-report.test.ts @@ -217,6 +217,7 @@ describe('the build\'s ceiling', () => { beforeEach(() => { vi.stubEnv('LIBTMUX_DOCS_DANGLING_REPORT', report()) vi.stubEnv('LIBTMUX_DOCS_PORT', '') + vi.stubEnv('LIBTMUX_DOCS_SOURCE_SHA', undefined) }) it('fails a root build that has no report, where nothing ran to write one', () => { @@ -246,6 +247,14 @@ describe('the build\'s ceiling', () => { expect(() => done()).not.toThrow() }) + it('applies the general site link ceiling only to a full build', () => { + writeFileSync(report(), lines(325)) + vi.stubEnv('LIBTMUX_DOCS_SOURCE_SHA', 'a'.repeat(40)) + expect(() => done()).not.toThrow() + vi.stubEnv('LIBTMUX_DOCS_SOURCE_SHA', undefined) + expect(() => done()).toThrow(/325 unresolved mentions exceeds the ceiling of 60/) + }) + it('refuses to start a build that inherits VITEST without a report to write', () => { expect(process.env.VITEST).toBeTruthy() vi.stubEnv('LIBTMUX_DOCS_DANGLING_REPORT', '') diff --git a/site/test/machine-readable.test.ts b/site/test/machine-readable.test.ts index 8a869fcde..c8f37fe78 100644 --- a/site/test/machine-readable.test.ts +++ b/site/test/machine-readable.test.ts @@ -161,6 +161,14 @@ describe('machine-readable footer parsing', () => { }) describe.skipIf(!SITE_BUILT)('machine-readable footer', () => { + it('links each shared glossary to the shared Markdown', () => { + const shared = LOCALES.map((locale) => `${PREVIEW_PREFIX}/${locale}/reference/glossary.md`) + for (const locale of LOCALES.filter((locale) => existsSync(join(ASSEMBLY_ROOT, locale, 'docs.json')))) { + const html = readFileSync(join(ASSEMBLY_ROOT, locale, 'reference/glossary/index.html'), 'utf8') + expect(shared, locale).toContain(footerOf(html)?.markdown) + } + }) + it('links every page to its source and to Markdown, docs.json and llms files that exist', () => { const tracked = trackedFiles() const problems: string[] = [] diff --git a/site/test/tmux-reference.test.ts b/site/test/tmux-reference.test.ts index ff48b6a96..d7106c4dc 100644 --- a/site/test/tmux-reference.test.ts +++ b/site/test/tmux-reference.test.ts @@ -211,3 +211,16 @@ describe('the card a link to a C declaration opens', () => { expect(unanswered([real], generic)).toEqual([real]) }) }) + +it('keeps tmux source previews in general English documentation', () => { + vi.stubEnv('LIBTMUX_DOCS_PORT', '') + vi.stubEnv('LIBTMUX_DOCS_LOCALE', 'en') + try { + vi.stubEnv('LIBTMUX_DOCS_SOURCE_SHA', undefined) + expect(getStaticPaths().length).toBeGreaterThan(0) + vi.stubEnv('LIBTMUX_DOCS_SOURCE_SHA', 'a'.repeat(40)) + expect(getStaticPaths().length).toBe(0) + } finally { + vi.unstubAllEnvs() + } +})