From dd2a70fc68bc52f783a0df5c1f8c5399d80ae707 Mon Sep 17 00:00:00 2001 From: Nicolas Sebrecht Date: Tue, 17 Mar 2015 02:37:44 +0100 Subject: [PATCH] website-doc.sh: learn to export Changelog's definitions Signed-off-by: Nicolas Sebrecht --- Changelog.md | 10 ++++- docs/Makefile | 3 +- docs/website-doc.sh | 89 +++++++++++++++++++++++++++++++++++---------- 3 files changed, 81 insertions(+), 21 deletions(-) diff --git a/Changelog.md b/Changelog.md index b2746fe..5fa6c38 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,13 +3,21 @@ layout: page title: Changelog of mainline --- + + + * The following excerpt is only usefull when rendered in the website. {:toc} ### OfflineIMAP v6.5.7-rc3 (2015- - ) - ### OfflineIMAP v6.5.7-rc2 (2015-01-18) #### Notes diff --git a/docs/Makefile b/docs/Makefile index 6a7f8ea..0efd63b 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -28,7 +28,8 @@ api: $(SPHINXBUILD) -b html -d html/doctrees doc-src html websitedoc: - ./website-doc.sh + ./website-doc.sh releases + ./website-doc.sh api clean: $(RM) -f $(HTML_TARGETS) diff --git a/docs/website-doc.sh b/docs/website-doc.sh index f232e1d..dc1b883 100755 --- a/docs/website-doc.sh +++ b/docs/website-doc.sh @@ -2,40 +2,91 @@ # # vim: expandtab ts=2 : +ARGS=$* + SPHINXBUILD=sphinx-build TMPDIR='/tmp/offlineimap-sphinx-doctrees' WEBSITE='../website' DOCBASE="${WEBSITE}/_doc" DESTBASE="${DOCBASE}/versions" VERSIONS_YML="${WEBSITE}/_data/versions.yml" +ANNOUNCES_YML="${WEBSITE}/_data/announces.yml" version="v$(../offlineimap.py --version)" test -d "$DESTBASE" || exit 1 -dest="${DESTBASE}/${version}" # -# Build sphinx documentation. +# Build the sphinx documentation. # -echo "Cleaning target directory: $dest" -rm -rf "$dest" -$SPHINXBUILD -b html -d "$TMPDIR" doc-src "$dest" +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" +} + + # -# Dynamically build JSON definitions for Jekyll. +# Make Changelog public and save links to them as JSON. # -echo "Building Jekyll data: $VERSIONS_YML" -for version in $(ls "$DESTBASE" -1 | sort -nr) +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: '', 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 - echo "- $version" -done > "$VERSIONS_YML" - -# -# Copy usefull sources of documentation. -# - -# Changelogs. -for foo in ../Changelog.md ../Changelog.maint.md -do - cp -afv "$foo" "$DOCBASE" + case "n$arg" in + "nreleases") + releases + ;; + "napi") + api + ;; + "nusage") + echo "Usage: website-doc.sh " + ;; + *) + echo "unkown option $arg" + exit_code=$(( $exit_code + 1 )) + ;; + esac done + +exit $exit_code