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