SVN maintenance.
[blender.git] / doc / python_api / sphinx_doc_gen.sh
1 #!/bin/sh
2 # run from the blender source dir
3 #   bash source/blender/python/doc/sphinx_doc_gen.sh
4 # ssh upload means you need an account on the server
5
6
7 # ----------------------------------------------------------------------------
8 # Upload vars
9
10 # disable for testing
11 DO_UPLOAD=true
12
13 BLENDER="./blender.bin"
14 SSH_USER="ideasman42"
15 SSH_HOST=$SSH_USER"@emo.blender.org"
16 SSH_UPLOAD="/data/www/vhosts/www.blender.org/documentation" # blender_python_api_VERSION, added after
17
18 # ----------------------------------------------------------------------------
19 # Blender Version & Info
20
21 # 'Blender 2.53 (sub 1) Build' --> '2_53_1' as a shell script.
22 # "_".join(str(v) for v in bpy.app.version)
23 # custom blender vars
24 blender_srcdir=$(dirname $0)/../../
25 blender_version=$(grep "BLENDER_VERSION\s" $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}')
26 blender_version_char=$(grep BLENDER_VERSION_CHAR $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}')
27 blender_version_cycle=$(grep BLENDER_VERSION_CYCLE $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}')
28 blender_subversion=$(grep BLENDER_SUBVERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}')
29
30 if [ "$blender_version_cycle" == "release" ]
31 then
32         BLENDER_VERSION=$(expr $blender_version / 100)_$(expr $blender_version % 100)$blender_version_char"_release"
33 else
34         BLENDER_VERSION=$(expr $blender_version / 100)_$(expr $blender_version % 100)_$blender_subversion
35 fi
36
37 SSH_UPLOAD_FULL=$SSH_UPLOAD/"blender_python_api_"$BLENDER_VERSION
38
39 SPHINXBASE=doc/python_api/
40
41
42 # ----------------------------------------------------------------------------
43 # Generate reStructuredText (blender/python only)
44
45 # dont delete existing docs, now partial updates are used for quick builds.
46 $BLENDER --background --factory-startup --python $SPHINXBASE/sphinx_doc_gen.py
47
48
49 # ----------------------------------------------------------------------------
50 # Generate HTML (sphinx)
51
52 sphinx-build -n -b html $SPHINXBASE/sphinx-in $SPHINXBASE/sphinx-out
53
54
55 # ----------------------------------------------------------------------------
56 # Generate PDF (sphinx/laytex)
57
58 sphinx-build -n -b latex $SPHINXBASE/sphinx-in $SPHINXBASE/sphinx-out
59 make -C $SPHINXBASE/sphinx-out
60 mv $SPHINXBASE/sphinx-out/contents.pdf $SPHINXBASE/sphinx-out/blender_python_reference_$BLENDER_VERSION.pdf
61
62 # ----------------------------------------------------------------------------
63 # Upload to blender servers, comment this section for testing
64
65 if $DO_UPLOAD ; then
66
67         cp $SPHINXBASE/sphinx-out/contents.html $SPHINXBASE/sphinx-out/index.html
68         ssh $SSH_USER@emo.blender.org 'rm -rf '$SSH_UPLOAD_FULL'/*'
69         rsync --progress -avze "ssh -p 22" $SPHINXBASE/sphinx-out/* $SSH_HOST:$SSH_UPLOAD_FULL/
70
71         ## symlink the dir to a static URL
72         #ssh $SSH_USER@emo.blender.org 'rm '$SSH_UPLOAD'/250PythonDoc && ln -s '$SSH_UPLOAD_FULL' '$SSH_UPLOAD'/250PythonDoc'
73
74         # better redirect
75         ssh $SSH_USER@emo.blender.org 'echo "<html><head><title>Redirecting...</title><meta http-equiv=\"REFRESH\" content=\"0;url=../blender_python_api_'$BLENDER_VERSION'/\"></head><body>Redirecting...</body></html>" > '$SSH_UPLOAD'/250PythonDoc/index.html'
76
77         # rename so local PDF has matching name.
78         rsync --progress -avze "ssh -p 22" $SPHINXBASE/sphinx-out/blender_python_reference_$BLENDER_VERSION.pdf $SSH_HOST:$SSH_UPLOAD_FULL/blender_python_reference_$BLENDER_VERSION.pdf
79
80 fi
81
82
83 # ----------------------------------------------------------------------------
84 # Print some useful text
85
86 echo ""
87 echo "Finished! view the docs from: "
88 echo "  html:" $SPHINXBASE/sphinx-out/contents.html
89 echo "   pdf:" $SPHINXBASE/sphinx-out/blender_python_reference_$BLENDER_VERSION.pdf