-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructured repository allowing for the storing of multiple versions (…
…#29) Restructed the repository to allow for multiple versions to be maintained together. The following changes were done: - Updated the deployment script to allow for the Redocly bundles to be deployed whenever a new version is available. - Automatically created a header html to allow for the linking to a specific version. - Updated the versions by one bugfix to allow for the link fixes within the openapi.yaml.
- Loading branch information
Showing
4 changed files
with
1,717 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,66 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "Getting started" | ||
declare currentFolder=$(pwd) | ||
declare publicFolder="$currentFolder/public" | ||
declare allFolders | ||
|
||
# Bundle docs into zero-dependency HTML file | ||
npx redoc-cli bundle openapi.yaml && \ | ||
mv redoc-static.html index.html && \ | ||
echo "Changed name from redoc-static.html to index.html" && \ | ||
# Add favicon | ||
sed -i '7 i \ \ <link rel="icon" type="image/png" href="images/favicon.png"/>' index.html && \ | ||
echo -e "\nDone!" | ||
# Creates static html files for openapi.yaml file in the current directory | ||
loadStaticHtmlToFolder() { | ||
local folder="$1" | ||
|
||
echo "Creating folder $publicFolder/$folder" | ||
mkdir -p $publicFolder/$folder | ||
|
||
echo "Running redocly/cli build-docs command on $currentFolder/$folder/openapi.yaml and saving it to $publicFolder/$folder/index.html" | ||
npx @redocly/cli@latest build-docs $currentFolder/$folder/openapi.yaml -o $publicFolder/$folder/index.html | ||
} | ||
|
||
# Selects all folders in the current directory | ||
selectAllFoldersInDirectory() { | ||
local -n folders=$1 | ||
|
||
echo "Selecting all folders in $currentFolder" | ||
|
||
# Use glob pattern to get all directories | ||
for dir in "$currentFolder"/*/; do | ||
# Check if it's a directory | ||
if [ -d "$dir" ] && [[ "$dir" != */images/ ]] && [[ "$dir" != */public/ ]]; then | ||
folders+=("$dir") | ||
fi | ||
done | ||
|
||
# Stripping the path and getting only the folder name | ||
folders=("${folders[@]%/}") | ||
folders=("${folders[@]##*/}") | ||
} | ||
|
||
# Initializes the public folder | ||
initializePublicFolder() { | ||
echo "Creating $publicFolder" | ||
mkdir -p $publicFolder | ||
|
||
echo "Copying $currentFolder/images folder to $publicFolder" | ||
cp -r $currentFolder/images $publicFolder | ||
} | ||
|
||
# Creates index.html file | ||
createIndexHtml() { | ||
local -n folders=$1 | ||
|
||
echo "Creating index.html in $publicFolder" | ||
local indexHtml="$publicFolder/index.html" | ||
echo "<html><head><title>SSC API</title></head><body><h1>SSC API</h1><ul>" > $indexHtml | ||
for folder in "${folders[@]}"; do | ||
echo "<li><a href=\"$folder/\">$folder</a></li>" >> $indexHtml | ||
done | ||
echo "</ul></body></html>" >> $indexHtml | ||
} | ||
|
||
selectAllFoldersInDirectory allFolders | ||
initializePublicFolder | ||
createIndexHtml allFolders | ||
|
||
for directory in "${allFolders[@]}"; do | ||
loadStaticHtmlToFolder $directory | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.