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