blob: 87fee32759ef6860cf82ee4159df62edd1775e27 [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
borenet@google.com6f0f5b42014-01-09 21:41:39 +000034if [ -d "skia" ]; then
35 pushd skia
36 git pull
37 git checkout origin/master
38 popd
rmistry@google.coma8a977a2012-07-17 18:27:03 +000039else
borenet@google.com6f0f5b42014-01-09 21:41:39 +000040 git clone https://skia.googlesource.com/skia.git
rmistry@google.coma8a977a2012-07-17 18:27:03 +000041fi
42if [ -d "docs" ]; then
43 svn update --accept theirs-full docs
rmistry@google.com8fc729f2013-05-01 14:47:03 +000044 svn info docs
45 ret_code=$?
46 if [ $ret_code != 0 ]; then
47 # This is not a valid SVN checkout.
48 rm -rf docs
49 check_out_docs
50 fi
rmistry@google.coma8a977a2012-07-17 18:27:03 +000051else
rmistry@google.com8fc729f2013-05-01 14:47:03 +000052 check_out_docs
53fi
54
borenet@google.com72e34032012-09-26 16:09:43 +000055if [ ! -f "docs/static_footer.txt" ]; then
borenet@google.com6f0f5b42014-01-09 21:41:39 +000056 cp skia/tools/doxygen_footer.txt docs/static_footer.txt
borenet@google.com72e34032012-09-26 16:09:43 +000057fi
epoger@google.comb0c5e072011-12-06 14:52:38 +000058
59# Run Doxygen.
borenet@google.com6f0f5b42014-01-09 21:41:39 +000060cd skia
epoger@google.comb0c5e072011-12-06 14:52:38 +000061doxygen Doxyfile
rmistry@google.com00324072012-08-24 17:16:05 +000062ret_code=$?
63if [ $ret_code != 0 ]; then
64 echo "Error while executing Doxygen command"
65 exit $ret_code
66fi
67
epoger@google.comb0c5e072011-12-06 14:52:38 +000068cd ../docs
69
70# Add any newly created files to Subversion.
71NEWFILES=$(svn status | grep ^\? | awk '{print $2}')
72if [ -n "$NEWFILES" ]; then
73 svn add $NEWFILES
74fi
75
76# We haven't updated the timestamp footer yet... if there are no changes
77# yet, just exit. (We'll wait until there are any actual doc changes before
78# updating the timestamp and committing changes to the repository.)
79MODFILES=$(svn status | grep ^[AM])
80if [ -z "$MODFILES" ]; then
81 echo "No documentation updates, exiting early."
82 exit 0
83fi
84
85# Update the timestamp footer.
86cat >iframe_footer.html <<EOF
87<html><body>
88<address style="text-align: right;"><small>
89Generated on $(date) for skia by
90<a href="http://www.doxygen.org/index.html">doxygen</a>
91$(doxygen --version) </small></address>
92</body></html>
93EOF
94
95# Make sure that all files have the correct mimetype.
epoger@google.com338ef652011-12-07 18:52:40 +000096find . -name '*.html' -exec svn propset svn:mime-type text/html '{}' \;
97find . -name '*.css' -exec svn propset svn:mime-type text/css '{}' \;
98find . -name '*.js' -exec svn propset svn:mime-type text/javascript '{}' \;
99find . -name '*.gif' -exec svn propset svn:mime-type image/gif '{}' \;
100find . -name '*.png' -exec svn propset svn:mime-type image/png '{}' \;
epoger@google.comb0c5e072011-12-06 14:52:38 +0000101
rmistry@google.combcf0c522012-07-09 20:53:03 +0000102# Output files with documentation updates.
103echo -e "\n\nThe following are the documentation updates:"
104echo $MODFILES
105
106if $DOXYGEN_COMMIT ; then
107 # Commit the updated docs to the subversion repo.
108 svn commit --message 'commit doxygen-generated documentation'
109fi