Add python-eventlet package to MOS 9.0 repository
[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 describe --dirty --tags`
57     git branch --track gh-pages origin/gh-pages || true
58     git checkout gh-pages
59     git ls-files |grep -Ev '^.gitignore$' |xargs rm -f
60     rm -rf "doc"
61
62     mv "$build"/* ./
63     touch ".nojekyll"
64     echo "eventlet.net" >"CNAME"
65     rmdir "$build"
66
67     echo "4. Commit"
68     git add -A
69     git status
70
71     read -p "Carefully read git status output above, press Enter to continue or Ctrl+C to abort"
72     git commit --edit -m "Website built from $source_name"
73 fi