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