forked from NCAS-CMS/cfunits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_docs
executable file
·81 lines (69 loc) · 2.39 KB
/
release_docs
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
#!/bin/bash
set -x
if [[ $2 ]] ; then
echo "You no longer need to set the version. Hooray!"
exit 1
fi
version=`python -c "import cfunits; print(cfunits.__version__)"`
if [[ $1 = "latest" ]] ; then
dir=$PWD/docs
elif [[ $1 = "archive" ]] ; then
dir=$PWD/docs/$version
elif [[ $1 = "dev" ]] ; then
# For testing: creates separate dir and does not (git) commit. DOES
# NOT delete an existing .doctrees subdirectory, meaning that
# untouched source files (.py or .rst) might not get rebuilt, even
# if conf.py or other styling files have been modified.
dir=$PWD/docs/dev
elif [[ $1 = "dev-clean" ]] ; then
# For testing: creates separate dir and does not (git) commit and
# also deletes an existing .doctrees subdirectory
dir=$PWD/docs/dev
elif [[ $1 = "dev-scrub" ]] ; then
# For testing: creates separate dir and does not (git) commit and
# also completely deletes the new target directory.
dir=$PWD/docs/dev
rm -fr $dir
else
set +x
echo "\$1 must be one of 'dev', 'dev-clean', 'dev-scrub', 'latest', or 'archive'"
exit 2
fi
# --------------------------------------------------------------------
# Make the latest docs
# --------------------------------------------------------------------
cd docs
if [[ $1 = "latest" ]] || [[ $1 = "archive" ]] || [[ $1 = "dev-clean" ]] ; then
rm -fr $dir/.doctrees
fi
make html $dir
# Copy over our custom stylesheet. It is referenced in the HTML docs files but
# Sphinx with alabaster theme doesn't seem to (?) provide a means to transfer
# it to the created _static dir via the build itself *when* the output dir is
# the top-level one (hence copy works for 'dev' & 'archive' sub-dir builds).
# Seemingly relates to the build warning:
# WARNING: html_static_path entry '_static' is placed inside outdir
if [[ $1 = "latest" ]] ; then
cp source/_static/customise-alabaster.css _static/customise-alabaster.css
fi
# Copy the templates to the target directory
if [[ $1 != "latest" ]] ; then
rm -fr $dir/_templates
cp -pr _templates $dir
fi
# --------------------------------------------------------------------
# Add and commit
# --------------------------------------------------------------------
if [[ $1 = "latest" ]] || [[ $1 = "archive" ]] ; then
cd $dir
git add \
*.html \
*.inv \
*.js \
generated \
_static \
_templates
git commit -a -m "v$version $1 documentation"
fi
set +x
echo PYTTHONPATH=$PYTHONPATH