teleport/docs/build.sh

35 lines
1.1 KiB
Bash
Raw Normal View History

#!/bin/bash
2017-03-24 04:44:25 +00:00
# IMPORTANT! To add a new version, say 8.1
# * copy 2.3.yaml to 8.1.yaml
2017-03-24 04:44:25 +00:00
# * edit 8.1.yaml
2018-12-07 22:10:47 +00:00
# * edit theme/scripts.html and update docVersions variable
cd "$(dirname $0)" || exit
rm -f latest.yaml
# find all *.yaml files and convert them to array, pick the latest
cfiles=$(find . -maxdepth 1 -name '*.yaml' | sort)
mapfile -t cfiles_array <<< "$cfiles"
latest_cfile=${cfiles_array[-1]} # becomes "3.1.yaml"
latest_ver=${latest_cfile%.yaml} # becomes "3.1"
# build all documentation versions at the same time (4-8x speedup)
parallel --will-cite mkdocs build --config-file ::: $cfiles
# drop the 'latest.yml' symlink to the latest version so `mkdocs serve` will
# automatically serve the latest
echo "Latest version: $latest_ver"
ln -fs $latest_cfile latest.yaml
2017-03-24 04:44:25 +00:00
# copy the index file which serves /docs requests and redirects
# visitors to the latest verion of QuickStart
cp index.html ../build/docs/index.html
# create a symlink called 'latest' to the latest directory, like "3.1"
cd ../build/docs || exit
rm -f latest
ln -s $latest_ver latest
echo "The docs have been built and saved in 'build/docs'"