diff --git a/scripts/generate_docs.sh b/scripts/generate_docs.sh index 8c67b6d..f25e4bf 100755 --- a/scripts/generate_docs.sh +++ b/scripts/generate_docs.sh @@ -52,9 +52,11 @@ if ! command -v jazzy > /dev/null; then gem install jazzy --no-ri --no-rdoc fi -tmp=`mktemp -d` -mkdir -p "$tmp/docs/$version" -module_switcher="$tmp/docs/$version/README.md" +jazzy_dir="$root_path/.build/jazzy" +rm -rf "$jazzy_dir" +mkdir -p "$jazzy_dir" + +module_switcher="$jazzy_dir/README.md" jazzy_args=(--clean --author 'SwiftMetrics team' --readme "$module_switcher" @@ -84,7 +86,9 @@ done for module in "${modules[@]}"; do echo "processing $module" - args=("${jazzy_args[@]}" --output "$tmp/docs/$version/$module" --docset-path "$tmp/docset/$version/$module" --module "$module") + args=("${jazzy_args[@]}" --output "$jazzy_dir/docs/$version/$module" --docset-path "$jazzy_dir/docset/$version/$module" + --module "$module" --module-version $version + --root-url "https://apple.github.io/swift-metrics/docs/$version/$module/") if [[ -f "$root_path/.build/sourcekitten/$module.json" ]]; then args+=(--sourcekitten-sourcefile "$root_path/.build/sourcekitten/$module.json") fi @@ -92,13 +96,14 @@ for module in "${modules[@]}"; do done # push to github pages -if [[ $CI == true ]]; then +if [[ $PUSH == true ]]; then BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) GIT_AUTHOR=$(git --no-pager show -s --format='%an <%ae>' HEAD) git fetch origin +gh-pages:gh-pages git checkout gh-pages - rm -rf "docs" - cp -r "$tmp/docs" . + rm -rf "docs/$version" + rm -rf "docs/current" + cp -r "$jazzy_dir/docs/$version" docs/ cp -r "docs/$version" docs/current git add --all docs echo '
' > index.html