epoger@google.com | b0c5e07 | 2011-12-06 14:52:38 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
epoger@google.com | 338ef65 | 2011-12-07 18:52:40 +0000 | [diff] [blame] | 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 |
rmistry@google.com | bcf0c52 | 2012-07-09 20:53:03 +0000 | [diff] [blame] | 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 |
epoger@google.com | b0c5e07 | 2011-12-06 14:52:38 +0000 | [diff] [blame] | 15 | |
rmistry@google.com | 8fc729f | 2013-05-01 14:47:03 +0000 | [diff] [blame] | 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 | |
epoger@google.com | b0c5e07 | 2011-12-06 14:52:38 +0000 | [diff] [blame] | 26 | # Prepare a temporary dir and check out Skia trunk and docs. |
| 27 | cd |
rmistry@google.com | bcf0c52 | 2012-07-09 20:53:03 +0000 | [diff] [blame] | 28 | DOXYGEN_TEMPDIR=${DOXYGEN_TEMPDIR:-/tmp/skia-doxygen} |
| 29 | DOXYGEN_COMMIT=${DOXYGEN_COMMIT:-true} |
| 30 | |
rmistry@google.com | bcf0c52 | 2012-07-09 20:53:03 +0000 | [diff] [blame] | 31 | mkdir -p $DOXYGEN_TEMPDIR |
| 32 | cd $DOXYGEN_TEMPDIR |
rmistry@google.com | a8a977a | 2012-07-17 18:27:03 +0000 | [diff] [blame] | 33 | |
borenet@google.com | 6f0f5b4 | 2014-01-09 21:41:39 +0000 | [diff] [blame] | 34 | if [ -d "skia" ]; then |
| 35 | pushd skia |
| 36 | git pull |
| 37 | git checkout origin/master |
| 38 | popd |
rmistry@google.com | a8a977a | 2012-07-17 18:27:03 +0000 | [diff] [blame] | 39 | else |
borenet@google.com | 6f0f5b4 | 2014-01-09 21:41:39 +0000 | [diff] [blame] | 40 | git clone https://skia.googlesource.com/skia.git |
rmistry@google.com | a8a977a | 2012-07-17 18:27:03 +0000 | [diff] [blame] | 41 | fi |
| 42 | if [ -d "docs" ]; then |
| 43 | svn update --accept theirs-full docs |
rmistry@google.com | 8fc729f | 2013-05-01 14:47:03 +0000 | [diff] [blame] | 44 | 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.com | a8a977a | 2012-07-17 18:27:03 +0000 | [diff] [blame] | 51 | else |
rmistry@google.com | 8fc729f | 2013-05-01 14:47:03 +0000 | [diff] [blame] | 52 | check_out_docs |
| 53 | fi |
| 54 | |
borenet@google.com | 72e3403 | 2012-09-26 16:09:43 +0000 | [diff] [blame] | 55 | if [ ! -f "docs/static_footer.txt" ]; then |
borenet@google.com | 6f0f5b4 | 2014-01-09 21:41:39 +0000 | [diff] [blame] | 56 | cp skia/tools/doxygen_footer.txt docs/static_footer.txt |
borenet@google.com | 72e3403 | 2012-09-26 16:09:43 +0000 | [diff] [blame] | 57 | fi |
epoger@google.com | b0c5e07 | 2011-12-06 14:52:38 +0000 | [diff] [blame] | 58 | |
| 59 | # Run Doxygen. |
borenet@google.com | 6f0f5b4 | 2014-01-09 21:41:39 +0000 | [diff] [blame] | 60 | cd skia |
epoger@google.com | b0c5e07 | 2011-12-06 14:52:38 +0000 | [diff] [blame] | 61 | doxygen Doxyfile |
rmistry@google.com | 0032407 | 2012-08-24 17:16:05 +0000 | [diff] [blame] | 62 | ret_code=$? |
| 63 | if [ $ret_code != 0 ]; then |
| 64 | echo "Error while executing Doxygen command" |
| 65 | exit $ret_code |
| 66 | fi |
| 67 | |
epoger@google.com | b0c5e07 | 2011-12-06 14:52:38 +0000 | [diff] [blame] | 68 | cd ../docs |
| 69 | |
| 70 | # Add any newly created files to Subversion. |
| 71 | NEWFILES=$(svn status | grep ^\? | awk '{print $2}') |
| 72 | if [ -n "$NEWFILES" ]; then |
| 73 | svn add $NEWFILES |
| 74 | fi |
| 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.) |
| 79 | MODFILES=$(svn status | grep ^[AM]) |
| 80 | if [ -z "$MODFILES" ]; then |
| 81 | echo "No documentation updates, exiting early." |
| 82 | exit 0 |
| 83 | fi |
| 84 | |
| 85 | # Update the timestamp footer. |
| 86 | cat >iframe_footer.html <<EOF |
| 87 | <html><body> |
| 88 | <address style="text-align: right;"><small> |
| 89 | Generated on $(date) for skia by |
| 90 | <a href="http://www.doxygen.org/index.html">doxygen</a> |
| 91 | $(doxygen --version) </small></address> |
| 92 | </body></html> |
| 93 | EOF |
| 94 | |
| 95 | # Make sure that all files have the correct mimetype. |
epoger@google.com | 338ef65 | 2011-12-07 18:52:40 +0000 | [diff] [blame] | 96 | find . -name '*.html' -exec svn propset svn:mime-type text/html '{}' \; |
| 97 | find . -name '*.css' -exec svn propset svn:mime-type text/css '{}' \; |
| 98 | find . -name '*.js' -exec svn propset svn:mime-type text/javascript '{}' \; |
| 99 | find . -name '*.gif' -exec svn propset svn:mime-type image/gif '{}' \; |
| 100 | find . -name '*.png' -exec svn propset svn:mime-type image/png '{}' \; |
epoger@google.com | b0c5e07 | 2011-12-06 14:52:38 +0000 | [diff] [blame] | 101 | |
rmistry@google.com | bcf0c52 | 2012-07-09 20:53:03 +0000 | [diff] [blame] | 102 | # Output files with documentation updates. |
| 103 | echo -e "\n\nThe following are the documentation updates:" |
| 104 | echo $MODFILES |
| 105 | |
| 106 | if $DOXYGEN_COMMIT ; then |
| 107 | # Commit the updated docs to the subversion repo. |
| 108 | svn commit --message 'commit doxygen-generated documentation' |
| 109 | fi |