blob: f573fd79e7cb1a58be4699e779accf398bd1ec51 [file] [log] [blame]
epoger@google.comb0c5e072011-12-06 14:52:38 +00001#!/bin/bash
2#
epoger@google.com338ef652011-12-07 18:52:40 +00003# Runs doxygen and stores its results in the skia-autogen repo, so that they
4# can be browsed at http://skia-autogen.googlecode.com/svn/docs/html/index.html
rmistry@google.combcf0c522012-07-09 20:53:03 +00005#
6# The DOXYGEN_TEMPDIR env variable is the working directory within which we will
7# check out the code, generate documentation, and store the doxygen log
8# (by default, /tmp/skia-doxygen). The DOXYGEN_COMMIT env variable determines
9# whether docs should be commited (true by default).
10#
11# Sample Usage:
12# export DOXYGEN_TEMPDIR=/tmp/doxygen
13# export DOXYGEN_COMMIT=false
14# bash update-doxygen.sh
epoger@google.comb0c5e072011-12-06 14:52:38 +000015
16# Prepare a temporary dir and check out Skia trunk and docs.
17cd
rmistry@google.combcf0c522012-07-09 20:53:03 +000018DOXYGEN_TEMPDIR=${DOXYGEN_TEMPDIR:-/tmp/skia-doxygen}
19DOXYGEN_COMMIT=${DOXYGEN_COMMIT:-true}
20
rmistry@google.combcf0c522012-07-09 20:53:03 +000021mkdir -p $DOXYGEN_TEMPDIR
22cd $DOXYGEN_TEMPDIR
rmistry@google.coma8a977a2012-07-17 18:27:03 +000023
24if [ -d "trunk" ]; then
25 svn update --accept theirs-full trunk
26else
27 svn checkout http://skia.googlecode.com/svn/trunk # read-only
28fi
29if [ -d "docs" ]; then
30 svn update --accept theirs-full docs
31else
32 svn checkout https://skia-autogen.googlecode.com/svn/docs # writeable
borenet@google.com72e34032012-09-26 16:09:43 +000033if [ ! -f "docs/static_footer.txt" ]; then
34 TOOLS_DIR="$(cd "$(dirname "$0" )" && pwd )"
35 cp ${TOOLS_DIR}/doxygen_footer.txt docs/static_footer.txt
36fi
rmistry@google.coma8a977a2012-07-17 18:27:03 +000037fi
epoger@google.comb0c5e072011-12-06 14:52:38 +000038
39# Run Doxygen.
40cd trunk
41doxygen Doxyfile
rmistry@google.com00324072012-08-24 17:16:05 +000042ret_code=$?
43if [ $ret_code != 0 ]; then
44 echo "Error while executing Doxygen command"
45 exit $ret_code
46fi
47
epoger@google.comb0c5e072011-12-06 14:52:38 +000048cd ../docs
49
50# Add any newly created files to Subversion.
51NEWFILES=$(svn status | grep ^\? | awk '{print $2}')
52if [ -n "$NEWFILES" ]; then
53 svn add $NEWFILES
54fi
55
56# We haven't updated the timestamp footer yet... if there are no changes
57# yet, just exit. (We'll wait until there are any actual doc changes before
58# updating the timestamp and committing changes to the repository.)
59MODFILES=$(svn status | grep ^[AM])
60if [ -z "$MODFILES" ]; then
61 echo "No documentation updates, exiting early."
62 exit 0
63fi
64
65# Update the timestamp footer.
66cat >iframe_footer.html <<EOF
67<html><body>
68<address style="text-align: right;"><small>
69Generated on $(date) for skia by
70<a href="http://www.doxygen.org/index.html">doxygen</a>
71$(doxygen --version) </small></address>
72</body></html>
73EOF
74
75# Make sure that all files have the correct mimetype.
epoger@google.com338ef652011-12-07 18:52:40 +000076find . -name '*.html' -exec svn propset svn:mime-type text/html '{}' \;
77find . -name '*.css' -exec svn propset svn:mime-type text/css '{}' \;
78find . -name '*.js' -exec svn propset svn:mime-type text/javascript '{}' \;
79find . -name '*.gif' -exec svn propset svn:mime-type image/gif '{}' \;
80find . -name '*.png' -exec svn propset svn:mime-type image/png '{}' \;
epoger@google.comb0c5e072011-12-06 14:52:38 +000081
rmistry@google.combcf0c522012-07-09 20:53:03 +000082# Output files with documentation updates.
83echo -e "\n\nThe following are the documentation updates:"
84echo $MODFILES
85
86if $DOXYGEN_COMMIT ; then
87 # Commit the updated docs to the subversion repo.
88 svn commit --message 'commit doxygen-generated documentation'
89fi