forked from NCAS-CMS/cf-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_docs
executable file
·96 lines (80 loc) · 2.75 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
set -x
if [[ ! $1 ]] ; then
echo "No version \$1 (e.g. 3.3.0)"
exit 1
fi
version=$1
if [[ $2 = "latest" ]] ; then
dir=$PWD/docs
elif [[ $2 = "archive" ]] ; then
dir=$PWD/docs/$version
elif [[ $2 = "dev" ]] ; then
# For testing: creates separate dir and does not (git) commit. DOES
# NOT deletes 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 [[ $2 = "dev-clean" ]] ; then
# For testing: creates separate dir and does not (git) commit and
# also deletes an existing .doctrees subdirectory
dir=$PWD/docs/dev
else
set +x
echo "\$2 must be one of 'latest', 'archive', 'dev' or 'dev-clean'"
exit 2
fi
export PYTHONPATH=$PWD:$PYTHONPATH
# Make zip file
cd docs/source/sample_files
zip cf_tutorial_files.zip *.nc *.pp
cd -
# --------------------------------------------------------------------
# Make the latest docs
# --------------------------------------------------------------------
cd docs
if [[ $2 = "latest" ]] || [[ $2 = "archive" ]] || [[ $2 = "dev-clean" ]] ; then
rm -fr $dir/.doctrees
fi
mkdir -p $dir/_downloads
make html $dir
cp -pv source/sample_files/cf_tutorial_files.zip source/tutorial.py $dir/_downloads
for download_file in cf_tutorial_files.zip tutorial.py
do
# Remove the hash string component added by GitHub to the link
# where the resources are hosted (GH changes it to something like
# '_downloads/4cd32e1c6bdf28fb61e15ffab2a8d84e/download_file')
sed -i "s/\(href=._downloads\).*\($download_file\)/\1\/\2/" \
$dir/tutorial.html \
$dir/analysis.html
# all pages referencing these resources must be added to this list
done
# 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' builds to sub-dirs). Seemingly relates to the
# build warning:
# WARNING: html_static_path entry '_static' is placed inside outdir
if [[ $2 = "latest" ]] ; then
cp source/_static/customise-alabaster.css _static/customise-alabaster.css
fi
# --------------------------------------------------------------------
# Add and commit the latest or archive
# --------------------------------------------------------------------
if [[ $2 = "latest" ]] || [[ $2 = "archive" ]] ; then
echo "d2=$2"
cd $dir
git add \
*.html \
*/*.html \
*.inv \
*.js \
_static \
_downloads/cf_tutorial_files.zip \
_downloads/tutorial.py \
_images/*.png
git commit -a -m "v$version $2 documentation"
fi
set +x
echo PYTHONATH=$PYTHONPATH