Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script and GitHub action to automatically generate ReSpec versions of the spec #2574

Merged
merged 35 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
76ff290
workflows: update used actions
MikeRalphson Feb 16, 2021
8c87817
.
MikeRalphson Feb 16, 2021
fd982b4
Merge branch 'fix-examples-action'
MikeRalphson Feb 16, 2021
24a1c48
bikeshed rendering (WIP)
MikeRalphson Nov 30, 2017
69abd86
bikeshed; split into v2, v3 directories
MikeRalphson Dec 1, 2017
f8ef13a
bikeshed; fixes to TOC,code blocks and indent levels
MikeRalphson Dec 6, 2017
65b43d6
bikeshed; work from unmodified .md files
MikeRalphson Dec 6, 2017
c847ecd
bikeshed; .gitignore
MikeRalphson Dec 6, 2017
b5ceccc
bikeshed; separate header for v3.0.1 for now
MikeRalphson Dec 7, 2017
9afcbea
respec; as an alternative to bikeshed
MikeRalphson Jan 30, 2018
493391a
Rename bikeshed to md2html
MikeRalphson Feb 17, 2018
67cf2ad
md2html; current setup
MikeRalphson May 2, 2018
d7d7ddb
md2html; wip
MikeRalphson May 2, 2018
31c26e4
md2html; fix 1 toc bug
MikeRalphson May 2, 2018
bf652b4
md2html; fix another toc bug
MikeRalphson May 2, 2018
5c345e9
md2html; fix 1 respec toc bug
MikeRalphson May 2, 2018
e13a565
md2html; fix another bikeshed toc bug
MikeRalphson May 2, 2018
252d0d7
respec; former editor support - needs ReSpec 20.x
MikeRalphson May 18, 2018
b184453
Latest respec tweaks
MikeRalphson Jun 12, 2018
07f16b7
pre block css background, RFC ref fixes
MikeRalphson Jun 12, 2018
615c4e8
Github gist syntax highlighting css
MikeRalphson Jun 12, 2018
1194d43
md2html: move to scripts dir
MikeRalphson Feb 15, 2020
0bdc26f
md2html: resolve relative links for examples
MikeRalphson Feb 15, 2020
3d3f530
md2html: use respec js from spec.openapis.org site
MikeRalphson Feb 15, 2020
fe073a3
md2html: find gist.css regardless of run dir
MikeRalphson Feb 16, 2020
c37ef59
md2html: don't mix https and http content (toc)
MikeRalphson Feb 22, 2020
559288c
md2html; include google analytics
MikeRalphson Sep 20, 2018
678ca70
md2html; build putative versions 4,5 etc
MikeRalphson Sep 20, 2018
cbdd3eb
md2html; tidying up
MikeRalphson May 27, 2020
33d8c0b
md2html; specify lang="en" in html
MikeRalphson May 27, 2020
a73363b
build: update deps
MikeRalphson Feb 16, 2021
fa8f44b
fix: style examples bugs, refs #2488
MikeRalphson Apr 29, 2021
85040b6
fix: update highlightjs call in md2html
MikeRalphson May 12, 2021
b2b1c16
feat: add github action
MikeRalphson May 13, 2021
3e89efa
build: create a `latest.html` ReSpec version
MikeRalphson May 17, 2021
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
5 changes: 2 additions & 3 deletions .github/workflows/convert-examples-to-json.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1 # checkout repo content
- uses: actions/checkout@v2 # checkout repo content

- name: Install dependencies
run: npm i
Expand All @@ -36,10 +36,9 @@ jobs:
git --no-pager -c color.diff=always diff --staged

- name: Create Pull Request
uses: peter-evans/create-pull-request@v1
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch-suffix: none
branch: update-json-examples
title: Update JSON example files
commit-message: Update JSON example files
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/respec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: respec

# author: @MikeRalphson
# issue: https://github.com/OAI/OpenAPI-Specification/issues/1564

#
# This workflow updates the respec 'pretty' rendered versions of the spec
# on the gh-pages branch when the corresponding markdown files change.
#

# run this on push to main
on:
push:
branches:
- main
workflow_dispatch: {}

jobs:
respec:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2 # checkout main branch

- name: Install dependencies
run: npm i

- uses: actions/checkout@v2 # checkout gh-pages branch
with:
ref: gh-pages
path: deploy

- name: run main script
run: scripts/md2html/build.sh

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update-respec-version
base: gh-pages
delete-branch: true
path: deploy
labels: Housekeeping
reviewers: webron,darrelmiller
title: Update ReSpec versions
commit-message: Update ReSpec versions
signoff: true
body: |
This pull request is automatically triggered by GitHub action `respec`.

The versions/v*.md files have changed, so the HTML files are automatically being regenerated.


2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ target
atlassian-ide-plugin.xml
node_modules/
package-lock.json
deploy/
history
Gemfile.lock
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
"README.md",
"schemas/*"
],
"dependencies": {},
"dependencies": {
"cheerio": "^1.0.0-rc.5",
"highlight.js": "^10.6.0",
"markdown-it": "^12.0.4",
"yargs": "^12.0.5"
},
"devDependencies": {
"mdv": "^1.0.7",
"yaml": "^1.8.3"
Expand Down
2 changes: 2 additions & 0 deletions scripts/md2html/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.err
input.bs
8 changes: 8 additions & 0 deletions scripts/md2html/analytics/google.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-831873-42"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-831873-42');
</script>
27 changes: 27 additions & 0 deletions scripts/md2html/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

# run this script from the root of the repo

mkdir -p deploy/oas
mkdir -p deploy/js

cd scripts/md2html
mkdir -p history
git show c740e950d:MAINTAINERS.md > history/MAINTAINERS_v2.0.md
cp -p js/* ../../deploy/js 2> /dev/null
cp -p markdown/* ../../deploy/ 2> /dev/null

node md2html.js --respec --maintainers ./history/MAINTAINERS_v2.0.md ../../versions/2.0.md > ../../deploy/oas/v2.0.html

latest=`git describe --abbrev=0 --tags`
for filename in ../../versions/[3456789].*.md ; do
version=$(basename "$filename" .md)
node md2html.js --respec --maintainers ../../MAINTAINERS.md ${filename} > ../../deploy/oas/v$version.html
if [ $version = $latest ]; then
if [[ ${version} != *"rc"* ]];then
# version is not a Release Candidate
cp -p ../../deploy/oas/v$version.html ../../deploy/oas/latest.html
fi
fi
done

71 changes: 71 additions & 0 deletions scripts/md2html/gist.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* GitHub Gist Theme
* Author : Louis Barranqueiro - https://github.com/LouisBarranqueiro
*/

.hljs {
display: block;
background: white;
padding: 0.5em;
color: #333333;
overflow-x: auto;
}

.hljs-comment,
.hljs-meta {
color: #969896;
}

.hljs-string,
.hljs-variable,
.hljs-template-variable,
.hljs-strong,
.hljs-emphasis,
.hljs-quote {
color: #df5000;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-type {
color: #a71d5d;
}

.hljs-literal,
.hljs-symbol,
.hljs-bullet,
.hljs-attribute {
color: #0086b3;
}

.hljs-section,
.hljs-name {
color: #63a35c;
}

.hljs-tag {
color: #333333;
}

.hljs-title,
.hljs-attr,
.hljs-selector-id,
.hljs-selector-class,
.hljs-selector-attr,
.hljs-selector-pseudo {
color: #795da3;
}

.hljs-addition {
color: #55a532;
background-color: #eaffea;
}

.hljs-deletion {
color: #bd2c00;
background-color: #ffecec;
}

.hljs-link {
text-decoration: underline;
}
Loading