blob: 348f98fbbf3a19511a9e8c915f15b4f2d15a4c1b [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
rmistry@google.com8fc729f2013-05-01 14:47:03 +000016function check_out_docs {
17 svn checkout https://skia-autogen.googlecode.com/svn/docs # writeable
18 ret_code=$?
19 if [ $ret_code != 0 ]; then
20 # docs directory does not exist, skia-autogen must have been reset.
21 # Create a non svn docs directory instead.
22 mkdir docs
23 fi
24}
25
epoger@google.comb0c5e072011-12-06 14:52:38 +000026# Prepare a temporary dir and check out Skia trunk and docs.
27cd
rmistry@google.combcf0c522012-07-09 20:53:03 +000028DOXYGEN_TEMPDIR=${DOXYGEN_TEMPDIR:-/tmp/skia-doxygen}
29DOXYGEN_COMMIT=${DOXYGEN_COMMIT:-true}
30
rmistry@google.combcf0c522012-07-09 20:53:03 +000031mkdir -p $DOXYGEN_TEMPDIR
32cd $DOXYGEN_TEMPDIR
rmistry@google.coma8a977a2012-07-17 18:27:03 +000033
34if [ -d "trunk" ]; then
35 svn update --accept theirs-full trunk
36else
37 svn checkout http://skia.googlecode.com/svn/trunk # read-only
38fi
39if [ -d "docs" ]; then
40 svn update --accept theirs-full docs
rmistry@google.com8fc729f2013-05-01 14:47:03 +000041 svn info docs
42 ret_code=$?
43 if [ $ret_code != 0 ]; then
44 # This is not a valid SVN checkout.
45 rm -rf docs
46 check_out_docs
47 fi
rmistry@google.coma8a977a2012-07-17 18:27:03 +000048else
rmistry@google.com8fc729f2013-05-01 14:47:03 +000049 check_out_docs
50fi
51
borenet@google.com72e34032012-09-26 16:09:43 +000052if [ ! -f "docs/static_footer.txt" ]; then
borenet@google.com71f0f8e2012-09-26 16:25:22 +000053 cp trunk/tools/doxygen_footer.txt docs/static_footer.txt
borenet@google.com72e34032012-09-26 16:09:43 +000054fi
epoger@google.comb0c5e072011-12-06 14:52:38 +000055
56# Run Doxygen.
57cd trunk
58doxygen Doxyfile
rmistry@google.com00324072012-08-24 17:16:05 +000059ret_code=$?
60if [ $ret_code != 0 ]; then
61 echo "Error while executing Doxygen command"
62 exit $ret_code
63fi
64
epoger@google.comb0c5e072011-12-06 14:52:38 +000065cd ../docs
66
67# Add any newly created files to Subversion.
68NEWFILES=$(svn status | grep ^\? | awk '{print $2}')
69if [ -n "$NEWFILES" ]; then
70 svn add $NEWFILES
71fi
72
73# We haven't updated the timestamp footer yet... if there are no changes
74# yet, just exit. (We'll wait until there are any actual doc changes before
75# updating the timestamp and committing changes to the repository.)
76MODFILES=$(svn status | grep ^[AM])
77if [ -z "$MODFILES" ]; then
78 echo "No documentation updates, exiting early."
79 exit 0
80fi
81
82# Update the timestamp footer.
83cat >iframe_footer.html <<EOF
84<html><body>
85<address style="text-align: right;"><small>
86Generated on $(date) for skia by
87<a href="http://www.doxygen.org/index.html">doxygen</a>
88$(doxygen --version) </small></address>
89</body></html>
90EOF
91
92# Make sure that all files have the correct mimetype.
epoger@google.com338ef652011-12-07 18:52:40 +000093find . -name '*.html' -exec svn propset svn:mime-type text/html '{}' \;
94find . -name '*.css' -exec svn propset svn:mime-type text/css '{}' \;
95find . -name '*.js' -exec svn propset svn:mime-type text/javascript '{}' \;
96find . -name '*.gif' -exec svn propset svn:mime-type image/gif '{}' \;
97find . -name '*.png' -exec svn propset svn:mime-type image/png '{}' \;
epoger@google.comb0c5e072011-12-06 14:52:38 +000098
rmistry@google.combcf0c522012-07-09 20:53:03 +000099# Output files with documentation updates.
100echo -e "\n\nThe following are the documentation updates:"
101echo $MODFILES
102
103if $DOXYGEN_COMMIT ; then
104 # Commit the updated docs to the subversion repo.
105 svn commit --message 'commit doxygen-generated documentation'
106fi