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
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@ This might apply to, for example, Markdown files, automation, and scripts.
For all pull requests, if they should not be merged yet for any reason (they depend on something else, you would like feedback from a specific reviewer), mark them as draft and they will not be merged while in that state.
Draft pull requests can still be reviewed while in draft state.

### Preview specification HTML locally

The markdown source files are converted to HTML before publishing.
To do this locally, please

1. Install [Node.js](https://nodejs.org/)
2. Check out this repo, go to the repo root, and switch to a development branch
3. Execute `npm install` (once, repeat after merging upstream changes)
4. Execute `npm run build-src` after changing `src/oas.md` (this first executes `npm run validate-markdown`, which can also be run separately)
5. Open output file `deploy-preview/oas.html` with a browser and check your changes

Please make sure the markdown validates and builds using the above steps before creating a pull request or marking a draft pull request as ready for review.

## Reviewers

> [!NOTE]
Expand Down
13 changes: 8 additions & 5 deletions scripts/md2html/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ for specification in $specifications; do

minorVersion=${version:0:3}
tempfile="$deploydir/temp/$version.html"
tempfile2="$deploydir/temp/$version-2.html"

echo === Building $version to $destination

node scripts/md2html/md2html.js --maintainers $maintainers $specification "$allVersions" > $tempfile
npx respec --no-sandbox --use-local --src $tempfile --out $destination
rm $tempfile
npx respec --no-sandbox --use-local --src $tempfile --out $tempfile2
# remove unwanted Google Tag Manager and Google Analytics scripts
sed -e 's/<script type="text\/javascript" async="" src="https:\/\/www.google-analytics.com\/analytics.js"><\/script>//' \
-e 's/<script type="text\/javascript" async="" src="https:\/\/www.googletagmanager.com\/gtag\/js?id=G-[^"]*"><\/script>//' \
$tempfile2 > $destination

echo === Built $destination

Expand All @@ -79,6 +83,5 @@ if [ "$latestCopied" != "none" ]; then
echo Latest tag is $latest, copied $latestCopied to latest.html
fi

rm $deploydir/js/respec-w3c.*
rmdir $deploydir/js
rmdir $deploydir/temp
rm -r $deploydir/js
rm -r $deploydir/temp
11 changes: 6 additions & 5 deletions scripts/md2html/md2html.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,18 @@ function preface(title,options) {
// }
};

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

// SEO
preface += '<meta name="description" content="The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.">';
preface += `<meta charset="UTF-8">\n<title>${md.utils.escapeHtml(title)}</title>`;
preface += '<meta name="description" content="The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.">\n';

// ReSpec
preface += '<meta name="color-scheme" content="light dark">';
preface += '<script src="../js/respec-w3c.js" class="remove"></script>';
preface += `<script class="remove">var respecConfig = ${JSON.stringify(respec)};</script>`;
preface += fs.readFileSync(path.resolve(__dirname,'./analytics/google.html'),'utf8');
preface += '</head><body>';
preface += `<script class="remove">var respecConfig = ${JSON.stringify(respec)};</script>\n`;
preface += '</head>\n<body>';
preface += '<style>';
preface += fs.readFileSync(path.resolve(__dirname,'main.css'),'utf8').split(/\r?\n/).join(' ');
preface += fs.readFileSync(path.resolve(__dirname,'gist.css'),'utf8').split(/\r?\n/).join(' ');
Expand Down
Loading