Merge "Simplify docs build"
This commit is contained in:
commit
5853160c6e
@ -8,3 +8,5 @@ Recent Changes What's been happening?
|
|||||||
These are the commits to DevStack for the last six months. For the
|
These are the commits to DevStack for the last six months. For the
|
||||||
complete list see `the DevStack project in
|
complete list see `the DevStack project in
|
||||||
Gerrit <https://review.openstack.org/#/q/status:merged+project:openstack-dev/devstack,n,z>`__.
|
Gerrit <https://review.openstack.org/#/q/status:merged+project:openstack-dev/devstack,n,z>`__.
|
||||||
|
|
||||||
|
%GIT_LOG%
|
||||||
|
@ -1,35 +1,19 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# **build_docs.sh** - Build the gh-pages docs for DevStack
|
# **build_docs.sh** - Build the docs for DevStack
|
||||||
#
|
#
|
||||||
# - Install shocco if not found on PATH and INSTALL_SHOCCO is set
|
# - Install shocco if not found on PATH and INSTALL_SHOCCO is set
|
||||||
# - Clone MASTER_REPO branch MASTER_BRANCH
|
# - Clone MASTER_REPO branch MASTER_BRANCH
|
||||||
# - Re-creates ``doc/build/html`` directory from existing repo + new generated script docs
|
# - Re-creates ``doc/build/html`` directory from existing repo + new generated script docs
|
||||||
|
|
||||||
# Usage:
|
# Usage:
|
||||||
## build_docs.sh [-o <out-dir>] [-g] [master|<repo> [<branch>]]
|
## build_docs.sh [-o <out-dir>]
|
||||||
## <repo> The DevStack repository to clone (default is DevStack github repo)
|
|
||||||
## If a repo is not supplied use the current directory
|
|
||||||
## (assumed to be a DevStack checkout) as the source.
|
|
||||||
## <branch> The DevStack branch to check out (default is master; ignored if
|
|
||||||
## repo is not specified)
|
|
||||||
## . Use the current repo and branch (do not use with -p to
|
|
||||||
## prevent stray files in the workspace being added tot he docs)
|
|
||||||
## -o <out-dir> Write the static HTML output to <out-dir>
|
## -o <out-dir> Write the static HTML output to <out-dir>
|
||||||
## (Note that <out-dir> will be deleted and re-created to ensure it is clean)
|
## (Note that <out-dir> will be deleted and re-created to ensure it is clean)
|
||||||
## -g Update the old gh-pages repo (set PUSH=1 to actually push up to RCB)
|
|
||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
# --------
|
# --------
|
||||||
|
|
||||||
# Source repo/branch for DevStack
|
|
||||||
MASTER_REPO=${MASTER_REPO:-git://git.openstack.org/openstack-dev/devstack}
|
|
||||||
MASTER_BRANCH=${MASTER_BRANCH:-master}
|
|
||||||
|
|
||||||
# http://devstack.org is a GitHub gh-pages site in the https://github.com/cloudbuilders/devtack.git repo
|
|
||||||
GH_PAGES_REPO=git@github.com:cloudbuilders/devstack.git
|
|
||||||
|
|
||||||
DOCS_SOURCE=doc/source
|
|
||||||
HTML_BUILD=doc/build/html
|
HTML_BUILD=doc/build/html
|
||||||
|
|
||||||
# Keep track of the devstack directory
|
# Keep track of the devstack directory
|
||||||
@ -60,10 +44,8 @@ if ! which shocco; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Process command-line args
|
# Process command-line args
|
||||||
while getopts go: c; do
|
while getopts o: c; do
|
||||||
case $c in
|
case $c in
|
||||||
g) GH_UPDATE=1
|
|
||||||
;;
|
|
||||||
o) HTML_BUILD=$OPTARG
|
o) HTML_BUILD=$OPTARG
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -71,55 +53,24 @@ done
|
|||||||
shift `expr $OPTIND - 1`
|
shift `expr $OPTIND - 1`
|
||||||
|
|
||||||
|
|
||||||
if [[ -n "$1" ]]; then
|
|
||||||
master="master"
|
|
||||||
if [[ "${master/#$1}" != "master" ]]; then
|
|
||||||
# Partial match on "master"
|
|
||||||
REPO=$MASTER_REPO
|
|
||||||
else
|
|
||||||
REPO=$1
|
|
||||||
fi
|
|
||||||
REPO_BRANCH=${2:-$MASTER_BRANCH}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check out a specific DevStack branch
|
|
||||||
if [[ -n $REPO ]]; then
|
|
||||||
# Make a workspace
|
|
||||||
TMP_ROOT=$(mktemp -d work-docs-XXXX)
|
|
||||||
echo "Building docs in $TMP_ROOT"
|
|
||||||
cd $TMP_ROOT
|
|
||||||
|
|
||||||
# Get the master branch
|
|
||||||
git clone $REPO devstack
|
|
||||||
cd devstack
|
|
||||||
if [[ -n "$REPO_BRANCH" ]]; then
|
|
||||||
git checkout $REPO_BRANCH
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Assumption is we are now in the DevStack workspace to be processed
|
|
||||||
|
|
||||||
# Processing
|
# Processing
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
# Clean up build dir
|
# Ensure build dir exists
|
||||||
rm -rf $HTML_BUILD
|
|
||||||
mkdir -p $HTML_BUILD
|
mkdir -p $HTML_BUILD
|
||||||
|
|
||||||
# Get fully qualified dirs
|
# Get fully qualified dirs
|
||||||
FQ_DOCS_SOURCE=$(cd $DOCS_SOURCE && pwd)
|
|
||||||
FQ_HTML_BUILD=$(cd $HTML_BUILD && pwd)
|
FQ_HTML_BUILD=$(cd $HTML_BUILD && pwd)
|
||||||
|
|
||||||
# Get repo static
|
|
||||||
cp -pr $FQ_DOCS_SOURCE/* $FQ_HTML_BUILD
|
|
||||||
|
|
||||||
# Insert automated bits
|
# Insert automated bits
|
||||||
GLOG=$(mktemp gitlogXXXX)
|
GLOG=$(mktemp gitlogXXXX)
|
||||||
|
echo "<ul>" >$GLOG
|
||||||
git log \
|
git log \
|
||||||
--pretty=format:' <li>%s - <em>Commit <a href="https://review.openstack.org/#q,%h,n,z">%h</a> %cd</em></li>' \
|
--pretty=format:' <li>%s - <em>Commit <a href="https://review.openstack.org/#q,%h,n,z">%h</a> %cd</em></li>' \
|
||||||
--date=short \
|
--date=short \
|
||||||
--since '6 months ago' | grep -v Merge >$GLOG
|
--since '6 months ago' | grep -v Merge >>$GLOG
|
||||||
sed -e $"/%GIT_LOG%/r $GLOG" $FQ_DOCS_SOURCE/changes.html >$FQ_HTML_BUILD/changes.html
|
echo "</ul>" >>$GLOG
|
||||||
|
sed -i~ -e $"/^.*%GIT_LOG%.*$/r $GLOG" -e $"/^.*%GIT_LOG%.*$/s/^.*%GIT_LOG%.*$//" $FQ_HTML_BUILD/changes.html
|
||||||
rm -f $GLOG
|
rm -f $GLOG
|
||||||
|
|
||||||
# Build list of scripts to process
|
# Build list of scripts to process
|
||||||
@ -138,28 +89,6 @@ for f in $(find functions functions-common lib samples -type f -name \*); do
|
|||||||
done
|
done
|
||||||
echo "$FILES" >doc/files
|
echo "$FILES" >doc/files
|
||||||
|
|
||||||
if [[ -n $GH_UPDATE ]]; then
|
|
||||||
GH_ROOT=$(mktemp -d work-gh-XXXX)
|
|
||||||
cd $GH_ROOT
|
|
||||||
|
|
||||||
# Pull the latest docs branch from devstack.org repo
|
|
||||||
git clone -b gh-pages $GH_PAGES_REPO gh-docs
|
|
||||||
|
|
||||||
# Get the generated files
|
|
||||||
cp -pr $FQ_HTML_BUILD/* gh-docs
|
|
||||||
|
|
||||||
# Collect the new generated pages
|
|
||||||
(cd gh-docs; find . -name \*.html -print0 | xargs -0 git add)
|
|
||||||
|
|
||||||
# Push our changes back up to the docs branch
|
|
||||||
if ! git diff-index HEAD --quiet; then
|
|
||||||
git commit -a -m "Update script docs"
|
|
||||||
if [[ -n $PUSH ]]; then
|
|
||||||
git push
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Clean up or report the temp workspace
|
# Clean up or report the temp workspace
|
||||||
if [[ -n REPO && -n $PUSH_REPO ]]; then
|
if [[ -n REPO && -n $PUSH_REPO ]]; then
|
||||||
echo rm -rf $TMP_ROOT
|
echo rm -rf $TMP_ROOT
|
||||||
|
Loading…
Reference in New Issue
Block a user