8f461e0db8902ee735e43ab3fdf89b2b30671c3b
[packages/trusty/python-eventlet.git] / python-eventlet / bin / build-website.bash
1 #!/bin/bash
2 set -e
3
4 build="$PWD/website-build"
5 usage="Builds eventlet.net website static pages into ${build}.
6 Requires sphinx-build, git and Github account.
7
8   --no-commit        Just build HTML, skip any git operations."
9
10 commit=1
11 while [ -n "$1" ]; do
12     case $1 in
13     --no-commit)
14         commit=0
15         ;;
16     *)
17         echo "$usage" >&2
18         exit 1
19         ;;
20     esac
21         shift
22 done
23
24 if ! which sphinx-build >/dev/null; then
25         echo "sphinx-build not found. Possible solution: pip install sphinx" >&2
26         echo "Links: http://sphinx-doc.org/" >&2
27         exit 1
28 fi
29
30 if [ $commit -eq 1 ] && ! git status >/dev/null; then
31         echo "git not found. git and Github account are required to update online documentation." >&2
32         echo "Links: http://git-scm.com/ https://github.com/" >&2
33         exit 1
34 fi
35
36 echo "1. clean"
37 rm -rf "$build"
38 mkdir -p "$build/doc"
39
40 echo "2. build static pages"
41 cp doc/real_index.html "$build/index.html"
42 cp NEWS doc/changelog.rst
43
44 # -b html -- builder, output mode
45 # -d dir  -- path to doctrees cache
46 # -n      -- nit-picky mode (kind of -Wall for gcc)
47 # -W      -- turns warnings into errors
48 # -q      -- quiet, emit only warnings and errors
49 sphinx-build -b html -d "$build/tmp" -n -q "doc" "$build/doc"
50 rm -rf "$build/tmp"
51 rm -f "$build/doc/.buildinfo"
52 rm -f "doc/changelog.rst"
53
54 if [ $commit -eq 1 ]; then
55     echo "3. Updating git branch gh-pages"
56     source_name=`git rev-parse --abbrev-ref HEAD`
57     source_id=`git rev-parse --short HEAD`
58     git branch --track gh-pages origin/gh-pages || true
59     git checkout gh-pages
60     git ls-files |grep -Ev '^.gitignore$' |xargs rm -f
61     rm -rf "doc"
62
63     mv "$build"/* ./
64     touch ".nojekyll"
65     echo "eventlet.net" >"CNAME"
66     rmdir "$build"
67
68     echo "4. Commit"
69     git add -A
70     git status
71
72     read -p "Carefully read git status output above, press Enter to continue or Ctrl+C to abort"
73     git commit --edit -m "Website built from $source_name $source_id"
74 fi