forked from NCAS-CMS/cfdm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
release_docs
executable file
·115 lines (97 loc) · 3.23 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
set -x
if [[ $2 ]] ; then
echo "You no longer need to set the version. Hooray!"
exit 1
fi
version=`python -c "import cfdm; print(cfdm.__version__)"`
sphinx_version=`python -c "import sphinx; print(sphinx.__version__)"`
if [[ $sphinx_version != "2.4.5" ]] ; then
echo "ERROR: Must (sadly) use sphinx version 2.4.5. Got $sphinx_version"
exit 3
fi
if [[ $1 = "latest" ]] ; then
dir=$PWD/docs
elif [[ $1 = "archive" ]] ; then
# Creates separate dir and does not (git) commit
dir=$PWD/docs/$version
elif [[ $1 = "dev" ]] ; then
# For testing: creates separate dir and does not (git) commit
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 zip file
cd docs/source/sample_files
zip cfdm_tutorial_files.zip *.nc
cd -
# Regerenate tutorial.py
if [[ $1 = "latest" ]] ; then
./test_tutorial_code
fi
# --------------------------------------------------------------------
# Make the latest docs
# --------------------------------------------------------------------
cd docs
if [[ $1 = "latest" ]] || [[ $1 = "archive" ]] || [[ $1 = "dev-clean" ]] ; then
rm -fr $dir/.doctrees
fi
mkdir -p $dir/_downloads
make html $dir
cp -pv source/sample_files/cfdm_tutorial_files.zip source/tutorial.py $dir/_downloads
for download_file in cfdm_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
# 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' 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" ]] ; then
cd $dir
git add \
*.html \
class/*.html \
function/*.html \
method/*.html \
attribute/*.html \
*.inv \
*.js \
_static \
_templates \
_downloads/cfdm_tutorial_files.zip \
_downloads/tutorial.py \
_images/*
git commit -a -m "v$version documentation"
fi
set +x
echo PYTHONPATH=$PYTHONPATH