Skip to content

Commit

Permalink
ci: add documentation generation scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjl-mux committed May 8, 2024
1 parent 3541df4 commit b8123cc
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
43 changes: 43 additions & 0 deletions scripts/create-docc-archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

readonly XCODE=$(xcodebuild -version | grep Xcode | cut -d " " -f2)

readonly TOP_DIR=$PWD
readonly BUILD_DIR="${TOP_DIR}/.build"
readonly DOCUMENTATION_DIR=".build/docs"
readonly OUTPUT_DIR="${TOP_DIR}/docs"

readonly SCHEME=MuxPlayerSwift
readonly DOCC_ARCHIVE_NAME="${SCHEME}.doccarchive"
readonly DOCC_ARCHIVE_PATH="${BUILD_DIR}/${DOCC_ARCHIVE_NAME}"

if ! command -v xcbeautify &> /dev/null
then
echo -e "\033[1;31m ERROR: xcbeautify could not be found please install it... \033[0m"
exit 1
fi

set -eu pipefail

echo "▸ Removing build directory: ${BUILD_DIR}"

rm -rf ${BUILD_DIR}

echo "▸ Using Xcode Version: ${XCODE}"

echo "▸ Building Documentation Catalog for ${SCHEME}"

mkdir -p $DOCUMENTATION_DIR

echo "▸ Creating documentation catalog with derived data path: ${DOCUMENTATION_DIR}"

xcodebuild docbuild -scheme $SCHEME \
-destination 'generic/platform=iOS' \
-sdk iphoneos \
-derivedDataPath "${DOCUMENTATION_DIR}" \
OTHER_DOCC_FLAGS="--transform-for-static-hosting --hosting-base-path mux-player-swift --output-path docs" \
| xcbeautify

echo "▸ Finished building Documentation Archive"

zip -ry mux-player-swift-static-docs.zip docs
6 changes: 6 additions & 0 deletions scripts/docc-files/index.html.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<meta charset="utf-8">
<!-- This file is intended to replace the automatically generated index.html so it redirects to the "real" homepage for mux-player-swift docs -->
<title>Redirecting to mux-player-swift homepage</title>
<meta http-equiv="refresh" content="0; URL=/mux-player-swift/documentation/muxplayerswift/">
<link rel="canonical" href="/mux-player-swift/documentation/muxplayerswift/"/>
1 change: 1 addition & 0 deletions scripts/docc-files/theme-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
29 changes: 29 additions & 0 deletions scripts/post-process-docc-archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

if [ -z $1 ]
then
echo -e "\033[1;31m ERROR: this script requires a repository name parameter. \033[0m"
exit $E_MISSING_POS_PARAM
fi

if [ -z $2 ]
then
echo -e "\033[1;31m ERROR: this script requires a target name parameter. \033[0m"
exit $E_MISSING_POS_PARAM
fi

echo "▸ Adding redirect from the docc static archive root"

output_path="docs"

sed -e "s/__SLUG__/${1}/g" \
-e "s/__TARGET__/${2}/g" \
"scripts/docc-files/index.html.template" > ${output_path}/index.html

echo "▸ Rewrote ${output_path}/index.html to:"

cat ${output_path}/index.html

echo "▸ Copy theme settings to static archive"

cp scripts/docc-files/theme-settings.json docs

0 comments on commit b8123cc

Please sign in to comment.