forked from smithy-lang/smithy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkdocs
executable file
·89 lines (71 loc) · 2.3 KB
/
mkdocs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# This script updates the documentation hosted at
# https://smithy.io/. There is a y/n prompt before a publish
# is performed to allow for a spot-check of the changes.
#
# This script will run `pip3 install -r requirements.txt` in the docs
# directory. If you don't want to globally install dependencies, ensure that
# you are first in a virtual environment of some kind before running this
# script.
set -e
#### Load library version ####
# Load the version number of the library (used to version javadocs)
library_version=$(cat VERSION)
library_version=${library_version%%*( )}
if [ -z "${library_version}" ]; then
echo "Unable to find the version property or it is empty"
exit 1
fi
#### Clone the docs branch ####
# Clone a copy of smithy into a staging directory
rm -rf /tmp/_smithy-docs
git clone git@github.com:awslabs/smithy.git --branch gh-pages --single-branch /tmp/_smithy-docs
cd /tmp/_smithy-docs
git checkout gh-pages
cd -
#### Build javadoc ####
./gradlew javadoc
# Always build javadoc into each version.
cp -R build/docs/javadoc/* /tmp/_smithy-docs/javadoc/${library_version}
# Remove this unnecessary duplicate copy of the docs.
rm -rf /tmp/_smithy-docs/javadoc/${library_version}/latest
# Create a redirect from "latest" to the version:
rm -rf /tmp/_smithy-docs/javadoc/latest
mkdir -p /tmp/_smithy-docs/javadoc/latest
# Create an HTML redirect from javadoc/latest/ to, for example, javadoc/1.0.0
cat << EOF > /tmp/_smithy-docs/javadoc/latest/index.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>Redirecting to latest javadocs</title>
<meta http-equiv="refresh" content="0; URL=../${library_version}/">
EOF
#### Build Sphinx docs ####
cd docs
pip3 install -r requirements.txt
make clean && make html
cp -R build/html/* /tmp/_smithy-docs
# Delete unnecessary files
rm /tmp/_smithy-docs/.buildinfo || true
rm /tmp/_smithy-docs/objects.inv || true
cd -
cd /tmp/_smithy-docs
git add -A
git status
#### Deploy the docs ####
# We can automate this eventually
read -p "Show full diff? [y/n]" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
git diff origin/gh-pages
fi
read -p "Publish docs? [y/n]" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
git commit -m 'Update documentation'
git push origin gh-pages
echo "Documentation has been published"
else
echo "Documentation was not published"
fi