利用者:Mindrones/Python/API/Sphinx-build.sh

提供: wiki
< 利用者:Mindrones‎ | Python‎ | API
2012年2月22日 (水) 03:26時点におけるwiki>Mindronesによる版 (moved User:Mindrones/Python/API/Sphinx-build to User:Mindrones/Python/API/Sphinx-build.sh)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

This is needed when developing the theme with Alex, we exchange things in https://svn.blender.org/svnroot/blend-doc/ and when ok he pushes in https://svn.blender.org/svnroot/bf-blender/trunk/blender/

sphinx-build.sh

#! /bin/sh
#
# This script assumes that you have a directories setup as below.
#
# $ROOT/
#   blender/    <-- blender source code
#       doc/
#           python_api/
#               sphinx-build    <-- ./ (run this script from here)
#   blender-doc/        <-- development files for sphinx
#   cmake
#       bin/
#           blender     <-- blender exe built with cmake
#   scons/
#       bin/
#           blender     <-- blender exe built with scons
#   doc/
#       python_api/     <-- this script builds the doc here

#`basename $0`
#`dirname $0`

SCRIPTDIR=`dirname $(readlink -f $0)`
ROOT=`readlink -f $SCRIPTDIR/../../../`
APIDOC="$ROOT/doc/python_api"
BLENDDOC="$ROOT/blend-doc/trunk/python/doc"
BLENDERBIN="$ROOT/cmake/bin/blender"

echo
echo "Setting up..."
echo

echo "mkdir -p $APIDOC"
mkdir -p $APIDOC

if [ ! $1 ]; then
    SPHINXIN="sphinx-in"
    SPHINXINTMP="sphinx-in-tmp"
    SPHINXOUT="sphinx-out"
else
    SPHINXIN="devel-sphinx-in"
    SPHINXINTMP="devel-sphinx-in-tmp"
    SPHINXOUT="devel-sphinx-out"
    if [ ! -d $BLENDDOC ]; then
        echo "mkdir -p $BLENDDOC"
        mkdir -p $BLENDDOC
        echo "svn co https://svn.blender.org/svnroot/blend-doc/trunk/python/doc/ $BLENDDOC"
        svn co https://svn.blender.org/svnroot/blend-doc/trunk/python/doc/ $BLENDDOC
    fi
fi

echo
echo "Generating rst files with sphinx_doc_gen.py..."
echo

if [ -d $APIDOC/$SPHINXINTMP ]; then
    echo "cp -rf $APIDOC/$SPHINXINTMP sphinx-in-tmp"
    cp -rf $APIDOC/$SPHINXINTMP sphinx-in-tmp
fi

$BLENDERBIN -b -P $SCRIPTDIR/sphinx_doc_gen.py


echo "rm -rf $APIDOC/$SPHINXIN"
rm -rf $APIDOC/$SPHINXIN
echo "mv $SCRIPTDIR/sphinx-in $APIDOC/$SPHINXIN"
mv $SCRIPTDIR/sphinx-in $APIDOC/$SPHINXIN

echo "rm -rf $APIDOC/$SPHINXINTMP"
rm -rf $APIDOC/$SPHINXINTMP
echo "mv $SCRIPTDIR/sphinx-in-tmp $APIDOC/$SPHINXINTMP"
mv $SCRIPTDIR/sphinx-in-tmp $APIDOC/$SPHINXINTMP

echo
echo "...done generating rst files in $APIDOC"
echo

if [ ! $1 ]; then
    BLENDERORG=$SCRIPTDIR/blender-org
else
    BLENDERORG=$BLENDDOC/blender-org
fi

echo
echo "Updating svn in $BLENDERORG..."
echo
svn up $BLENDERORG
svn log $BLENDERORG --limit 4

pushd $APIDOC
    echo
    echo "Symlinking blender-org -> $BLENDERORG"
    echo
    ln -snf $BLENDERORG blender-org
    ln -snf $SCRIPTDIR/examples examples
    echo
    echo "Building html with Sphinx..."
    echo
    sphinx-build $SPHINXIN $SPHINXOUT
popd
    
echo
echo "Done building html sphinx doc in:"
echo "$APIDOC/$SPHINXOUT"
echo
echo "Open link: file://$APIDOC/$SPHINXOUT/contents.html"
echo