1 #!/bin/bash 2 # 3 # 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 5 # 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 15 16 function 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 26 # Prepare a temporary dir and check out Skia trunk and docs. 27 cd 28 DOXYGEN_TEMPDIR=${DOXYGEN_TEMPDIR:-/tmp/skia-doxygen} 29 DOXYGEN_COMMIT=${DOXYGEN_COMMIT:-true} 30 31 mkdir -p $DOXYGEN_TEMPDIR 32 cd $DOXYGEN_TEMPDIR 33 34 if [ -d "trunk" ]; then 35 svn update --accept theirs-full trunk 36 else 37 svn checkout http://skia.googlecode.com/svn/trunk # read-only 38 fi 39 if [ -d "docs" ]; then 40 svn update --accept theirs-full docs 41 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 48 else 49 check_out_docs 50 fi 51 52 if [ ! -f "docs/static_footer.txt" ]; then 53 cp trunk/tools/doxygen_footer.txt docs/static_footer.txt 54 fi 55 56 # Run Doxygen. 57 cd trunk 58 doxygen Doxyfile 59 ret_code=$? 60 if [ $ret_code != 0 ]; then 61 echo "Error while executing Doxygen command" 62 exit $ret_code 63 fi 64 65 cd ../docs 66 67 # Add any newly created files to Subversion. 68 NEWFILES=$(svn status | grep ^\? | awk '{print $2}') 69 if [ -n "$NEWFILES" ]; then 70 svn add $NEWFILES 71 fi 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.) 76 MODFILES=$(svn status | grep ^[AM]) 77 if [ -z "$MODFILES" ]; then 78 echo "No documentation updates, exiting early." 79 exit 0 80 fi 81 82 # Update the timestamp footer. 83 cat >iframe_footer.html <<EOF 84 <html><body> 85 <address style="text-align: right;"><small> 86 Generated on $(date) for skia by 87 <a href="http://www.doxygen.org/index.html">doxygen</a> 88 $(doxygen --version) </small></address> 89 </body></html> 90 EOF 91 92 # Make sure that all files have the correct mimetype. 93 find . -name '*.html' -exec svn propset svn:mime-type text/html '{}' \; 94 find . -name '*.css' -exec svn propset svn:mime-type text/css '{}' \; 95 find . -name '*.js' -exec svn propset svn:mime-type text/javascript '{}' \; 96 find . -name '*.gif' -exec svn propset svn:mime-type image/gif '{}' \; 97 find . -name '*.png' -exec svn propset svn:mime-type image/png '{}' \; 98 99 # Output files with documentation updates. 100 echo -e "\n\nThe following are the documentation updates:" 101 echo $MODFILES 102 103 if $DOXYGEN_COMMIT ; then 104 # Commit the updated docs to the subversion repo. 105 svn commit --message 'commit doxygen-generated documentation' 106 fi 107