Skip to content

Commit 3ed9e38

Browse files
committed
Preserve experimental api docs when deploying site
1 parent d826f5f commit 3ed9e38

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

site/deploy.sh

+25-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,31 @@ git --work-tree "$ROOT_DIR" worktree add -B gh-pages "$PAGES_DIR" origin/gh-page
3838
# Now work in newly created workspace
3939
cd "$PAGES_DIR"
4040

41-
# Remove all the old documentation
42-
git rm -r * > /dev/null
41+
# Fixup all the old documentation files
42+
# Remove non-.html files
43+
git rm `find . -type f -not -name '*.html' -not -name '.git'` > /dev/null
44+
45+
# Replace "experimental" .html files with links to the corresponding non-experimental version
46+
# or remove them if there is no corresponding non-experimental file
47+
echo "Redirecting experimental pages"
48+
git_add=()
49+
git_rm=()
50+
for file in `find . -type f -name '*.html'` ; do
51+
match=nothing_is_found
52+
if [[ $file =~ \.experimental ]] ; then
53+
match="${file//\.experimental/}"
54+
fi
55+
if [[ -f "$DIST_DIR/$match" ]] ; then
56+
# redirect to non-experimental version
57+
echo "<html><script>window.onload = function() { window.location.href = \"/kotlinx.coroutines${match#.}\" }</script></html>" > "$file"
58+
git_add+=("$file")
59+
else
60+
# redirect not found -- remove the file
61+
git_rm+=("$file")
62+
fi
63+
done
64+
git add "${git_add[@]}"
65+
git rm "${git_rm[@]}" > /dev/null
4366

4467
# Copy new documentation from dist
4568
cp -r "$DIST_DIR"/* "$PAGES_DIR"

0 commit comments

Comments
 (0)