Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions scripts/build-site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion site/src/integrations/dangling-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions site/src/lib/site-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string | undefined> = process.env): boolean {
return !env.LIBTMUX_DOCS_PORT && !env.LIBTMUX_DOCS_SOURCE_SHA
}

/**
* The root under which the port trees and the reference live.
*
Expand Down
6 changes: 3 additions & 3 deletions site/src/lib/tmux-manual-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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<string, string | undefined> = 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. */
Expand Down
9 changes: 9 additions & 0 deletions site/test/dangling-report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', '')
Expand Down
8 changes: 8 additions & 0 deletions site/test/machine-readable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = []
Expand Down
13 changes: 13 additions & 0 deletions site/test/tmux-reference.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
})
Loading