website-doc.sh: learn to export Changelog's definitions

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2015-03-17 02:37:44 +01:00
parent c89d17dacb
commit dd2a70fc68
3 changed files with 81 additions and 21 deletions

View File

@ -3,13 +3,21 @@ layout: page
title: Changelog of mainline title: Changelog of mainline
--- ---
<!--
Note to mainainers:
* You should not edit this file manually; prefer the ./contrib/release.sh script.
* If you really want to do manual edition, keep in mind that it's exported as-is
to the website which expect the current structure (title levels, title syntax,
sub-sections, front matter, etc).
-->
* The following excerpt is only usefull when rendered in the website. * The following excerpt is only usefull when rendered in the website.
{:toc} {:toc}
### OfflineIMAP v6.5.7-rc3 (2015- - ) ### OfflineIMAP v6.5.7-rc3 (2015- - )
### OfflineIMAP v6.5.7-rc2 (2015-01-18) ### OfflineIMAP v6.5.7-rc2 (2015-01-18)
#### Notes #### Notes

View File

@ -28,7 +28,8 @@ api:
$(SPHINXBUILD) -b html -d html/doctrees doc-src html $(SPHINXBUILD) -b html -d html/doctrees doc-src html
websitedoc: websitedoc:
./website-doc.sh ./website-doc.sh releases
./website-doc.sh api
clean: clean:
$(RM) -f $(HTML_TARGETS) $(RM) -f $(HTML_TARGETS)

View File

@ -2,40 +2,91 @@
# #
# vim: expandtab ts=2 : # vim: expandtab ts=2 :
ARGS=$*
SPHINXBUILD=sphinx-build SPHINXBUILD=sphinx-build
TMPDIR='/tmp/offlineimap-sphinx-doctrees' TMPDIR='/tmp/offlineimap-sphinx-doctrees'
WEBSITE='../website' WEBSITE='../website'
DOCBASE="${WEBSITE}/_doc" DOCBASE="${WEBSITE}/_doc"
DESTBASE="${DOCBASE}/versions" DESTBASE="${DOCBASE}/versions"
VERSIONS_YML="${WEBSITE}/_data/versions.yml" VERSIONS_YML="${WEBSITE}/_data/versions.yml"
ANNOUNCES_YML="${WEBSITE}/_data/announces.yml"
version="v$(../offlineimap.py --version)" version="v$(../offlineimap.py --version)"
test -d "$DESTBASE" || exit 1 test -d "$DESTBASE" || exit 1
dest="${DESTBASE}/${version}"
# #
# Build sphinx documentation. # Build the sphinx documentation.
# #
echo "Cleaning target directory: $dest" function sphinx_doc () {
rm -rf "$dest" # Build the doc with sphinx.
$SPHINXBUILD -b html -d "$TMPDIR" doc-src "$dest" 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"
}
# #
# Dynamically build JSON definitions for Jekyll. # Make Changelog public and save links to them as JSON.
# #
echo "Building Jekyll data: $VERSIONS_YML" function releases () {
for version in $(ls "$DESTBASE" -1 | sort -nr) # 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"
}
exit_code=0
test "n$ARGS" = 'n' && ARG='usage' # no option passed
for arg in $ARGS
do do
echo "- $version" case "n$arg" in
done > "$VERSIONS_YML" "nreleases")
releases
# ;;
# Copy usefull sources of documentation. "napi")
# api
;;
# Changelogs. "nusage")
for foo in ../Changelog.md ../Changelog.maint.md echo "Usage: website-doc.sh <releases|api|usage>"
do ;;
cp -afv "$foo" "$DOCBASE" *)
echo "unkown option $arg"
exit_code=$(( $exit_code + 1 ))
;;
esac
done done
exit $exit_code