regen.sh 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. #!/bin/bash
  2. #
  3. #
  4. # This bash script regenerates the HTML doxygen version of the
  5. # wxWidgets manual and adjusts the doxygen log to make it more
  6. # readable.
  7. #
  8. # Usage:
  9. # ./regen.sh [html|chm|xml|latex|all]
  10. #
  11. # Pass "x" to regen only the X output format and "all" to regen them all.
  12. # If no arguments are passed all formats are regenerated
  13. # (just like passing "all").
  14. #
  15. # remember current folder and then cd to the docs/doxygen one
  16. me=$(basename $0)
  17. path=${0%%/$me} # path from which the script has been launched
  18. current=$(pwd)
  19. cd $path
  20. if [[ -z "$WXWIDGETS" ]]; then
  21. # Notice the use of -P to ensure we get the canonical path even if there
  22. # are symlinks in the current path. This is important because Doxygen
  23. # strips this string from the paths in the generated files textually and it
  24. # wouldn't work if it contained symlinks.
  25. WXWIDGETS=`cd ../.. && pwd -P`
  26. if [ "$OSTYPE" = "cygwin" ]; then
  27. WXWIDGETS=`cygpath -w $WXWIDGETS`
  28. fi
  29. export WXWIDGETS
  30. fi
  31. if [ "$DOXYGEN" = "" ]; then
  32. DOXYGEN=doxygen
  33. fi
  34. # Check that doxygen has the correct version as different versions of it are
  35. # unfortunately not always (in fact, practically never) compatible.
  36. #
  37. # Still allow using incompatible version for some quick local testing if really
  38. # needed and 1.8.2 can't be installed for whatever reason.
  39. if [[ -z $WX_SKIP_DOXYGEN_VERSION_CHECK ]]; then
  40. doxygen_version=`$DOXYGEN --version`
  41. doxygen_version_required=1.8.2
  42. if [[ $doxygen_version != $doxygen_version_required ]]; then
  43. echo "Doxygen version $doxygen_version is not supported."
  44. echo "Please use Doxygen $doxygen_version_required or export WX_SKIP_DOXYGEN_VERSION_CHECK."
  45. exit 1
  46. fi
  47. fi
  48. # prepare folders for the cp commands below
  49. mkdir -p out/html # we need to copy files in this folder below
  50. mkdir -p out/html/generic
  51. # These are not automatically copied by Doxygen because they're not
  52. # used in doxygen documentation, only in our html footer and by our
  53. # custom aliases
  54. cp images/generic/*png out/html/generic
  55. # Defaults for settings controlled by this script
  56. export GENERATE_DOCSET="NO";
  57. export GENERATE_HTML="NO";
  58. export GENERATE_HTMLHELP="NO";
  59. export GENERATE_LATEX="NO";
  60. export GENERATE_QHP="NO";
  61. export GENERATE_XML="NO";
  62. export SEARCHENGINE="NO";
  63. export SERVER_BASED_SEARCH="NO";
  64. # Which format should we generate during this run?
  65. case "$1" in
  66. all) # All *main* formats, not all formats, here for backwards compat.
  67. export GENERATE_HTML="YES";
  68. export GENERATE_HTMLHELP="YES";
  69. export GENERATE_XML="YES";
  70. ;;
  71. chm)
  72. export GENERATE_HTML="YES";
  73. export GENERATE_HTMLHELP="YES";
  74. ;;
  75. docset)
  76. export GENERATE_DOCSET="YES";
  77. export GENERATE_HTML="YES";
  78. ;;
  79. latex)
  80. export GENERATE_LATEX="YES";
  81. ;;
  82. php) # HTML, but with PHP Search Engine
  83. export GENERATE_HTML="YES";
  84. export SEARCHENGINE="YES";
  85. export SERVER_BASED_SEARCH="YES";
  86. ;;
  87. qch)
  88. export GENERATE_HTML="YES";
  89. export GENERATE_QHP="YES";
  90. ;;
  91. xml)
  92. export GENERATE_XML="YES";
  93. ;;
  94. *) # Default to HTML only
  95. export GENERATE_HTML="YES";
  96. export SEARCHENGINE="YES";
  97. ;;
  98. esac
  99. #
  100. # NOW RUN DOXYGEN
  101. #
  102. # NB: we do this _after_ copying the required files to the output folders
  103. # otherwise when generating the CHM file with Doxygen, those files are
  104. # not included!
  105. #
  106. $DOXYGEN Doxyfile
  107. if [[ "$1" = "qch" ]]; then
  108. # we need to add missing files to the .qhp
  109. cd out/html
  110. qhelpfile="index.qhp"
  111. # remove all <file> and <files> tags
  112. cat $qhelpfile | grep -v "<file" >temp
  113. # remove last 4 lines (so we have nothing after the last <keyword> tag)
  114. lines=$(wc -l < temp)
  115. wanted=`expr $lines - 4`
  116. head -n $wanted temp >$qhelpfile
  117. # generate a list of new <keyword> tags to add to the index file; without
  118. # this step in the 'index' tab of Qt assistant the "wxWindow" class is not
  119. # present; just "wxWindow::wxWindow" ctor is listed.
  120. # NOTE: this operation is not indispensable but produces a QCH easier to use IMO.
  121. sed -e 's/<keyword name="wx[a-zA-Z~]*" id="wx\([a-zA-Z]*\)::[a-zA-Z~]*" ref="\([a-z_]*.html\)#.*"/<keyword name="wx\1" id="wx\1" ref="\2"/g' < $qhelpfile | grep "<keyword name=\"wx" | uniq >temp
  122. cat temp >>$qhelpfile
  123. echo " </keywords>" >>$qhelpfile
  124. echo " <files>" >>$qhelpfile
  125. # remove useless files to make the qch slim
  126. rm temp *map *md5
  127. # add a <file> tag for _any_ file in out/html folder except the .qhp itself
  128. for f in * */*png; do
  129. if [[ $f != $qhelpfile ]]; then
  130. echo " <file>$f</file>" >>$qhelpfile
  131. fi
  132. done
  133. # add ending tags to the qhp file
  134. echo " </files>
  135. </filterSection>
  136. </QtHelpProject>" >>$qhelpfile
  137. # replace keyword names so that they appear fully-qualified in the
  138. # "index" tab of the Qt Assistant; e.g. Fit => wxWindow::Fit
  139. # NOTE: this operation is not indispendable but produces a QCH easier to use IMO.
  140. sed -e 's/<keyword name="[a-zA-Z:~]*" id="\([a-zA-Z]*::[a-zA-Z~]*\)"/<keyword name="\1" id="\1"/g' <$qhelpfile >temp
  141. mv temp $qhelpfile
  142. # last, run qhelpgenerator:
  143. cd ../..
  144. qhelpgenerator out/html/index.qhp -o out/wx.qch
  145. fi
  146. if [[ "$1" = "docset" ]]; then
  147. BASENAME="wxWidgets-3.0" # was org.wxwidgets.doxygen.docset.wx30
  148. DOCSETNAME="$BASENAME.docset"
  149. ATOM="$BASENAME.atom"
  150. ATOMDIR="http://docs.wxwidgets.org/docsets"
  151. XAR="$BASENAME.xar"
  152. XARDIR="http://docs.wxwidgets.org/docsets"
  153. XCODE_INSTALL=`xcode-select -print-path`
  154. cd out/html
  155. DESTINATIONDIR=`pwd`/../docset
  156. mkdir -p $DESTINATIONDIR
  157. rm -rf $DESTINATIONDIR/$DOCSETNAME
  158. rm -f $DESTINATIONDIR/$XAR
  159. make DOCSET_NAME=$DESTINATIONDIR/$DOCSETNAME
  160. defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info CFBundleVersion 1.3
  161. defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info CFBundleShortVersionString 1.3
  162. defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info CFBundleName "wxWidgets 3.0"
  163. defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info DocSetFeedURL $ATOMDIR/$ATOM
  164. defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info DocSetFallbackURL http://docs.wxwidgets.org
  165. defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info DocSetDescription "API reference and conceptual documentation for wxWidgets 3.0"
  166. defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info NSHumanReadableCopyright "Copyright 1992-2014 wxWidgets team, Portions 1996 Artificial Intelligence Applications Institute"
  167. defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info isJavaScriptEnabled true
  168. defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info dashIndexFilePath index.html
  169. defaults write $DESTINATIONDIR/$DOCSETNAME/Contents/Info DocSetPlatformFamily wx
  170. $XCODE_INSTALL/usr/bin/docsetutil package -atom $DESTINATIONDIR/$ATOM -download-url $XARDIR/$XAR -output $DESTINATIONDIR/$XAR $DESTINATIONDIR/$DOCSETNAME
  171. cd ../..
  172. fi
  173. # Doxygen has the annoying habit to put the full path of the
  174. # affected files in the log file; remove it to make the log
  175. # more readable
  176. currpath=`pwd`/
  177. interfacepath=`cd ../../interface && pwd`/
  178. cat doxygen.log | sed -e "s|$currpath||g" -e "s|$interfacepath||g" > temp
  179. cat temp > doxygen.log
  180. rm temp
  181. # return to the original folder from which this script was launched
  182. cd $current