Skip to content

Commit 428007d

Browse files
authored
Merge pull request #4401 from ralfhandl/main-respec-other-versions
2 parents 3e40ee4 + 70a5c94 commit 428007d

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

scripts/md2html/build.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ cp -p node_modules/respec/builds/respec-w3c.* $deploydir/js/
2424

2525
latest=$(git describe --abbrev=0 --tags)
2626

27+
allVersions=$(ls -1 versions/[23456789].*.md | grep -v -e "\-editors" | sort -r)
28+
2729
if [ -z "$1" ]; then
28-
specifications=$(ls -1 versions/[23456789].*.md | grep -v -e "\-editors" | sort -r)
30+
specifications=$allVersions
2931
elif [ "$1" = "latest" ]; then
3032
specifications=$(ls -1 versions/$latest.md)
3133
elif [ "$1" = "src" ]; then
@@ -53,7 +55,7 @@ for specification in $specifications; do
5355

5456
echo === Building $version to $destination
5557

56-
node scripts/md2html/md2html.js --maintainers $maintainers $specification > $tempfile
58+
node scripts/md2html/md2html.js --maintainers $maintainers $specification "$allVersions" > $tempfile
5759
npx respec --no-sandbox --use-local --src $tempfile --out $destination
5860
rm $tempfile
5961

scripts/md2html/md2html.js

+9
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const md = require('markdown-it')({
7777
});
7878

7979
function preface(title,options) {
80+
const otherVersions = options._[1].split("\n").map(v => path.basename(v,'.md')).filter(v => v !== options.subtitle);
8081
const respec = {
8182
specStatus: "base",
8283
latestVersion: "https://spec.openapis.org/oas/latest.html",
@@ -96,6 +97,14 @@ function preface(title,options) {
9697
height: 48,
9798
url: "https://openapis.org/"}],
9899
otherLinks: [
100+
{
101+
key: "Other versions:",
102+
data: otherVersions.map(v => {
103+
return {
104+
href: `https://spec.openapis.org/oas/v${v}.html`
105+
}
106+
})
107+
},
99108
{
100109
key: "Participate",
101110
data: [

tests/md2html/fixtures/basic-new.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>OpenAPI Specification v30.0.1 | Introduction, Definitions, &amp; More</title><meta name="description" content="The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs."><meta name="color-scheme" content="light dark"><script src="../js/respec-w3c.js" class="remove"></script><script class="remove">var respecConfig = {"specStatus":"base","latestVersion":"https://spec.openapis.org/oas/latest.html","thisVersion":"https://spec.openapis.org/oas/v30.0.1.html","canonicalURI":"https://spec.openapis.org/oas/v30.0.1.html","editors":[{"name":"John Doe "},{"name":"Jane Doe "}],"formerEditors":[{"name":"Foo Bar "}],"publishDate":"3001-04-01T00:00:00.000Z","subtitle":"Version 30.0.1","edDraftURI":"https://github.com/OAI/OpenAPI-Specification/","shortName":"OAS","historyURI":null,"lint":false,"logos":[{"src":"https://raw.githubusercontent.com/OAI/OpenAPI-Style-Guide/master/graphics/bitmap/OpenAPI_Logo_Pantone.png","alt":"OpenAPI Initiative","height":48,"url":"https://openapis.org/"}],"otherLinks":[{"key":"Participate","data":[{"value":"GitHub OAI/OpenAPI-Specification","href":"https://github.com/OAI/OpenAPI-Specification/"},{"value":"File a bug","href":"https://github.com/OAI/OpenAPI-Specification/issues"},{"value":"Commit history","href":"https://github.com/OAI/OpenAPI-Specification/commits/main/versions/30.0.1.md"},{"value":"Pull requests","href":"https://github.com/OAI/OpenAPI-Specification/pulls"}]}]};</script><!-- Global site tag (gtag.js) - Google Analytics -->
1+
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>OpenAPI Specification v30.0.1 | Introduction, Definitions, &amp; More</title><meta name="description" content="The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs."><meta name="color-scheme" content="light dark"><script src="../js/respec-w3c.js" class="remove"></script><script class="remove">var respecConfig = {"specStatus":"base","latestVersion":"https://spec.openapis.org/oas/latest.html","thisVersion":"https://spec.openapis.org/oas/v30.0.1.html","canonicalURI":"https://spec.openapis.org/oas/v30.0.1.html","editors":[{"name":"John Doe "},{"name":"Jane Doe "}],"formerEditors":[{"name":"Foo Bar "}],"publishDate":"3001-04-01T00:00:00.000Z","subtitle":"Version 30.0.1","edDraftURI":"https://github.com/OAI/OpenAPI-Specification/","shortName":"OAS","historyURI":null,"lint":false,"logos":[{"src":"https://raw.githubusercontent.com/OAI/OpenAPI-Style-Guide/master/graphics/bitmap/OpenAPI_Logo_Pantone.png","alt":"OpenAPI Initiative","height":48,"url":"https://openapis.org/"}],"otherLinks":[{"key":"Other versions:","data":[{"href":"https://spec.openapis.org/oas/v31.0.0.html"},{"href":"https://spec.openapis.org/oas/v30.0.0.html"}]},{"key":"Participate","data":[{"value":"GitHub OAI/OpenAPI-Specification","href":"https://github.com/OAI/OpenAPI-Specification/"},{"value":"File a bug","href":"https://github.com/OAI/OpenAPI-Specification/issues"},{"value":"Commit history","href":"https://github.com/OAI/OpenAPI-Specification/commits/main/versions/30.0.1.md"},{"value":"Pull requests","href":"https://github.com/OAI/OpenAPI-Specification/pulls"}]}]};</script><!-- Global site tag (gtag.js) - Google Analytics -->
22
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-831873-42"></script>
33
<script>
44
window.dataLayer = window.dataLayer || [];

tests/md2html/fixtures/basic-old.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>OpenAPI Specification v30.0.1 | Introduction, Definitions, &amp; More</title><meta name="description" content="The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs."><meta name="color-scheme" content="light dark"><script src="../js/respec-w3c.js" class="remove"></script><script class="remove">var respecConfig = {"specStatus":"base","latestVersion":"https://spec.openapis.org/oas/latest.html","thisVersion":"https://spec.openapis.org/oas/v30.0.1.html","canonicalURI":"https://spec.openapis.org/oas/v30.0.1.html","editors":[{"name":"Foo Bar "}],"formerEditors":[],"publishDate":"3001-04-01T00:00:00.000Z","subtitle":"Version 30.0.1","edDraftURI":"https://github.com/OAI/OpenAPI-Specification/","shortName":"OAS","historyURI":null,"lint":false,"logos":[{"src":"https://raw.githubusercontent.com/OAI/OpenAPI-Style-Guide/master/graphics/bitmap/OpenAPI_Logo_Pantone.png","alt":"OpenAPI Initiative","height":48,"url":"https://openapis.org/"}],"otherLinks":[{"key":"Participate","data":[{"value":"GitHub OAI/OpenAPI-Specification","href":"https://github.com/OAI/OpenAPI-Specification/"},{"value":"File a bug","href":"https://github.com/OAI/OpenAPI-Specification/issues"},{"value":"Commit history","href":"https://github.com/OAI/OpenAPI-Specification/commits/main/versions/30.0.1.md"},{"value":"Pull requests","href":"https://github.com/OAI/OpenAPI-Specification/pulls"}]}]};</script><!-- Global site tag (gtag.js) - Google Analytics -->
1+
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>OpenAPI Specification v30.0.1 | Introduction, Definitions, &amp; More</title><meta name="description" content="The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs."><meta name="color-scheme" content="light dark"><script src="../js/respec-w3c.js" class="remove"></script><script class="remove">var respecConfig = {"specStatus":"base","latestVersion":"https://spec.openapis.org/oas/latest.html","thisVersion":"https://spec.openapis.org/oas/v30.0.1.html","canonicalURI":"https://spec.openapis.org/oas/v30.0.1.html","editors":[{"name":"Foo Bar "}],"formerEditors":[],"publishDate":"3001-04-01T00:00:00.000Z","subtitle":"Version 30.0.1","edDraftURI":"https://github.com/OAI/OpenAPI-Specification/","shortName":"OAS","historyURI":null,"lint":false,"logos":[{"src":"https://raw.githubusercontent.com/OAI/OpenAPI-Style-Guide/master/graphics/bitmap/OpenAPI_Logo_Pantone.png","alt":"OpenAPI Initiative","height":48,"url":"https://openapis.org/"}],"otherLinks":[{"key":"Other versions:","data":[{"href":"https://spec.openapis.org/oas/v31.0.0.html"},{"href":"https://spec.openapis.org/oas/v30.0.0.html"}]},{"key":"Participate","data":[{"value":"GitHub OAI/OpenAPI-Specification","href":"https://github.com/OAI/OpenAPI-Specification/"},{"value":"File a bug","href":"https://github.com/OAI/OpenAPI-Specification/issues"},{"value":"Commit history","href":"https://github.com/OAI/OpenAPI-Specification/commits/main/versions/30.0.1.md"},{"value":"Pull requests","href":"https://github.com/OAI/OpenAPI-Specification/pulls"}]}]};</script><!-- Global site tag (gtag.js) - Google Analytics -->
22
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-831873-42"></script>
33
<script>
44
window.dataLayer = window.dataLayer || [];

tests/md2html/md2html.test.mjs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { readdirSync, readFileSync } from "node:fs";
2-
import { exec } from "node:child_process";
2+
import { execFile } from "node:child_process";
33
import { resolve } from "node:path";
44
import { describe, test, expect } from "vitest";
55
import assert from "node:assert";
@@ -13,12 +13,13 @@ describe("md2html", async () => {
1313
const expected = readFileSync(
1414
folder + entry.name.replace(".md", ".html"),
1515
"utf8",
16-
);
16+
);
1717
const output = await md2html(
1818
[
1919
"--maintainers",
2020
entry.name.replace(".md", ".maintainers"),
2121
entry.name,
22+
"path/31.0.0.md\npath/30.0.1.md\npath/30.0.0.md",
2223
],
2324
folder,
2425
);
@@ -29,8 +30,9 @@ describe("md2html", async () => {
2930

3031
function md2html(args, cwd) {
3132
return new Promise((res) => {
32-
exec(
33-
`node ${resolve("./scripts/md2html/md2html.js")} ${args.join(" ")}`,
33+
execFile(
34+
"node",
35+
[`${resolve("./scripts/md2html/md2html.js")}`, ...args],
3436
{ cwd },
3537
(error, stdout, stderr) => {
3638
res({

0 commit comments

Comments
 (0)