BGE: KX_PhysicsObjectWrapper was not being used anywhere in the code base, but it...
[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 DO_EXE_BLENDER=true
13 DO_OUT_HTML=true
14 DO_OUT_HTML_ZIP=true
15 DO_OUT_PDF=false
16
17
18 BLENDER="./blender.bin"
19 SSH_USER="ideasman42"
20 SSH_HOST=$SSH_USER"@emo.blender.org"
21 SSH_UPLOAD="/data/www/vhosts/www.blender.org/documentation" # blender_python_api_VERSION, added after
22
23 # ----------------------------------------------------------------------------
24 # Blender Version & Info
25
26 # 'Blender 2.53 (sub 1) Build' --> '2_53_1' as a shell script.
27 # "_".join(str(v) for v in bpy.app.version)
28 # custom blender vars
29 blender_srcdir=$(dirname $0)/../../
30 blender_version=$(grep "BLENDER_VERSION\s" $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}')
31 blender_version_char=$(grep BLENDER_VERSION_CHAR $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}')
32 blender_version_cycle=$(grep BLENDER_VERSION_CYCLE $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}')
33 blender_subversion=$(grep BLENDER_SUBVERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}')
34
35 if [ "$blender_version_cycle" == "release" ]
36 then
37         BLENDER_VERSION=$(expr $blender_version / 100)_$(expr $blender_version % 100)$blender_version_char"_release"
38 else
39         BLENDER_VERSION=$(expr $blender_version / 100)_$(expr $blender_version % 100)_$blender_subversion
40 fi
41
42 SSH_UPLOAD_FULL=$SSH_UPLOAD/"blender_python_api_"$BLENDER_VERSION
43
44 SPHINXBASE=doc/python_api
45
46
47 # ----------------------------------------------------------------------------
48 # Generate reStructuredText (blender/python only)
49
50 if $DO_EXE_BLENDER ; then
51         # dont delete existing docs, now partial updates are used for quick builds.
52         $BLENDER --background -noaudio --factory-startup --python $SPHINXBASE/sphinx_doc_gen.py
53 fi
54
55
56 # ----------------------------------------------------------------------------
57 # Generate HTML (sphinx)
58
59 if $DO_OUT_HTML ; then
60         # sphinx-build -n -b html $SPHINXBASE/sphinx-in $SPHINXBASE/sphinx-out
61
62         # annoying bug in sphinx makes it very slow unless we do this. should report.
63         cd $SPHINXBASE
64         sphinx-build -b html sphinx-in sphinx-out
65
66         # XXX, saves space on upload and zip, should move HTML outside
67         # and zip up there, for now this is OK
68         rm -rf sphinx-out/.doctrees
69
70         # incase we have a zip already
71         rm -f blender_python_reference_$BLENDER_VERSION.zip
72
73         # ------------------------------------------------------------------------
74         # ZIP the HTML dir for upload
75
76         if $DO_OUT_HTML_ZIP ; then
77                 # lame, temp rename dir
78                 mv sphinx-out blender_python_reference_$BLENDER_VERSION
79                 zip -r -9 blender_python_reference_$BLENDER_VERSION.zip blender_python_reference_$BLENDER_VERSION
80                 mv blender_python_reference_$BLENDER_VERSION sphinx-out
81         fi
82
83         cd -
84 fi
85
86
87 # ----------------------------------------------------------------------------
88 # Generate PDF (sphinx/laytex)
89
90 if $DO_OUT_PDF ; then
91         sphinx-build -n -b latex $SPHINXBASE/sphinx-in $SPHINXBASE/sphinx-out
92         make -C $SPHINXBASE/sphinx-out
93         mv $SPHINXBASE/sphinx-out/contents.pdf $SPHINXBASE/sphinx-out/blender_python_reference_$BLENDER_VERSION.pdf
94 fi
95
96
97 # ----------------------------------------------------------------------------
98 # Upload to blender servers, comment this section for testing
99
100 if $DO_UPLOAD ; then
101
102         cp $SPHINXBASE/sphinx-out/contents.html $SPHINXBASE/sphinx-out/index.html
103         ssh $SSH_USER@emo.blender.org 'rm -rf '$SSH_UPLOAD_FULL'/*'
104         rsync --progress -avze "ssh -p 22" $SPHINXBASE/sphinx-out/* $SSH_HOST:$SSH_UPLOAD_FULL/
105
106         ## symlink the dir to a static URL
107         #ssh $SSH_USER@emo.blender.org 'rm '$SSH_UPLOAD'/250PythonDoc && ln -s '$SSH_UPLOAD_FULL' '$SSH_UPLOAD'/250PythonDoc'
108
109         # better redirect
110         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'
111
112         if $DO_OUT_PDF ; then
113                 # rename so local PDF has matching name.
114                 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
115         fi
116
117         if $DO_OUT_HTML_ZIP ; then
118                 rsync --progress -avze "ssh -p 22" $SPHINXBASE/blender_python_reference_$BLENDER_VERSION.zip $SSH_HOST:$SSH_UPLOAD_FULL/blender_python_reference_$BLENDER_VERSION.zip
119         fi
120
121 fi
122
123
124 # ----------------------------------------------------------------------------
125 # Print some useful text
126
127 echo ""
128 echo "Finished! view the docs from: "
129 if $DO_OUT_HTML ; then echo "  html:" $SPHINXBASE/sphinx-out/contents.html ; fi
130 if $DO_OUT_PDF ; then  echo "   pdf:" $SPHINXBASE/sphinx-out/blender_python_reference_$BLENDER_VERSION.pdf ; fi