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'
|
2015-03-25 20:09:59 +01:00
|
|
|
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"
|
2016-07-22 17:21:13 +02:00
|
|
|
ANNOUNCES_YML_TMP="${ANNOUNCES_YML}.tmp"
|
2015-03-25 20:09:59 +01:00
|
|
|
CONTRIB_YML="${WEBSITE}/_data/contribs.yml"
|
|
|
|
CONTRIB="${DOCBASE}/contrib"
|
|
|
|
HEADER="# DO NOT EDIT MANUALLY: it is generated by a script (website-doc.sh)."
|
|
|
|
|
|
|
|
|
|
|
|
function fix_pwd () {
|
|
|
|
cd "$(git rev-parse --show-toplevel)" || \
|
|
|
|
exit 2 "cannot determine the root of the repository"
|
|
|
|
test -d "$DESTBASE" || exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
fix_pwd
|
|
|
|
version="v$(./offlineimap.py --version)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Add the doc for the contrib files.
|
|
|
|
#
|
|
|
|
function contrib () {
|
|
|
|
echo $HEADER > "$CONTRIB_YML"
|
|
|
|
# systemd
|
|
|
|
cp -afv "./contrib/systemd/README.md" "${CONTRIB}/systemd.md"
|
|
|
|
echo "- {filename: 'systemd', linkname: 'Integrate with systemd'}" >> "$CONTRIB_YML"
|
|
|
|
}
|
2015-03-10 05:19:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
2015-03-17 02:37:44 +01:00
|
|
|
# Build the sphinx documentation.
|
2015-03-10 05:19:59 +01:00
|
|
|
#
|
2015-03-19 23:35:03 +01:00
|
|
|
function api () {
|
2015-03-17 02:37:44 +01:00
|
|
|
# Build the doc with sphinx.
|
|
|
|
dest="${DESTBASE}/${version}"
|
|
|
|
echo "Cleaning target directory: $dest"
|
|
|
|
rm -rf "$dest"
|
2015-03-25 20:09:59 +01:00
|
|
|
$SPHINXBUILD -b html -d "$TMPDIR" ./docs/doc-src "$dest"
|
2015-03-17 02:37:44 +01:00
|
|
|
|
|
|
|
# Build the JSON definitions for Jekyll.
|
|
|
|
# This let know the website about the available APIs documentations.
|
|
|
|
echo "Building Jekyll data: $VERSIONS_YML"
|
2015-03-14 15:45:56 +01:00
|
|
|
# Erase previous content.
|
2015-03-25 20:09:59 +01:00
|
|
|
echo "$HEADER" > "$VERSIONS_YML"
|
2015-03-17 02:37:44 +01:00
|
|
|
for version in $(ls "$DESTBASE" -1 | sort -nr)
|
|
|
|
do
|
|
|
|
echo "- $version"
|
2017-03-11 13:42:52 +01:00
|
|
|
done | sort -V >> "$VERSIONS_YML"
|
2015-03-17 02:37:44 +01:00
|
|
|
}
|
|
|
|
|
2015-03-10 05:19:59 +01:00
|
|
|
|
|
|
|
|
2016-06-08 03:21:28 +02:00
|
|
|
#
|
|
|
|
# Return title from release entry.
|
|
|
|
# $1: full release title
|
|
|
|
#
|
|
|
|
function parse_releases_get_link () {
|
2016-07-22 17:21:13 +02:00
|
|
|
echo $1 | sed -r -e 's,^### (OfflineIMAP.*)\),\1,' \
|
|
|
|
| tr '[:upper:]' '[:lower:]' \
|
|
|
|
| sed -r -e 's,[\.("],,g' \
|
|
|
|
| sed -r -e 's, ,-,g'
|
2016-06-08 03:21:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Return version from release entry.
|
|
|
|
# $1: full release title
|
|
|
|
#
|
|
|
|
function parse_releases_get_version () {
|
2016-07-22 17:57:24 +02:00
|
|
|
echo $1 | sed -r -e 's,^### [a-Z]+ (v[^ ]+).*,\1,'
|
2016-07-22 17:21:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Return date from release entry.
|
|
|
|
# $1: full release title
|
|
|
|
#
|
|
|
|
function parse_releases_get_date () {
|
2016-07-22 17:57:24 +02:00
|
|
|
echo $1 | sed -r -e 's,.*\(([0-9]+-[0-9]+-[0-9]+).*,\1,'
|
2016-06-08 03:21:28 +02:00
|
|
|
}
|
|
|
|
|
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.
|
2015-03-25 20:09:59 +01:00
|
|
|
for foo in ./Changelog.md ./Changelog.maint.md
|
2015-03-17 02:37:44 +01:00
|
|
|
do
|
|
|
|
cp -afv "$foo" "$DOCBASE"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Build the announces JSON list. Format is JSON:
|
|
|
|
# - {version: '<version>', link: '<link>'}
|
|
|
|
# - ...
|
2015-03-25 20:09:59 +01:00
|
|
|
echo "$HEADER" > "$ANNOUNCES_YML"
|
2016-06-08 03:21:28 +02:00
|
|
|
# Announces for the mainline.
|
2015-03-25 20:09:59 +01:00
|
|
|
grep -E '^### OfflineIMAP' ./Changelog.md | while read title
|
2015-03-17 02:37:44 +01:00
|
|
|
do
|
2016-07-22 17:57:24 +02:00
|
|
|
link="$(parse_releases_get_link "$title")"
|
|
|
|
v="$(parse_releases_get_version "$title")"
|
|
|
|
d="$(parse_releases_get_date "$title")"
|
2016-07-22 17:21:13 +02:00
|
|
|
echo "- {date: '${d}', version: '${v}', link: 'Changelog.html#${link}'}"
|
|
|
|
done | tee -a "$ANNOUNCES_YML_TMP"
|
2016-06-08 03:21:28 +02:00
|
|
|
# Announces for the maintenance releases.
|
|
|
|
grep -E '^### OfflineIMAP' ./Changelog.maint.md | while read title
|
|
|
|
do
|
2016-07-22 17:57:24 +02:00
|
|
|
link="$(parse_releases_get_link "$title")"
|
|
|
|
v="$(parse_releases_get_version "$title")"
|
|
|
|
d="$(parse_releases_get_date "$title")"
|
2016-07-22 17:21:13 +02:00
|
|
|
echo "- {date: '${d}', version: '${v}', link: 'Changelog.maint.html#${link}'}"
|
|
|
|
done | tee -a "$ANNOUNCES_YML_TMP"
|
|
|
|
sort -nr "$ANNOUNCES_YML_TMP" >> "$ANNOUNCES_YML"
|
|
|
|
rm -f "$ANNOUNCES_YML_TMP"
|
2015-03-17 02:37:44 +01:00
|
|
|
}
|
|
|
|
|
2015-03-10 05:19:59 +01:00
|
|
|
|
2015-03-17 02:37:44 +01:00
|
|
|
exit_code=0
|
2016-09-21 04:11:17 +02:00
|
|
|
test "n$ARGS" = 'n' && ARGS='usage' # no option passed
|
2015-03-17 02:37:44 +01:00
|
|
|
for arg in $ARGS
|
2015-03-10 16:08:19 +01:00
|
|
|
do
|
2015-03-25 20:09:59 +01:00
|
|
|
# PWD was fixed at the very beginning.
|
2015-03-17 02:37:44 +01:00
|
|
|
case "n$arg" in
|
|
|
|
"nreleases")
|
|
|
|
releases
|
|
|
|
;;
|
|
|
|
"napi")
|
|
|
|
api
|
|
|
|
;;
|
2015-03-25 20:09:59 +01:00
|
|
|
"ncontrib")
|
|
|
|
contrib
|
|
|
|
;;
|
2015-03-17 02:37:44 +01:00
|
|
|
"nusage")
|
2015-03-25 20:09:59 +01:00
|
|
|
echo "Usage: website-doc.sh <releases|api|contrib|usage>"
|
2015-03-17 02:37:44 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
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
|