2015-03-10 05:19:59 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# vim: expandtab ts=2 :
|
|
|
|
|
2015-03-17 02:37:44 +01:00
|
|
|
ARGS=$*
|
|
|
|
|
2015-03-10 05:19:59 +01:00
|
|
|
SPHINXBUILD=sphinx-build
|
|
|
|
TMPDIR='/tmp/offlineimap-sphinx-doctrees'
|
|
|
|
WEBSITE='../website'
|
2015-03-10 16:08:19 +01:00
|
|
|
DOCBASE="${WEBSITE}/_doc"
|
|
|
|
DESTBASE="${DOCBASE}/versions"
|
2015-03-10 05:19:59 +01:00
|
|
|
VERSIONS_YML="${WEBSITE}/_data/versions.yml"
|
2015-03-17 02:37:44 +01:00
|
|
|
ANNOUNCES_YML="${WEBSITE}/_data/announces.yml"
|
2015-03-10 05:19:59 +01:00
|
|
|
|
|
|
|
version="v$(../offlineimap.py --version)"
|
|
|
|
|
|
|
|
test -d "$DESTBASE" || exit 1
|
|
|
|
|
|
|
|
#
|
2015-03-17 02:37:44 +01:00
|
|
|
# Build the sphinx documentation.
|
2015-03-10 05:19:59 +01:00
|
|
|
#
|
2015-03-17 02:37:44 +01:00
|
|
|
function sphinx_doc () {
|
|
|
|
# Build the doc with sphinx.
|
|
|
|
dest="${DESTBASE}/${version}"
|
|
|
|
echo "Cleaning target directory: $dest"
|
|
|
|
rm -rf "$dest"
|
|
|
|
$SPHINXBUILD -b html -d "$TMPDIR" doc-src "$dest"
|
|
|
|
|
|
|
|
# Build the JSON definitions for Jekyll.
|
|
|
|
# This let know the website about the available APIs documentations.
|
|
|
|
echo "Building Jekyll data: $VERSIONS_YML"
|
|
|
|
echo "# DO NOT EDIT MANUALLY: it is generated by a script (website-doc.sh)" > "$VERSIONS_YML"
|
|
|
|
for version in $(ls "$DESTBASE" -1 | sort -nr)
|
|
|
|
do
|
|
|
|
echo "- $version"
|
|
|
|
done >> "$VERSIONS_YML"
|
|
|
|
}
|
|
|
|
|
2015-03-10 05:19:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
#
|
2015-03-17 02:37:44 +01:00
|
|
|
# Make Changelog public and save links to them as JSON.
|
2015-03-10 05:19:59 +01:00
|
|
|
#
|
2015-03-17 02:37:44 +01:00
|
|
|
function releases () {
|
|
|
|
# Copy the Changelogs.
|
|
|
|
for foo in ../Changelog.md ../Changelog.maint.md
|
|
|
|
do
|
|
|
|
cp -afv "$foo" "$DOCBASE"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Build the announces JSON list. Format is JSON:
|
|
|
|
# - {version: '<version>', link: '<link>'}
|
|
|
|
# - ...
|
|
|
|
echo "# DO NOT EDIT MANUALLY: it is generated by a script (website-doc.sh)" > "$ANNOUNCES_YML"
|
|
|
|
grep -E '^### OfflineIMAP' ../Changelog.md | while read title
|
|
|
|
do
|
|
|
|
link="$(echo $title | sed -r -e 's,^### (OfflineIMAP.*)\),\1,' \
|
|
|
|
| tr '[:upper:]' '[:lower:]' \
|
|
|
|
| sed -r -e 's,[\.("],,g' \
|
|
|
|
| sed -r -e 's, ,-,g'
|
|
|
|
)"
|
|
|
|
v="$(echo $title \
|
|
|
|
| sed -r -e 's,^### [a-Z]+ (v[^ ]+).*,\1,'
|
|
|
|
)"
|
|
|
|
echo "- {version: '${v}', link: '$link'}"
|
|
|
|
done | tee -a "$ANNOUNCES_YML"
|
|
|
|
}
|
|
|
|
|
2015-03-10 05:19:59 +01:00
|
|
|
|
2015-03-17 02:37:44 +01:00
|
|
|
|
|
|
|
exit_code=0
|
|
|
|
test "n$ARGS" = 'n' && ARG='usage' # no option passed
|
|
|
|
for arg in $ARGS
|
2015-03-10 16:08:19 +01:00
|
|
|
do
|
2015-03-17 02:37:44 +01:00
|
|
|
case "n$arg" in
|
|
|
|
"nreleases")
|
|
|
|
releases
|
|
|
|
;;
|
|
|
|
"napi")
|
|
|
|
api
|
|
|
|
;;
|
|
|
|
"nusage")
|
|
|
|
echo "Usage: website-doc.sh <releases|api|usage>"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "unkown option $arg"
|
|
|
|
exit_code=$(( $exit_code + 1 ))
|
|
|
|
;;
|
|
|
|
esac
|
2015-03-10 16:08:19 +01:00
|
|
|
done
|
2015-03-17 02:37:44 +01:00
|
|
|
|
|
|
|
exit $exit_code
|