Browse code

Merge "Simplify docs build"

Jenkins authored on 2014/12/09 14:12:16
Showing 3 changed files
... ...
@@ -8,3 +8,5 @@ Recent Changes What's been happening?
8 8
 These are the commits to DevStack for the last six months. For the
9 9
 complete list see `the DevStack project in
10 10
 Gerrit <https://review.openstack.org/#/q/status:merged+project:openstack-dev/devstack,n,z>`__.
11
+
12
+%GIT_LOG%
... ...
@@ -1,35 +1,19 @@
1 1
 #!/usr/bin/env bash
2 2
 
3
-# **build_docs.sh** - Build the gh-pages docs for DevStack
3
+# **build_docs.sh** - Build the docs for DevStack
4 4
 #
5 5
 # - Install shocco if not found on PATH and INSTALL_SHOCCO is set
6 6
 # - Clone MASTER_REPO branch MASTER_BRANCH
7 7
 # - Re-creates ``doc/build/html`` directory from existing repo + new generated script docs
8 8
 
9 9
 # Usage:
10
-## build_docs.sh [-o <out-dir>] [-g] [master|<repo> [<branch>]]
11
-## <repo>           The DevStack repository to clone (default is DevStack github repo)
12
-##                  If a repo is not supplied use the current directory
13
-##                  (assumed to be a DevStack checkout) as the source.
14
-## <branch>         The DevStack branch to check out (default is master; ignored if
15
-##                  repo is not specified)
16
-## .                Use the current repo and branch (do not use with -p to
17
-##                  prevent stray files in the workspace being added tot he docs)
10
+## build_docs.sh [-o <out-dir>]
18 11
 ## -o <out-dir>     Write the static HTML output to <out-dir>
19 12
 ##                  (Note that <out-dir> will be deleted and re-created to ensure it is clean)
20
-## -g               Update the old gh-pages repo  (set PUSH=1 to actually push up to RCB)
21 13
 
22 14
 # Defaults
23 15
 # --------
24 16
 
25
-# Source repo/branch for DevStack
26
-MASTER_REPO=${MASTER_REPO:-git://git.openstack.org/openstack-dev/devstack}
27
-MASTER_BRANCH=${MASTER_BRANCH:-master}
28
-
29
-# http://devstack.org is a GitHub gh-pages site in the https://github.com/cloudbuilders/devtack.git repo
30
-GH_PAGES_REPO=git@github.com:cloudbuilders/devstack.git
31
-
32
-DOCS_SOURCE=doc/source
33 17
 HTML_BUILD=doc/build/html
34 18
 
35 19
 # Keep track of the devstack directory
... ...
@@ -60,10 +44,8 @@ if ! which shocco; then
60 60
 fi
61 61
 
62 62
 # Process command-line args
63
-while getopts go: c; do
63
+while getopts o: c; do
64 64
     case $c in
65
-        g)  GH_UPDATE=1
66
-            ;;
67 65
         o)  HTML_BUILD=$OPTARG
68 66
             ;;
69 67
     esac
... ...
@@ -71,55 +53,24 @@ done
71 71
 shift `expr $OPTIND - 1`
72 72
 
73 73
 
74
-if [[ -n "$1" ]]; then
75
-    master="master"
76
-    if [[ "${master/#$1}" != "master" ]]; then
77
-        # Partial match on "master"
78
-        REPO=$MASTER_REPO
79
-    else
80
-        REPO=$1
81
-    fi
82
-    REPO_BRANCH=${2:-$MASTER_BRANCH}
83
-fi
84
-
85
-# Check out a specific DevStack branch
86
-if [[ -n $REPO ]]; then
87
-    # Make a workspace
88
-    TMP_ROOT=$(mktemp -d work-docs-XXXX)
89
-    echo "Building docs in $TMP_ROOT"
90
-    cd $TMP_ROOT
91
-
92
-    # Get the master branch
93
-    git clone $REPO devstack
94
-    cd devstack
95
-    if [[ -n "$REPO_BRANCH" ]]; then
96
-        git checkout $REPO_BRANCH
97
-    fi
98
-fi
99
-
100
-# Assumption is we are now in the DevStack workspace to be processed
101
-
102 74
 # Processing
103 75
 # ----------
104 76
 
105
-# Clean up build dir
106
-rm -rf $HTML_BUILD
77
+# Ensure build dir exists
107 78
 mkdir -p $HTML_BUILD
108 79
 
109 80
 # Get fully qualified dirs
110
-FQ_DOCS_SOURCE=$(cd $DOCS_SOURCE && pwd)
111 81
 FQ_HTML_BUILD=$(cd $HTML_BUILD && pwd)
112 82
 
113
-# Get repo static
114
-cp -pr $FQ_DOCS_SOURCE/* $FQ_HTML_BUILD
115
-
116 83
 # Insert automated bits
117 84
 GLOG=$(mktemp gitlogXXXX)
85
+echo "<ul>" >$GLOG
118 86
 git log \
119 87
     --pretty=format:'            <li>%s - <em>Commit <a href="https://review.openstack.org/#q,%h,n,z">%h</a> %cd</em></li>' \
120 88
     --date=short \
121
-    --since '6 months ago' | grep -v Merge >$GLOG
122
-sed -e $"/%GIT_LOG%/r $GLOG" $FQ_DOCS_SOURCE/changes.html >$FQ_HTML_BUILD/changes.html
89
+    --since '6 months ago' | grep -v Merge >>$GLOG
90
+echo "</ul>" >>$GLOG
91
+sed -i~ -e $"/^.*%GIT_LOG%.*$/r $GLOG" -e $"/^.*%GIT_LOG%.*$/s/^.*%GIT_LOG%.*$//" $FQ_HTML_BUILD/changes.html
123 92
 rm -f $GLOG
124 93
 
125 94
 # Build list of scripts to process
... ...
@@ -138,28 +89,6 @@ for f in $(find functions functions-common lib samples -type f -name \*); do
138 138
 done
139 139
 echo "$FILES" >doc/files
140 140
 
141
-if [[ -n $GH_UPDATE ]]; then
142
-    GH_ROOT=$(mktemp -d work-gh-XXXX)
143
-    cd $GH_ROOT
144
-
145
-    # Pull the latest docs branch from devstack.org repo
146
-    git clone -b gh-pages $GH_PAGES_REPO gh-docs
147
-
148
-    # Get the generated files
149
-    cp -pr $FQ_HTML_BUILD/* gh-docs
150
-
151
-    # Collect the new generated pages
152
-    (cd gh-docs; find . -name \*.html -print0 | xargs -0 git add)
153
-
154
-    # Push our changes back up to the docs branch
155
-    if ! git diff-index HEAD --quiet; then
156
-        git commit -a -m "Update script docs"
157
-        if [[ -n $PUSH ]]; then
158
-            git push
159
-        fi
160
-    fi
161
-fi
162
-
163 141
 # Clean up or report the temp workspace
164 142
 if [[ -n REPO && -n $PUSH_REPO ]]; then
165 143
     echo rm -rf $TMP_ROOT
... ...
@@ -36,5 +36,5 @@ setenv =
36 36
   TOP_DIR={toxinidir}
37 37
   INSTALL_SHOCCO=true
38 38
 commands = 
39
-	bash tools/build_docs.sh
40 39
 	python setup.py build_sphinx
40
+	bash tools/build_docs.sh