-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild-docs.sh
More file actions
executable file
·54 lines (43 loc) · 1.96 KB
/
build-docs.sh
File metadata and controls
executable file
·54 lines (43 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash -e
DOCS_DIR=build/docs
OAS3_YAML=api.oas3.yaml
OAS3_JSON=api.oas3.json
mkdir -p $DOCS_DIR
# Validate OpenAPI 3.0 YAML
./node_modules/.bin/swagger-cli validate $OAS3_YAML
# Resolve YAML files in to one master JSON file
./node_modules/.bin/swagger-cli bundle -o $OAS3_JSON $OAS3_YAML
# Convert OpenAPI to doc to Shins Markdown
./node_modules/.bin/widdershins \
--theme dracula \
--language_tabs shell:Curl http:HTTP javascript--nodejs:NodeJS php:PHP ruby:Ruby python:Python java:Java go:Go \
--summary $OAS3_JSON \
--outfile $DOCS_DIR/index.html.md
cp $DOCS_DIR/index.html.md .shins/source/index.html.md
# Replace Create, Serve, Ingest API URL's as overrides do not work
sed -i -e 's/https:\/\/api.shotstack.io\/edit\/{version}\/assets/https:\/\/api.shotstack.io\/serve\/{version}\/assets/g' .shins/source/index.html.md
sed -i -e 's/https:\/\/api.shotstack.io\/edit\/{version}\/sources/https:\/\/api.shotstack.io\/ingest\/{version}\/sources/g' .shins/source/index.html.md
sed -i -e 's/https:\/\/api.shotstack.io\/edit\/{version}\/createassets/https:\/\/api.shotstack.io\/create\/{version}\/assets/g' .shins/source/index.html.md
# Openapi doesn't support duplicate path mapping
sed -i -e 's/\/path_alias_createassets/\/assets/g' .shins/source/index.html.md
# Build the Shins docs HTML
cd .shins
node shins.js \
--logo ../assets/img/logo.svg \
--logo-url https://shotstack.io \
--customCss --minify
rm -f source/index.html.md-e
cd ..
mkdir -p $DOCS_DIR/source/images
cp .shins/index.html ./$DOCS_DIR/.
cp -r .shins/pub ./$DOCS_DIR/.
cp -r .shins/source/images/custom_logo.svg ./$DOCS_DIR/source/images/custom_logo.svg
cp -r .shins/source/images/navbar.png ./$DOCS_DIR/source/images/navbar.png
cp -r .shins/source/fonts ./$DOCS_DIR/source/fonts
# Insert Google Analytics
if [ -f .tags ]; then
sed -i.tmp -e '/{{TAGS}}/r.tags' -e '/{{TAGS}}/d' ./$DOCS_DIR/index.html
rm -f ./$DOCS_DIR/index.html.tmp
fi
rm -f ./$DOCS_DIR/index.html.md
rm -f $OAS3_JSON