Skip to content

Commit f4168f6

Browse files
committed
Align spec build scripts with OpenAPI repo
- separate editors file per published spec version - deploy-preview for spec versions under development - update EDITORS.md
1 parent cf78517 commit f4168f6

File tree

6 files changed

+91
-37
lines changed

6 files changed

+91
-37
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ target
66
atlassian-ide-plugin.xml
77
node_modules/
88
deploy/
9+
deploy-preview/
910
coverage/
1011
history
1112
Gemfile.lock

EDITORS.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
## Active
44

5+
* Lorna Mitchell [@lornajane](https://github.com/lornajane)
6+
* Mike Kistler [@mikekistler](https://github.com/mikekistler)
7+
* Vincent Biret [@baywet](https://github.com/baywet)
8+
9+
## Emeritus
10+
511
* Darrel Miller [@darrelmiller](https://github.com/darrelmiller)
612
* Greg Dennis [@gregsdennis](https://github.com/gregsdennis)
713
* Kevin Swiber [@kevinswiber](https://github.com/kevinswiber)
8-
* Lorna Mitchell [@lornajane](https://github.com/lornajane)
9-
* Mike Kistler [@mikekistler](https://github.com/mikekistler)
1014
* Mike Ralphson [@MikeRalphson](https://github.com/MikeRalphson)
1115
* Ron Ratovsky [@webron](https://github.com/webron)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
],
4141
"scripts": {
4242
"build": "bash ./scripts/md2html/build.sh",
43+
"build-dev": "bash ./scripts/md2html/build.sh dev",
4344
"format-markdown": "bash ./scripts/format-markdown.sh ./versions/*.md",
4445
"test": "c8 --100 vitest run --coverage"
4546
}

scripts/md2html/build.sh

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,83 @@
22

33
# Author: @ralfhandl (inspired by the work of @MikeRalphson)
44

5-
# run this script from the root of the repo. It is designed to be run by a GitHub workflow.
5+
# run this script from the root of the repo
6+
# It is designed to be run by a GitHub workflow
7+
8+
# Usage: build.sh [version | "latest" | "dev"]
9+
# When run with no arguments, it builds artifacts for all published specification versions.
10+
# It may also be run with a specific version argument, such as "1.0.0" or "latest"
11+
# Finally, it may be run with "dev" to build "versions/*-dev.md"
12+
#
613
# It contains bashisms
714

8-
mkdir -p deploy/overlay
9-
mkdir -p deploy/js
15+
if [ "$1" = "dev" ]; then
16+
deploydir="deploy-preview"
17+
else
18+
deploydir="deploy/overlay"
19+
fi
20+
21+
mkdir -p $deploydir/js
22+
mkdir -p $deploydir/temp
23+
cp -p node_modules/respec/builds/respec-w3c.* $deploydir/js/
1024

11-
cd scripts/md2html
12-
mkdir -p history
13-
cp ../../EDITORS.md history/EDITORS_v1.0.0.md
25+
latest=$(git describe --abbrev=0 --tags)
1426

15-
# temporarily copy installed version of respec into build directory
16-
cp -p ../../node_modules/respec/builds/respec-w3c.* ../../deploy/js/
27+
if [ -z "$1" ]; then
28+
specifications=$(ls -1 versions/[1-9].[0-9].[0-9].md | sort -r)
29+
elif [ "$1" = "latest" ]; then
30+
specifications=$(ls -1 versions/$latest.md)
31+
elif [ "$1" = "dev" ]; then
32+
specifications=$(ls -1 versions/[1-9].[0-9].[0-9]-dev.md | sort -r)
33+
else
34+
specifications=$(ls -1 versions/$1.md)
35+
fi
1736

18-
# latest=`git describe --abbrev=0 --tags` -- introduce after release tags created
19-
latest=1.0.0
20-
latestCopied=none
37+
latestCopied="none"
2138
lastMinor="-"
22-
for filename in $(ls -1 ../../versions/[1-9].[0-9].[0-9].md | sort -r) ; do
23-
version=$(basename "$filename" .md)
39+
40+
for specification in $specifications; do
41+
version=$(basename "$specification" .md)
42+
43+
destination="$deploydir/v$version.html"
44+
if [ "$1" = "dev" ]; then
45+
maintainers="EDITORS.md"
46+
else
47+
maintainers="$(dirname $specification)/$version-editors.md"
48+
fi
49+
2450
minorVersion=${version:0:3}
25-
tempfile=../../deploy/overlay/v$version-tmp.html
26-
echo -e "\n=== v$version ==="
51+
tempfile="$deploydir/temp/$version.html"
52+
tempfile2="$deploydir/temp/$version-2.html"
53+
54+
echo === Building $version to $destination
2755

28-
node md2html.js --maintainers ./history/EDITORS_v$version.md ${filename} > $tempfile
29-
npx respec --use-local --src $tempfile --out ../../deploy/overlay/v$version.html
30-
rm $tempfile
56+
node scripts/md2html/md2html.js --maintainers $maintainers $specification "$allVersions" > $tempfile
57+
npx respec --no-sandbox --use-local --src $tempfile --out $tempfile2
58+
# remove unwanted Google Tag Manager and Google Analytics scripts
59+
sed -e 's/<script type="text\/javascript" async="" src="https:\/\/www.google-analytics.com\/analytics.js"><\/script>//' \
60+
-e 's/<script type="text\/javascript" async="" src="https:\/\/www.googletagmanager.com\/gtag\/js?id=G-[^"]*"><\/script>//' \
61+
$tempfile2 > $destination
62+
63+
echo === Built $destination
3164

3265
if [ $version = $latest ]; then
33-
if [[ ${version} != *"rc"* ]];then
66+
if [[ ${version} != *"rc"* ]]; then
3467
# version is not a Release Candidate
35-
( cd ../../deploy/overlay && ln -sf v$version.html latest.html )
36-
latestCopied=v$version
68+
ln -sf $(basename $destination) $deploydir/latest.html
69+
latestCopied="v$version"
3770
fi
3871
fi
3972

40-
if [ ${minorVersion} != ${lastMinor} ]; then
41-
( cd ../../deploy/overlay && ln -sf v$version.html v$minorVersion.html )
73+
if [ ${minorVersion} != ${lastMinor} ] && [ -z "$1" ]; then
74+
ln -sf $(basename $destination) $deploydir/v$minorVersion.html
4275
lastMinor=$minorVersion
4376
fi
4477
done
45-
echo Latest tag is $latest, copied $latestCopied to latest.html
4678

47-
# clean up build directory
48-
rm ../../deploy/js/respec-w3c.*
79+
if [ "$latestCopied" != "none" ]; then
80+
echo Latest tag is $latest, copied $latestCopied to latest.html
81+
fi
82+
83+
rm -r $deploydir/js
84+
rm -r $deploydir/temp

scripts/md2html/md2html.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const md = require('markdown-it')({
3636
'</code></pre>';
3737
}
3838

39-
return '<pre class="highlight '+lang+'" tabindex="0"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
39+
if (lang) console.warn('highlight.js does not support language',lang);
40+
return '<pre class="nohighlight" tabindex="0"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
4041
}
4142
});
4243

@@ -87,16 +88,16 @@ function preface(title,options) {
8788
// }
8889
};
8990

90-
let preface = `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>${md.utils.escapeHtml(title)}</title>`;
91+
let preface = '<!DOCTYPE html><html lang="en"><head>\n'
92+
preface += fs.readFileSync(path.resolve(__dirname,'./analytics/google.html'),'utf8');
93+
94+
// SEO
95+
preface += `<meta charset="UTF-8">\n<title>${md.utils.escapeHtml(title)}</title>`;
9196

9297
// ReSpec
9398
preface += '<script src="../js/respec-w3c.js" class="remove"></script>';
94-
preface += `<script class="remove">var respecConfig = ${JSON.stringify(respec)};</script>`;
95-
try {
96-
preface += fs.readFileSync('./analytics/google.html','utf8');
97-
}
98-
catch (ex) {}
99-
preface += '</head><body>';
99+
preface += `<script class="remove">var respecConfig = ${JSON.stringify(respec)};</script>\n`;
100+
preface += '</head>\n<body>';
100101
preface += '<style>';
101102
preface += '#respec-ui { visibility: hidden; }';
102103
preface += '#title { color: #578000; } #subtitle { color: #578000; }';
@@ -159,7 +160,7 @@ function getPublishDate(m) {
159160
let v = $(c[0]).text();
160161
let d = $(c[1]).text();
161162
argv.subtitle = v;
162-
if (d !== 'TBA') result = new Date(d);
163+
if (d !== 'TBD') result = new Date(d);
163164
}
164165
});
165166
return result;

versions/1.0.0-editors.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Overlay Specification Editors
2+
3+
## Active
4+
5+
* Darrel Miller [@darrelmiller](https://github.com/darrelmiller)
6+
* Greg Dennis [@gregsdennis](https://github.com/gregsdennis)
7+
* Kevin Swiber [@kevinswiber](https://github.com/kevinswiber)
8+
* Lorna Mitchell [@lornajane](https://github.com/lornajane)
9+
* Mike Kistler [@mikekistler](https://github.com/mikekistler)
10+
* Mike Ralphson [@MikeRalphson](https://github.com/MikeRalphson)
11+
* Ron Ratovsky [@webron](https://github.com/webron)

0 commit comments

Comments
 (0)