From 1135904f8e44c7ba05c267622be3b4c2c53ad86b Mon Sep 17 00:00:00 2001 From: viiccwen Date: Mon, 29 Jun 2026 05:55:38 +0000 Subject: [PATCH] feat: add local docs versioning validation --- website/README.md | 6 +++- website/package.json | 2 +- website/scripts/version-docs.js | 58 +++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 website/scripts/version-docs.js diff --git a/website/README.md b/website/README.md index 2955edbdd9..8a36da7617 100644 --- a/website/README.md +++ b/website/README.md @@ -175,16 +175,20 @@ served as `latest` at `/docs`; the editable current docs are served at `/docs/ne When releasing, snapshot the current docs: ```bash -npm run docusaurus docs:version +npm run version -- ``` This creates: - `versioned_docs/version-/` - Frozen snapshot - Updates `versions.json` +- Validates the generated versioned docs with a production Docusaurus build `docusaurus.config.ts` reads `versions.json` automatically, so release updates should not require editing the Docusaurus version configuration. +The command runs the documentation sync first, so generated Python API reference +pages are included in the version snapshot before the local build validation. + ## Blog Posts Blog posts live in `website/blog/`: diff --git a/website/package.json b/website/package.json index 386a659441..95ccdb28e8 100644 --- a/website/package.json +++ b/website/package.json @@ -17,7 +17,7 @@ "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", "typecheck": "tsc", - "version": "docusaurus docs:version" + "version": "node scripts/version-docs.js" }, "dependencies": { "@docusaurus/core": "3.10.1", diff --git a/website/scripts/version-docs.js b/website/scripts/version-docs.js new file mode 100644 index 0000000000..9f57688ea2 --- /dev/null +++ b/website/scripts/version-docs.js @@ -0,0 +1,58 @@ +#!/usr/bin/env node + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const { spawnSync } = require('child_process'); + +function usage() { + console.error('Usage: npm run version -- '); + console.error(''); + console.error('Example: npm run version -- 0.7'); +} + +function run(command, args) { + const result = spawnSync(command, args, { + cwd: process.cwd(), + stdio: 'inherit', + shell: process.platform === 'win32', + }); + + if (result.error) { + throw result.error; + } + + if (result.status !== 0) { + process.exit(result.status); + } +} + +function main() { + const version = process.argv[2]; + + if (!version || version.startsWith('-')) { + usage(); + process.exit(1); + } + + console.log(`Preparing versioned docs for ${version}...`); + run('npm', ['run', 'sync']); + run('npm', ['run', 'docusaurus', '--', 'docs:version', version]); + run('npm', ['run', 'build']); +} + +main();